You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 09235a9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(html): read a foreign style body as character data (#22258)
A `<style>` body is raw text in the HTML namespace, so its source is its
text. The same element in a foreign subtree holds character data, where a
character reference stands for what it names — so `<svg><style>.a{…}`
fed the CSS pipeline the literal `.a`, an invalid selector, instead of
the rule `.a` a browser reads there.
The namespace now decides which of the two the body is, as it already does
for `<script>` and on the printing side. Because the body is decoded going
in, the write-back escapes it as text coming back out, keeping the round
trip a fixed point where an `&` in the processed CSS would otherwise be
re-read as a character reference.
* Represents inline CSS in an HTML module — either a `<style>...</style>`
36
48
* block (a stylesheet) or an element's `style="..."` attribute (a CSS
@@ -47,14 +59,23 @@ class HtmlInlineStyleDependency extends ModuleDependency {
47
59
* @param {Range} range range of the inline CSS content (between `<style>` and `</style>`, or the `style` attribute value)
48
60
* @param {boolean=} attribute true when the source is a `style="..."` attribute (a block's contents) rather than a `<style>` block (stylesheet)
49
61
* @param {boolean=} inAttribute true when the range is an attribute value (decoded on parse, so the processed CSS must be re-escaped on write-back); defaults to `attribute` — differs only for attribute values parsed as full stylesheets
62
+
* @param {boolean=} characterData true when the range is a `<style>` body in a foreign (SVG/MathML) subtree, where the content model is character data rather than raw text, so the processed CSS is escaped as text on write-back
0 commit comments