-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
new-exampleA proposal of the new exampleA proposal of the new example
Description
script
tags are interpreted as CDATA in typical html but in xhtml characters are interpreted using the standard syntax so for example, <
and &
are represented by <
and &
. You may think this is irrelevant in modern web because nobody uses xhtml but they do. Any time a script
tag is nested inside an svg
tag, it is interpreted as xhtml. See this example:
<script type="module">
const gt = 5;
const test = 5 > + 7;
console.log(+test); // > 5
</script>
<svg>
<script type="module">
const gt = 5;
const test = 5 > + 7;
console.log(+test); // > 0
</script>
</svg>
In the first script test
is set to 5 & gt
which is 5 & 5
resulting in 5
. In the second script >
is converted to >
so test
is set to 5 > +7
which is false
. Then +test
is coerced into 0
.
Metadata
Metadata
Assignees
Labels
new-exampleA proposal of the new exampleA proposal of the new example