Re: [RFC] [Discussion] DOM HTML5 parsing and serialization support
| From: | Niels Dossche | Date: | Mon, 04 Sep 2023 20:00:18 +0000 |
| Subject: | Re: [RFC] [Discussion] DOM HTML5 parsing and serialization support | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120981@lists.php.net to get a copy of this message | ||
Hey Christian
Thank you for going through my proposal.
On 04/09/2023 09:23, naitsirch@e.mail.de wrote:
> Am 02-Sep-2023 21:41:50 +0200 schrieb dossche.niels@gmail.com:
>> Hello internals
>>
>> I'm opening the discussion for my RFC "DOM HTML5 parsing and serialization
>> support".
>> https://wiki.php.net/rfc/domdocument_html5_parser
>>
>> Kind regards
>> Niels
>>
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: https://www.php.net/unsub.php
>>
>
> Hi Niels,
>
> thank you for your proposal and your work on this.
>
>> This proposal introduces the DOM\HTML5Document class that extends the
>> DOMDocument class. The reason we introduce a new class instead of replacing
>> the methods of the existing class is to ensure full backwards compatibility.
>
> Although I do not dislike your idea with a new class for HTML5 parsing I have one question. Why
> not make the decision, which parser to use, dependent from the doctype declaration at the start of
> the html document?
There's three major reasons to not depend solely on the doctype:
1) Not all documents have a doctype. So in that case, do we have to pick the old parser or the HTML5
parser?
2) People create DOM documents from scratch, without loading some code or file first.
In that case, we can't choose upfront if the document is an HTML5 document or a legacy
document.
I believe that by using a class, and thus having a clear choice upfront, this minimizes
surprises.
3) Having a separate class allows us to use the type system to restrict some users to only allow
HTML5 documents.
>
> Best regards
> Christian
Kind regards
Niels