Hi internals
I'm opening the vote of my RFC "New ext-dom features in PHP 8.4".
RFC link: https://wiki.php.net/rfc/dom_additions_84
Voting runs until 24th of June 21:00 GMT+2.
Kind regards
Niels
On Mon, Jun 10, 2024 at 1:15 PM Niels Dossche dossche.niels@gmail.com
wrote:
Hi internals
I'm opening the vote of my RFC "New ext-dom features in PHP 8.4".
RFC link: https://wiki.php.net/rfc/dom_additions_84
Voting runs until 24th of June 21:00 GMT+2.Kind regards
Niels
Question: why is Dom\Document::$head
marked as readonly?
--
Matthew Weier O'Phinney
mweierophinney@gmail.com
https://mwop.net/
he/him
Hi internals I'm opening the vote of my RFC "New ext-dom features in PHP 8.4". RFC link: https://wiki.php.net/rfc/dom_additions_84 <https://wiki.php.net/rfc/dom_additions_84> Voting runs until 24th of June 21:00 GMT+2. Kind regards Niels
Question: why is
Dom\Document::$head
marked as readonly?
The HTML spec defines the head property to be readonly: https://html.spec.whatwg.org/#document
That's why $head is marked readonly.
So I guess the question becomes "why does the HTML spec define it this way?"
I couldn't find a conclusive answer to this, it looks like this has been read-only since HTML's early days...
I thought about it but don't really see a technical reason why this is the case. If I had to take a guess I'd say it's for simplicity sake.
--
Matthew Weier O'Phinney
mweierophinney@gmail.com mailto:mweierophinney@gmail.com
https://mwop.net/ https://mwop.net/
he/him
Kind regards
Niels
On Mon, Jun 10, 2024 at 1:15 PM Niels Dossche <dossche.niels@gmail.com
mailto:dossche.niels@gmail.com> wrote:Hi internals I'm opening the vote of my RFC "New ext-dom features in PHP 8.4". RFC link: https://wiki.php.net/rfc/dom_additions_84 <
https://wiki.php.net/rfc/dom_additions_84>
Voting runs until 24th of June 21:00 GMT+2. Kind regards Niels
Question: why is
Dom\Document::$head
marked as readonly?The HTML spec defines the head property to be readonly:
https://html.spec.whatwg.org/#document
That's why $head is marked readonly.So I guess the question becomes "why does the HTML spec define it this
way?"
I couldn't find a conclusive answer to this, it looks like this has been
read-only since HTML's early days...
I thought about it but don't really see a technical reason why this is the
case. If I had to take a guess I'd say it's for simplicity sake.he/him
I can understand that from a browser perspective, but from PHP, where we
might be manipulating HTML to send back to the client, having it readonly
would be a pretty big hindrance.
> > > > > Hi internals > > I'm opening the vote of my RFC "New ext-dom features in PHP 8.4". > RFC link: https://wiki.php.net/rfc/dom_additions_84 <https://wiki.php.net/rfc/dom_additions_84> <https://wiki.php.net/rfc/dom_additions_84 <https://wiki.php.net/rfc/dom_additions_84>> > Voting runs until 24th of June 21:00 GMT+2. > > Kind regards > Niels > > > Question: why is `Dom\Document::$head` marked as readonly? The HTML spec defines the head property to be readonly: https://html.spec.whatwg.org/#document <https://html.spec.whatwg.org/#document> That's why $head is marked readonly. So I guess the question becomes "why does the HTML spec define it this way?" I couldn't find a conclusive answer to this, it looks like this has been read-only since HTML's early days... I thought about it but don't really see a technical reason why this is the case. If I had to take a guess I'd say it's for simplicity sake. > he/him
I can understand that from a browser perspective, but from PHP, where we might be manipulating HTML to send back to the client, having it readonly would be a pretty big hindrance.
Would it?
Note that only the binding is readonly, you can manipulate the head element as you wish.
e.g. $doc->head->replaceWith($another_element);
is still possible and not much more difficult than $doc->head = $another_element;
.
I could add a setter for the head element, but what if WHATWG defines a setter for the head element at a later point in time that's incompatible with what I added?
It may sound far-fetched, but that's not unreasonable given that setting the $body property is way more complicated than just find+replace <body>
(e.g. handles framesets too).
Kind regards
Niels
Hi internals
I'm opening the vote of my RFC "New ext-dom features in PHP 8.4".
RFC link: https://wiki.php.net/rfc/dom_additions_84
Voting runs until 24th of June 21:00 GMT+2.Kind regards
Niels
Hi internals
The RFC was accepted with 25 yes votes and 0 no votes.
Thanks to everyone who participated.
Kind regards
Niels