ivopetkov / html5-dom-document-php

A better HTML5 parser for PHP.
MIT License
599 stars 40 forks source link

Feature request: `HTML5DOMDocumentFragment` with `appendHTML()` #57

Open rulatir opened 1 year ago

rulatir commented 1 year ago

Since XML is not HTML, using native DOMDocumentFragment and its appendXML() method is risky and prone to all the very same issues this library is trying to address.

ivopetkov commented 1 year ago

There are already two methods to help you with this. Please take a look at HTML5DOMDocument::insertHTML() and HTML5DOMDocument::insertHTMLMulti(). There is an example at https://github.com/ivopetkov/html5-dom-document-php (in the README section).

rulatir commented 1 year ago

I am implementing a contract that requires me to return a DOMDocumentFragment.

ivopetkov commented 1 year ago

Would you provide some example code so I can better understand the problem you're trying to solve and the API you're requesting?

rulatir commented 1 year ago

I must return a DOMDocumentFragment, because that is what a contract enforced by a 3rd-party library requires of me. I must also be able to assemble the contents of the resulting DOMDocumentFragment from pieces, which can be:

YES, I can do this:

ivopetkov commented 1 year ago

Currently, I do not have plans to add fragments support. Maybe someday. Feel free to contribute such code to the library.