New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Helper functions for CSS classes (classList) #11688
Comments
You can disregard some of my suggestions because apparently I’m an idiot and completely missed https://wiki.php.net/rfc/dom_living_standard_api. The current stable version of our software still supports PHP 7.4 (new version with PHP 8.1+ is around the corner though) and I completely missed the progress that has been made here. Feels a bit like the post-IE6 era where out of habit I was still writing garbage JS despite having access to newer JS features … |
Right. insertAdjacentElement is not implemented right now, but indeed append, after, before, replaceWith, etc are. Also: please split unrelated feature requests into different issues. People can then give thumbs up on individual issues such that we can prioritise what to implement. |
I'm going to edit your issue to split the feature request into the token list classList feature, and the insertAdjacent features. |
Hi, we must distinguish the DOM of the libxml (ext/dom) and the CoreDOM used in the navigator which implements the events, the ShadowRoot, MutationObserver... Html like Svg uses CoreDom with additional modules. The DOM of the libxml is a model object of the xml format while the CoreDOM (3.0 currently) is an implementation for web browser. On the other hand, if you want to use CSS selectors instead of XPath, you must use a css extension compatible with the ext/DOM. maybe libcroco (CSS2.0) If I had to make a request to improve ext/dom it would be DOMDocument::registerElementClass which will load a specific php class for each element (useful for building a model from an xml file) How is classList part of ext/dom? |
It's not specified which version of the DOM ext/dom follows, but the general idea is that it used to follow the W3C DOM spec. For recent features it follows the living WHATWG DOM spec, see https://wiki.php.net/rfc/dom_living_standard_api
The fact that it uses libxml2 under the hood is an implementation detail.
Because it's defined by the living WHATWG DOM spec. |
I don't have the patience to check but it seems to me that the webkit is using libxml's xmlSAXHandler but not its DOM(equivalent ext/dom). I think it's a mistake to confuse DOM(libxml dom) and CoreDOM Level 3(W3C - WHATWG now). (I don't mind that helper functions are implemented) |
What you're referring to as CoreDOM (Level 3) is the old DOM spec created by W3C that is no longer maintained. |
Ah I get what you're saying now. Libxml2 doesn't really define a DOM actually. ext/dom therefore doesn't follow libxml2's DOM. |
Ok, I took the time to read your link. https://wiki.php.net/rfc/dom_living_standard_api
But I say : ext/dom is the DOM bindings of the libxml2.so library, carried out with less rigor. In other words adding this kind of function adds confusion. that being said. I will adapt to the vision of PHP. |
Indeed.
It doesn't implement querySelector at the moment. |
Description
The DOM extension of PHP lacks a couple of helper functions that have eased the life of frontend engineers for many years.
The lack of a proper handling of CSS classes was painful back in the IE6 days and while jQuery solved that to some degree, the addition of the
.classList
was a massive improvement. I would really love to see PHP adding support for a similar interface to ease the work with CSS classes.Old additional content:
There is also
replaceWith()
that allows to swap out DOM nodes while preserving the original position in the DOM, but its arguably more niche of a use case.The text was updated successfully, but these errors were encountered: