-
Couldn't load subscription status.
- Fork 8k
Open
Description
Description
The following code:
<?php
$d = \Dom\HTMLDocument::createFromString('<p id="a">b</p><p id="a">c</p>');
$df = $d->createDocumentFragment();
$df->getElementById('a');Resulted in this output:
Error Call to undefined method Dom\DocumentFragment::getElementById().
But I expected this output instead:
(no output)
This method is present in the DOM spec: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment/getElementById and the similar method ::querySelector is implemented; I can't tell if querySelector actually uses the ID index though or does a linear scan through the fragment. (Aka, this method should not just be implemented, it is expected to have O(1) performance.)
PHP Version
PHP 8.4.13 (cli) (built: Oct 1 2025 20:34:15) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.13, Copyright (c) Zend Technologies
with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies
Operating System
Ubuntu 24.04.1