NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #1382 most downloaded on Packagist
Modern DOM API.
Latest stable
v4.2.2
Last release 3 months ago
13 Aug 2026
Release timing varies
gaps range from 3 weeks to 12 months
Nearly every release is documented
notes for 54 of 56 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
58 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
Appending an empty document fragment now returns the fragment correctly. This release also includes a regression test and a few improvements to the pr
Appending an empty document fragment now returns the fragment correctly. This release also includes a regression test and a few improvements to the project's checks.
Textarea values and ampersands #476 by @g105b in https://github.com/phpgt/Dom/pull/477
Full Changelog: https://github.com/phpgt/Dom/compare/v4.2.0...v4.2.1
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Select::options and optgroup bugfix by @g105b in https://github.com/phpgt/Dom/pull/470
Select::options and optgroup bugfix by @g105b in https://github.com/phpgt/Dom/pull/470empty() behaves as expected with value property closes #471 by @g105b in https://github.com/phpgt/Dom/pull/472Full Changelog: https://github.com/phpgt/Dom/compare/v4.1.9...v4.2.0
All versions 8.1-8.5 are compatible in this release, resolving any depreciation warnings too.
All versions 8.1-8.5 are compatible in this release, resolving any depreciation warnings too.
Full Changelog: https://github.com/phpgt/Dom/compare/v4.1.8...v4.1.9
Nothing published for this version
Prevent DocumentFragment from causing internal PHP error by using append() by @g105b in https://github.com/PhpGt/Dom/pull/454
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.6...v4.1.7
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.6...v4.1.7
DOMStringMap improvements with PHP 8.3 support by @g105b in https://github.com/PhpGt/Dom/pull/450
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.5...v4.1.6
This release is made today as the most recent version of PHP 8.1 and PHP 8.2 introduce a backwards-breaking change to DOMDocument::registerNodeClass()…
This release is made today as the most recent version of PHP 8.1 and PHP 8.2 introduce a backwards-breaking change to DOMDocument::registerNodeClass() - Argument #2 ($extendedClass) must not be an abstract class. Thanks to @szymanek-event-it for the fix, using the correct instance of the current document object.
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.4...v4.1.5
build: loosen psr/http-message by @g105b in https://github.com/PhpGt/Dom/pull/443
(discussion regarding this change here: #424
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.3...v4.1.4
maintenance: kill off scrutinizer (RIP) by @g105b in https://github.com/PhpGt/Dom/pull/435
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.2...v4.1.3
This minor release introduces a lot more quality assurance checks in Github Actions, along with a small bugfix when using an element's data-* attribut
This minor release introduces a lot more quality assurance checks in Github Actions, along with a small bugfix when using an element's data-* attributes.
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.1.0...v4.1.2
maintenance: dependabot by @g105b in https://github.com/PhpGt/Dom/pull/392
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.0.3...v4.1.1
Thanks to @kartofelek007 for their help in diagnosing an issue relating to non-UTF-8 characters.
Thanks to @kartofelek007 for their help in diagnosing an issue relating to non-UTF-8 characters.
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.0.3...v4.1.0
This minor patch release introduces some changes to the attributes that are exposed on different HTMLElement classes. Each change brings the library c
This minor patch release introduces some changes to the attributes that are exposed on different HTMLElement classes. Each change brings the library closer to the W3C standard.
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.0.2...v4.0.3
Bump phpstan/phpstan from 1.8.0 to 1.8.2 by @dependabot in https://github.com/PhpGt/Dom/pull/377
Full Changelog: https://github.com/PhpGt/Dom/compare/v4.0.1...v4.0.2
Updating IDs on the fly by @g105b in https://github.com/PhpGt/Dom/pull/375
In v3, a Facade was implemented to reach 100% compatibility with W3C's specification.
In v3, a Facade was implemented to reach 100% compatibility with W3C's specification.
In this v4 release, we see a drop of the Facade to go back to a native DOMDocument extension. This is because the native libxml bindings are extremely performant, and plain PHP simply can't compete. We used the existing unit tests to ensure there isn't any regression in functionality, but there are certain new quirks due to the libxml implementation, clearly documented in the README.
PHP 8.1 type deprecations are resolved
In this release:
<script> tags (https://github.com/PhpGt/Dom/pull/324)This minor patch release compares between null and falsey values, fixing a bug where elements with "0" as their value would not be selected if they al
This minor patch release compares between null and falsey values, fixing a bug where elements with "0" as their value would not be selected if they also had a textContent value.
Unicode support for emoji in innerHTML
value attribute of a HTMLSelectElementFull Changelog: https://github.com/PhpGt/Dom/compare/v3.0.0...v3.1.0
This new version has been a long time in development, but now is the time to make a formal v3 release.
This new version has been a long time in development, but now is the time to make a formal v3 release.
The RC version releases were already fully unit tested, but have been used heavily in real world projects over the last few months, where many improvements have been found.
This stable release is being made after the last static analysis improvements have been made.
As always, have fun and stay productive!
This second release candidate is made ready for full release within the month. Included within this RC are minor tweaks, including typehint improvemen
This second release candidate is made ready for full release within the month. Included within this RC are minor tweaks, including typehint improvements and the implementation of RadioNodeList. Any future functionality will be made as subsequent v3 releases, the only updates this month will be minor tweaks or bugfixes.
In this release we take advantage of the facade design pattern to provide a set of classes that iron out any creases with the W3C DOM Specification. I
In this release we take advantage of the facade design pattern to provide a set of classes that iron out any creases with the W3C DOM Specification. In previous versions, we were using libxml-provided classess (DOMDocument, DOMNode, etc.) and extending with our own functionality, but this meant that it was impossible to deviate from the inheritance model supplied by libxml.
The footprint of this version should be identical, but with added classes to represent the different types of Node extension.
Creating objects within the DOM is typically done through Factory classes, as most constructors are private to allow for more controlled/abstracted object creation.
Please test this release candidate and submit feedback through the issues list.
Have fun!
Thanks to @sidolov for their support keeping v2 up to date. This is a minor release with only a few tweaks to keep the v2 release compatible with the
Thanks to @sidolov for their support keeping v2 up to date. This is a minor release with only a few tweaks to keep the v2 release compatible with the latest release of PHP.
Full Changelog: https://github.com/PhpGt/Dom/compare/v2.2.3...v2.2.4
Massive thanks to @andrewbess for this improvement to the v2 release.
Massive thanks to @andrewbess for this improvement to the v2 release.
A few minor updates to the CI process have been made, along with a new test and functionality fix to innerHTML thanks to @speich.
A few minor updates to the CI process have been made, along with a new test and functionality fix to innerHTML thanks to @speich.
Bugfix: When working with a textarea's value attribute, getting and setting on the same request would not persist data.
value attribute, getting and setting on the same request would not persist data.disabled, checked, etc. all correspond to their correct HTML attributes.This release is very minor in scope, but has knock-on effects to DomTemplate, specifically PhpGt/DomTemplate#124
This release is very minor in scope, but has knock-on effects to DomTemplate, specifically PhpGt/DomTemplate#124
The changes in this release mean that setting an innerHTML of an empty string is much more efficient, and this can now be done on DocumentFragments too. Before, this would cause an exception, due to there not being a parent element.
Changes in DomTemplate are incoming so that binding an empty dataset to an list element will set the innerHTML to an empty string, which means that the :empty CSS selector will now be valid for empty lists.
There are no new features included within this release, just improvements to the way Element object properties are handled, and how Element and Docume
There are no new features included within this release, just improvements to the way Element object properties are handled, and how Element and Document objects are tested. Have fun.
Unit test coverage on the Element class is now improved to 100%, thanks to @Jelmergu.
Unit test coverage on the Element class is now improved to 100%, thanks to @Jelmergu.
The Element class has been improved to take advantage of the new CssXPath updates, along with fixing getter/setter for the value attribute, and a check for the property map constant which improves working with non-html documents such as XML.
The value property of Elements is made more consistent in this release. Certain element types behave differently when getting or setting the value pro
The value property of Elements is made more consistent in this release. Certain element types behave differently when getting or setting the value property - some access the value attribute directly, others affect the state of their children.
The PSR-7 StreamInterface has been implemented on the Document/HTMLDocument classes to improve interoperability when used within other frameworks. The
The PSR-7 StreamInterface has been implemented on the Document/HTMLDocument classes to improve interoperability when used within other frameworks. There is no new functionality due to this, so only a minor version increment is necessary.
Along with the interface implementation, a couple of bugfixes are released here too:
No new features in this release, just a selection of bugfixes and improvements.
No new features in this release, just a selection of bugfixes and improvements.
This release is minor in footprint, but potentially major in efficiency increase. This is only noticable on large trees, but when you have thousands o
This release is minor in footprint, but potentially major in efficiency increase. This is only noticable on large trees, but when you have thousands of Nodes in a Document, you can cut the page render time in half.
Main improvements lie in the iteration of NodeList objects. There is also improvement to the distinction between a NodeList and HTMLCollection (HTMLCollection objects can only contain Elements, not Nodes).
This release fixes an issue when getting the value attribute of a select element.
This release fixes an issue when getting the value attribute of a select element.
If a select element has option children that do not have the value attribute, getting or setting the value property would previously fail due to a Typ
If a select element has option children that do not have the value attribute, getting or setting the value property would previously fail due to a TypeError. The expected behaviour is to fall back to the value of innerText, which is how it is treated in this release. Tests have been updated to check this behaviour.
The Attr class has received typehints for the Node types it returns, and the introduction of Attr::remove() adds a missing functionality not shared by
The Attr class has received typehints for the Node types it returns, and the introduction of Attr::remove() adds a missing functionality not shared by Element::remove()
…so in theory there will not be any backwards-breaking changes, but theory is only ever as good as its latest observation. Please let us know using the…
The major change featured in this release is the introduction of PHP.Gt/CssXPath - our own CSS to XPath translator, meaning we can remove the huge dependency tree of Symfony Components and concentrate on a much more terse and efficient codebase.
All current v1 unit tests have been kept with the introduction of our own translator, so in theory there will not be any backwards-breaking changes, but theory is only ever as good as its latest observation. Please let us know using the issue tracker if this release affects your codebase (also, let us know if it has a positive effect - we'd love to hear from you).
Other notable changes in this release include:
<body> tag will be automatically inferred, as is the same in web browsers$link->href = "/page"; versus the longhand $link->setAttribute("href", "/page");checked property set to true.Please feedback to the contributors how you find this release, either through the issue tracker, or drop a message to dom@php.gt
Have fun and stay productive!
Amongst many updates to the unit tests, this release introduces new tests and functionality for "multiple" select elements, along with proper handling
Amongst many updates to the unit tests, this release introduces new tests and functionality for "multiple" select elements, along with proper handling of the "selected" property of checkboxes, radioboxes and selects.
Thanks to @ognjen-petrovic we now have a FormTest class specifically for testing form-related functionality.
Thanks to @ognjen-petrovic we now have a FormTest class specifically for testing form-related functionality.
Implemented in this release is the checked attribute on Form elements, along with the following small changes:
The dataset property on the HTMLElement interface provides read/write access to all the custom data attributes (data-*) set on the element. This acces
The dataset property on the HTMLElement interface provides read/write access to all the custom data attributes (data-*) set on the element. This access is available both in HTML and within the DOM. It is a StringMap, one entry for each custom data attribute. Note that the dataset property itself can be read, but not directly written. Instead, all writes must be to the individual properties within the dataset, which in turn represent the data attributes. Note also that an HTML data-attribute and its corresponding DOM dataset.property do not share the same name, but they are always similar.
Read more here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
The following two improvements have been made to better reflect the standard DOM behaviour:
The following two improvements have been made to better reflect the standard DOM behaviour:
innerHTML - a fragment must be used to set the innerHTML of an element, but fragments do not allow non-XML content to be appended! A temporary document is created to overcome this flaw in libxml.NodeList Iterator - it is possible for an item in the iterator to be set to null (https://dom.spec.whatwg.org/#interface-nodelist)Thanks to @jaroslavtyc for catching a bug that affected getting ID by magic __get access. The PHP return type now allows the correct nullable type for
Thanks to @jaroslavtyc for catching a bug that affected getting ID by magic __get access. The PHP return type now allows the correct nullable type for when there is no element by the provided ID.
Dependencies have been bumped up with this minor release.
innerText synonymous for textContent on Element
innerText synonymous for textContent on ElementgetAttribute compatibility with DOM Level 4nullNodeList bug fixed where Countable affects Iterator keyStandardisation of scope resolution
All DOM class implementations' methods/properties tested
This release marks the point where all features are implemented and tested for the current list of classes. Functionality lists were provided by MDN d
This release marks the point where all features are implemented and tested for the current list of classes. Functionality lists were provided by MDN documentation for each DOM class.
Nothing published for this version
All files are updated to comply with the [PHP.Gt Styleguide][styleguide].
Along with the implementation of DOM TokenList, we are now at 100% code coverage!
Along with the implementation of DOM TokenList, we are now at 100% code coverage!
Here we have another release of more tests. We'll be at 100% soon!
Here we have another release of more tests. We'll be at 100% soon!
The following extra tests are now made:
The following extra tests are now made:
For completeness, the XMLDocument class is introduced.
For completeness, the XMLDocument class is introduced.
Improved closest selector mechanism.
closest selector mechanism.Thanks to Álvaro Guimarães for most of the work in this release.
Thanks to Álvaro Guimarães for most of the work in this release.
HTMLCollection is now Countable.HTMLCollection implements ArrayAccess methods.Element::closest method.HTMLDocument can be constructed from existing native DOMDocument.Implement missing properties such as:
Implement missing properties such as:
$document->title$document->images$document->anchorsAll DOM interfaces that are currently within the repo are marked up with their PHPDoc blocks.
All DOM interfaces that are currently within the repo are marked up with their PHPDoc blocks.
Certain methods have been moved to their correct locations and tests adjusted accordingly.
The basics of the modern DOM implementation we have been using within browsers.
The basics of the modern DOM implementation we have been using within browsers.
There are a few known gaps in functionality, and tests need to be hardened before a production release.
One column per quarter.