mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
This is a long standing bug: IDs aren't properly tracked causing either outdated or plain incorrect results from getElementById. This PR implements a pragmatic solution in which we still try to use the ID lookup table to a degree, but only as a performance boost not as a "single source of truth". Full details are explained in the getElementById code. Closes GH-14349.
18 lines
531 B
PHP
18 lines
531 B
PHP
--TEST--
|
|
Bug #79701 (getElementById does not correctly work with duplicate definitions) - toggle variation
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
$dom = Dom\HTMLDocument::createFromString('<p id="test">foo</p>', LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED);
|
|
var_dump($dom->getElementById('test')?->nodeName);
|
|
$dom->documentElement->toggleAttribute('id');
|
|
var_dump($dom->getElementById('test')?->nodeName);
|
|
$dom->documentElement->toggleAttribute('id');
|
|
var_dump($dom->getElementById('test')?->nodeName);
|
|
?>
|
|
--EXPECT--
|
|
string(1) "P"
|
|
NULL
|
|
NULL
|