Skip to content

Dom\HTMLElement::getElementsByClassName() not implemented #18550

Open
@cscott

Description

@cscott

Description

The following code:

<?php
$doc = Dom\HTMLDocument::createFromString('');
$el = $doc->createElement('div');
$el->getElementsByClassName('foo');
echo("Success.\n");

Resulted in this output:

Error  Call to undefined method Dom\HTMLElement::getElementsByClassName().

But I expected this output instead:

Success.

Documentation for this method is at: https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
and it is standardized at https://dom.spec.whatwg.org/#ref-for-dom-element-getelementsbyclassname

PHP Version

PHP 8.4.6 (cli) (built: Apr 11 2025 02:19:40) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies

Operating System

Ubuntu 24.04.2 LTS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions