4.1.4
- FIX: Names and values from a document, such as tag names, attribute names, and the values of
dir,type,
andcontenteditable, are no longer held in memory after the document is released. They were lowered for
comparison through a cache shared by every call, which limited the number of strings but not their size, so a
long running process matching untrusted documents could hold many large strings. Names are now cached only for
the life of a singleselect(),match(),filter(), orclosest()call, and values are not cached. A value
that is only compared to keywords, such asdir="rtl", is not lowered when it is longer than any keyword, as it
can't match one, so a long value adds nothing to the cost of matching. - FIX:
:definednow follows the HTML specification's custom element names in HTML documents, as Chrome and
Firefox do. Names reserved by HTML, such asfont-face, are not custom element names and are matched, while a
hyphenated name with a colon, such asprefix:my-element, is one and is no longer matched. When the parser records
namespaces, ashtml5libdoes, hyphenated SVG and MathML elements are matched too, as they can't be custom
elements (@Muneer320). - FIX:
:definedin XHTML documents now follows the element's namespace instead of its prefix, as browsers do.
Previously, an element in the default namespace was treated as prefixed, so custom elements such as<x-foo>
were matched. Now only elements in the XHTML namespace can be undefined, whatever their prefix. Names with an
uppercase ASCII letter, and names reserved by HTML, such asfont-face, are not custom element names and are
matched. - FIX:
:rootno longer matches an element that has a top level text sibling made only of non-ASCII white space,
such as a non-breaking space, as such text was treated as white space. Only HTML white space is ignored, as with
:empty. - FIX:
[*|attr]now matches the attribute in any namespace, such asxlink:hreffor[*|href], and not only
the attribute without a namespace. When an element has several, such ashrefandxlink:href,[*|attr=value]
matches if any of them has the value, and[*|attr!=value]only if none of them does. - FIX: Attribute names are only matched without case sensitivity on HTML elements in HTML documents, as the HTML
specification says and Firefox and Safari do. On SVG and MathML elements in an HTML document, the name must now
match exactly, so[viewbox]no longer matches an SVG element'sviewBox. A document parsed without namespaces,
such as withhtml.parser, only has HTML elements, so it is unaffected. - FIX: Element names are only matched without case sensitivity on HTML elements in HTML documents, as the HTML
specification says and Firefox and Safari do. On SVG and MathML elements in an HTML document, the name must now
match exactly, solineargradientno longer matches an SVG element'slinearGradient. A document parsed without
namespaces, such as withhtml.parser, only has HTML elements, so it is unaffected (@Juanna470).