Skip to content

dom: register unprefixed id attributes from foreign content in HTML - #23598

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:promote/dom-foreign-id
Open

dom: register unprefixed id attributes from foreign content in HTML#23598
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:promote/dom-foreign-id

Conversation

@iliaal

@iliaal iliaal commented Sep 6, 2026

Copy link
Copy Markdown
Member

The HTML5 parser bridge only marked an id attribute as XML_ATTRIBUTE_ID when the attribute's lexbor namespace was LXB_NS_HTML, so ids on SVG and MathML elements never reached Dom\HTMLDocument::getElementById().

The condition the bridge wants is that the attribute is unprefixed, which lxml_attr->ns already records: the struct is memset to zero and ns is assigned only in the xmlns, xlink and xml branches above. Testing lxml_attr->ns == NULL covers every element namespace instead of an enumerated subset, and the test pins that a namespaced xml:id is still not registered.

The HTML5 parser bridge only marked an id attribute as XML_ATTRIBUTE_ID
when the attribute sat in the HTML namespace, so ids on SVG and MathML
elements never reached getElementById(). The condition the bridge wants
is that the attribute itself is unprefixed, which lxml_attr->ns already
records: it is only set for the xmlns, xlink and xml namespaces.

Closes phpGH-23598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant