IDLeDOM

IDLeDOM is a set of PHP interfaces automatically generated from the HTML DOM API, based on a rigorous PHP binding of the WHATWG WebIDL specification. It is  not  a DOM implementation (look at Dodo for that), merely the interfaces that a compatible DOM library will implement. It does contain a set of helpers and stubs for common functionality.

It uses wikimedia/webidl to parse the upstream DOM spec, but this is not required at runtime.

In MediaWiki
IDLeDOM will become available in MediaWiki as a composer dependency of  (via  ) when the Dodo library is mature.

Everywhere else
Install the wikimedia/idle-dom package from Packagist:

composer require wikimedia/idle-dom

Semantic versioning is used.

The major version number will be incremented for every change that breaks backwards compatibility.

Architecture overview
For full reference documentation, please see the documentation generated from the source (or the source itself)


 * Generated API documentation

WebIDL binding
The full PHP binding is documented in WebIDL.md in the source tree. It is intended to be largely compatible with the ad hoc binding used for the PHP built-in DOM extension. Explicit getter and setter functions are used for attributes, but PHP magic methods are used to allow property-style access. The best performance will be obtained by using the explicit getters and setters, however.

Writing a new DOM implementation
To write a new DOM implementation you will be implementing the interface types in. This library provides two traits for most interfaces in order to ease the task:


 * 1) The helper trait in   will implement the magic   and   methods for interfaces and dictionaries,   methods for dictionaries, the magic   method for callback classes, and   methods for callbacks and dictionaries to turn a   and associative-array, respectively, into the proper callback or dictionary type. The helper will also implement   and   where appropriate.
 * 2) The stub trait in   will stub out all methods of the interface by implementing them to throw the exception returned by   (which can be your own subclass of   or whatever you like).  This helps bootstrap a DOM implementation and ensures that new methods can be added to the DOM spec, and by extension to the   interfaces, without breaking code which implements these interfaces.

Putting these together, the first few lines of a typical DOM implementation will look something like this:

Hacking on IDLeDOM
To regenerate the interfaces in  from the WebIDL sources in  : To run tests: