Format <script> inside SVG (#14400)

This commit is contained in:
fisker Cheung authored and GitHub committed 2023-04-10 10:43:48 +08:00
1 parent 686320a88c
commit ecfa324b69
9 files changed
+350 -33

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
#### Format `<script>` inside SVG (#14400 by @fisker)
<!-- prettier-ignore -->
```html
<!-- Input -->
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<script>
document.addEventListener(
'DOMContentLoaded', () => {
const element = document.getElementById('foo')
if (element) {
element.fillStyle = 'currentColor'
}
});
</script>
</svg>
<!-- Prettier stable -->
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<script>
document.addEventListener( 'DOMContentLoaded', () => { const element =
document.getElementById('foo') if (element) { element.fillStyle =
'currentColor' } });
</script>
</svg>
<!-- Prettier main -->
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<script>
document.addEventListener("DOMContentLoaded", () => {
const element = document.getElementById("foo");
if (element) {
element.fillStyle = "currentColor";
}
});
</script>
</svg>
```