Skip to content

Serialization special casing of style, script, etc. needs to be namespace-dependent #333

@domenic

Description

@domenic

This escaping:

if (
parentTn === $.STYLE ||
parentTn === $.SCRIPT ||
parentTn === $.XMP ||
parentTn === $.IFRAME ||
parentTn === $.NOEMBED ||
parentTn === $.NOFRAMES ||
parentTn === $.PLAINTEXT ||
parentTn === $.NOSCRIPT
) {
this.html += content;
} else {
this.html += Serializer.escapeString(content, false);
}
is meant to mimic HTML's

If the parent of current node is a style, script, xmp, iframe, noembed, noframes, or plaintext element, or if the parent of current node is a noscript element and scripting is enabled for the node, then append the value of current node's data IDL attribute literally.

However, while HTML is referring specifically to those nodes in the HTML namespace, parse5 does not check the namespace before serializing.

This leads to the following wrong result in jsdom: https://runkit.com/domenicdenicola/6044168f463fb4001a725307 compared to browsers: http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=8981

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions