Skip to content

ext/dom: index HTML id attributes for getElementById() after loadHTML() (#15251) - #15306

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-15251-dom-loadhtml-get-element-by-id
Jul 3, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-15251-dom-loadhtml-get-element-by-id

Conversation

@PurHur

@PurHur PurHur commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

indexElementIdsRecursive() now treats plain id attributes as ID-map entries when the document was loaded via loadHTML(), matching php-src HTML getElementById() behavior.

php-src reference: ext/dom/document.c — HTML document id table

Closes #15251

Test plan

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_dom_loadhtml_get_element_by_id.php'
# ok

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_dom_get_element_by_id.php'
# null / missing_null (XML without DTD id — unchanged)

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_dom_get_element_by_id_dtd.php'
# dtd_ok (DTD ID path unchanged)

./script/docker-exec.sh -- bash -lc 'php vendor/bin/phpunit --filter document_loadhtml_get_element_by_id'
# OK (2 tests)

php bin/compile.php -l test/repro/maintainer_gap_dom_loadhtml_get_element_by_id.php
# AOT lint clean

Made with Cursor

During document ID reindex, treat plain `id` attributes as ID map entries
when the document was loaded via loadHTML(), matching php-src HTML behavior.

Closes #15251

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 2737241 into master Jul 3, 2026
@PurHur
PurHur deleted the agent/issue-15251-dom-loadhtml-get-element-by-id branch July 3, 2026 04:16
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.

Stdlib: DOMDocument::getElementById() after loadHTML() — HTML id attribute not indexed (ext/dom/document.c)

1 participant