Skip to content

Stdlib: DOMElement::setIdAttribute() missing — getElementById without DTD returns null (ext/dom/node.c) #14493

Closed

Description

@PurHur

Problem

DOMElement::setIdAttribute() is undefined on this compiler. Zend registers the method so callers can mark an attribute as an XML ID and use DOMDocument::getElementById() without a DTD ID declaration.

Today:

fail: DOMElement::setIdAttribute() undefined

After setIdAttribute('id', true), Zend resolves getElementById('target'); VM always returns null for undeclared-ID documents.

php-src reference

Implement in ext/dom/ (PHP-in-PHP); no new C runtime logic.

Repro

./script/bootstrap-selfhost-gate.sh link  # host gate
php test/repro/maintainer_gap_dom_set_id_attribute.php          # zend=0
php bin/vm.php test/repro/maintainer_gap_dom_set_id_attribute.php  # vm=1

Done when (php-src-strict)

  • method_exists($el, 'setIdAttribute') true on DOMElement
  • setIdAttribute('id', true) + getElementById('target') returns the element (no DTD)
  • Targeted compliance guard under test/compliance/ or test/repro/

Refs #6189, #14455, #1492

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 1, 2026
  2. PurHur commented on Jul 1, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issue #14493, continuing after #14576 merge)

  3. PurHur commented on Jul 1, 2026

    @PurHur
    OwnerAuthor

    Merged via #14588.

    Verification: repro OK; compliance dom_element_set_id_attribute.phpt; PHPUnit --filter dom_element_set_id_attribute (VM+JIT); bin/compile.php -l on repro.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions