Skip to content

Conversation

@nielsdos
Copy link
Member

This worked for non-parsed elements already, but not for elements where xmlAddID() returns early due to the ID already existing. In that case what was missing is marking the attribute as an ID.

…r nodes are removed

This worked for non-parsed elements already, but not for elements where
xmlAddID() returns early due to the ID already existing.
In that case what was missing is marking the attribute as an ID.
if (local_name_length == 2 && local_name[0] == 'i' && local_name[1] == 'd' && attr->node.ns == LXB_NS_HTML) {
xmlAddID(NULL, lxml_doc, value, lxml_attr);
if (xmlAddID(NULL, lxml_doc, value, lxml_attr) == 0) {
/* If the ID already exists, the ID attribute still needs to be marked as an ID. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confused by one thing though, would it happen only if xmlAddID 1st arg was not NULL ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument is a validation context. The only influence it has is in error reporting: if you pass a non-NULL pointer the error handler of that validation context will be used to emit an error saying there's a duplicate ID.

@nielsdos nielsdos closed this in cb1f932 Oct 25, 2025
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.

\Dom\Document::getElementById() is inconsistent after nodes are removed

2 participants