Extending DOMNode

So what? What is the problem with DOMNode?

The problem with DOMNode is, that when you replace it, it will work for DOMNode itself. But it will not work for all other elements that extend DOMNode. Because you just replace an element, you don’t put your element into the chain of extentings. Which means, you will have your functionality if you retrieve a DOMNode directly. If you retrieve it with for instance with getElementById then you will have an DOMElement which extends the original DOMNode and not yours.

It may work, if you rewrite the the getElementById and getElementsByTagName functions from DOMDocument, but that may be too high effort and I’m not sure that this will work.