# [RFC] [Vote] New ext-dom features in PHP 8.4

- Thread: https://externals.io/message/123570
- Original archive: https://news-web.php.net/php.internals/123570
- Started by Niels Dossche on 2024-06-10T18:10:59+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #123570 — Niels Dossche — 2024-06-10T18:10:59+00:00

URL: https://externals.io/message/123570#123570

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

---

## #123698 — Matthew Weier O'Phinney — 2024-06-20T14:28:46+00:00

URL: https://externals.io/message/123570#123698 · In reply to: #123570

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

---

## #123706 — Niels Dossche — 2024-06-20T18:26:00+00:00

URL: https://externals.io/message/123570#123706 · In reply to: #123698

> 
> 
> 
> 
>     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

---

## #123715 — Matthew Weier O'Phinney — 2024-06-20T21:55:49+00:00

URL: https://externals.io/message/123570#123715 · In reply to: #123706

> 
> > […]
> <mailto:dossche.niels@gmail.com>> wrote:
> > […]
> https://wiki.php.net/rfc/dom_additions_84>
> > […]
>
> 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.
> > […]
>

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.

---

## #123719 — Niels Dossche — 2024-06-21T08:08:31+00:00

URL: https://externals.io/message/123570#123719 · In reply to: #123715

> 
> 
> 
> 
>     
> > […]
> 
>     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.
> > […]
> 
> 
> 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

---

## #123785 — Niels Dossche — 2024-06-24T19:10:44+00:00

URL: https://externals.io/message/123570#123785 · In reply to: #123570

> 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
