Skip to content

[DOM] Register ids of SVG and MathML elements in the HTML5 parser - #254

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/dom-svg-mathml-getelementbyid
Closed

[DOM] Register ids of SVG and MathML elements in the HTML5 parser#254
iliaal wants to merge 1 commit into
PHP-8.4from
fix/dom-svg-mathml-getelementbyid

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Dom\HTMLDocument::getElementById() missed ids of SVG and MathML elements because the lexbor-to-libxml2 bridge in the HTML5 parser only registered id attributes when they were in the HTML namespace, while SVG and MathML elements carry their id attribute in their own namespace. The bridge now also registers the id attribute for elements in the SVG and MathML namespaces so that getElementById() finds them just like it does for HTML elements. Runtime paths (setAttribute(), setIdAttribute()) already handled this correctly and were audited as unaffected.

getElementById() relies on the parser registering id attributes in the
document ID cache. The lexbor bridge only registered them when the
attribute was in the HTML namespace, so the ids of SVG and MathML
elements were invisible. Sibling audit: dom_check_register_attribute_id()
and php_set_attribute_id() handle runtime attribute creation and are
namespace-correct already.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
@iliaal

iliaal commented Sep 6, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#23598.

@iliaal iliaal closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant