You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PHP 8.4 classList works not correctly if copy HTMLElement by clone keyword. #18744
changed the title [-]PHP 8.4 classList works not correctly if HTMLElement cloned.[/-][+]PHP 8.4 classList works not correctly if copy HTMLElement by `clone` keyword.[/+]on Jun 3, 2025
Some clarification as to why cloneNode behaves correctly but clone does not: clone creates a copy of the entire object, while cloneNode only copies the tree structure and then creates a new object instance. This is significant if you have custom properties on an Element instance, or you extend the Element class yourself.
The reason why TokenList is uncloneable is because the DOM spec requires it to always be the same object for a single Element. Therefore, the class can't be cloneable as it would violate this constraint.
Activity
[-]PHP 8.4 classList works not correctly if HTMLElement cloned.[/-][+]PHP 8.4 classList works not correctly if copy HTMLElement by `clone` keyword.[/+]Fix phpGH-18744: PHP 8.4 classList works not correctly if copy HTMLEl…
ndossche commentedon Jun 3, 2025
Good find.
Some clarification as to why
cloneNodebehaves correctly butclonedoes not:clonecreates a copy of the entire object, whilecloneNodeonly copies the tree structure and then creates a new object instance. This is significant if you have custom properties on an Element instance, or you extend the Element class yourself.The reason why TokenList is uncloneable is because the DOM spec requires it to always be the same object for a single Element. Therefore, the class can't be cloneable as it would violate this constraint.
Merge branch 'PHP-8.4'
Fix GH-18744: PHP 8.4 classList works not correctly if copy HTMLEleme…