Skip to content

Conversation

@ddebin
Copy link

@ddebin ddebin commented Dec 5, 2025

Inspired by #5, keep backward DOMDocument compatibility for PHP <8.4.
I can add a PR to brick/schema (to allow passing a Dom\Document) if accepted.

@ddebin ddebin mentioned this pull request Dec 6, 2025
@adamjgriffith
Copy link

@ddebin Firstly thanks for picking this up!

FYI I left the afformentioned PR in draft because my understanding of using the HTML_NO_DEFAULT_NS constant nullifies most of the advantages of the new PHP 8.4 DOM classes and my needs moved on from this package.

It is also possible to pass Dom\HTML_NO_DEFAULT_NS to disable the use of the HTML namespace and the template element. This should only be used if the implications are properly understood.

From https://www.php.net/manual/en/dom-htmldocument.createfromstring.php

Do you properly understand the implications of using this constant?

@ddebin
Copy link
Author

ddebin commented Dec 15, 2025

@adamjgriffith I'm not an expert. I see this option as a way to treat HTML5 as a proper XML DOM, but it's not. Per https://stackoverflow.com/a/79443754/377645, it seems HTML_NO_DEFAULT_NS should have been the default way, as 99% of cases need this option.

@ddebin
Copy link
Author

ddebin commented Dec 15, 2025

Some explanation here:

To ease migration from HTML to XML, user agents conforming to this specification will place elements in HTML in the http://www.w3.org/1999/xhtml namespace, at least for the purposes of the DOM and CSS. The term "HTML elements" refers to any element in that namespace, even in XML documents.

With HTML_NO_DEFAULT_NS, HTML elements are not placed in this namespace. It may impact the way of parsing and the DOM structure, but in this project, parsing is done (example) without a namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants