Modern DOM library written in PHP for HTML documents
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Dustin Wilson 2e07af4edb Added ChildNode::before, started on a bit of documentation 3 years ago
lib Added ChildNode::before, started on a bit of documentation 3 years ago
tests Added ChildNode::before, started on a bit of documentation 3 years ago
vendor-bin More Element tests 3 years ago
.gitattributes Add missing tests for charset pre-scan 3 years ago
.gitignore Fixed gitignore 3 years ago
AUTHORS Added authors file and updated license 6 years ago
LICENSE Added authors file and updated license 6 years ago
README.md Added ChildNode::before, started on a bit of documentation 3 years ago
RoboFile.php Moved MagicProperties and Exception to framework repository 3 years ago
composer.json Dropping support for PHP 7.4 3 years ago
composer.lock Element 100% code coverage 3 years ago
robo Basic skeleton of test suite 5 years ago
robo.bat Basic skeleton of test suite 5 years ago

README.md

HTML DOM

Modern DOM library written in PHP for HTML documents.

Usage

Coming soon

Limitations

The primary aim of this library is accuracy. If the document model differs from what the specification mandates, this is probably a bug. However, we are also constrained by PHP, which imposes various limtations. These are as follows:

  1. Due to PHP's DOM being designed for XML 1.0 Second Edition, element and attribute names which are illegal in XML 1.0 Second Edition are mangled as recommended by the specification.
  2. Due to a PHP bug which severely degrades performance with large documents and in consideration of existing PHP software, HTML elements are placed in the null namespace rather than in the HTML namespace.
  3. While DOMDocumentType can be extended and registered by PHP's DOMDocument::registerNodeClass DOMImplementation cannot; this means that doctypes created with DOMImplementation::createDocumentType can't ever be a registered class. Therefore, doctypes remain as DOMDocumentType in this library and retain the same limitations as ones in PHP's DOM.
  4. The DOM specification mentions that HTMLCollection has to be kept around for backwards compatibility in browsers, but any new implementations should use sequence<T> instead which is essentially just a typed array object of some kind. Any methods should also return a copy of an object instead of a reference to the platform object, meaning the bane of any web developer's existence -- live lists -- shouldn't be a thing anymore either. Since this implementation is not a fully userland PHP implementation of the DOM but instead an extension of it, this implementation will use DOMNodeList where PHP's DOM would normally and array for anything that cannot be hacked to use DOMNodeList to keep things consistent.