Comments (6)
This issue was raised due to the introduction of the value getter/setter to the select element. This is fine while there is only the one getter/setter for the one type of element, but there will be many more elements that need their own functionality. See https://github.com/phpgt/dom/pull/55/files#diff-cf04cad35ad97bb3de2901c4ce89acf6R100 for code in question.
from dom.
The implementation needs some thought...
@ognjen-petrovic has asked, "Do you intend to override all element getters, like getElementById, getElementsByTagName etc, so those return proper HTMLELement?" (#55 (comment))
This could become quite difficult to maintain. My initial plan is to create the sub-classes when needed, then use something like class_exists("HTML" . $this->tagName . "Element")
to check for the correct class to return.
Feedback would be appreciated.
from dom.
List of all classes, taken from https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
- HTMLAnchorElement
- HTMLAreaElement
- HTMLAudioElement
- HTMLBRElement
- HTMLBaseElement
- HTMLBaseFontElement
- HTMLBodyElement
- HTMLButtonElement
- HTMLCanvasElement
- HTMLContentElement
- HTMLDListElement
- HTMLDataElement
- HTMLDataListElement
- HTMLDialogElement
- HTMLDivElement
- HTMLDocument
- HTMLEmbedElement
- HTMLFieldSetElement
- HTMLFormControlsCollection
- HTMLFormElement
- HTMLFrameSetElement
- HTMLHRElement
- HTMLHeadElement
- HTMLHeadingElement
- HTMLHtmlElement
- HTMLIFrameElement
- HTMLImageElement
- HTMLInputElement
- HTMLIsIndexElement
- HTMLKeygenElement
- HTMLLIElement
- HTMLLabelElement
- HTMLLegendElement
- HTMLLinkElement
- HTMLMapElement
- HTMLMediaElement
- HTMLMetaElement
- HTMLMeterElement
- HTMLModElement
- HTMLOListElement
- HTMLObjectElement
- HTMLOptGroupElement
- HTMLOptionElement
- HTMLOptionsCollection
- HTMLOutputElement
- HTMLParagraphElement
- HTMLParamElement
- HTMLPictureElement
- HTMLPreElement
- HTMLProgressElement
- HTMLQuoteElement
- HTMLScriptElement
- HTMLSelectElement
- HTMLShadowElement
- HTMLSourceElement
- HTMLSpanElement
- HTMLStyleElement
- HTMLTableCaptionElement
- HTMLTableCellElement
- HTMLTableColElement
- HTMLTableDataCellElement
- HTMLTableElement
- HTMLTableHeaderCellElement
- HTMLTableRowElement
- HTMLTableSectionElement
- HTMLTemplateElement
- HTMLTextAreaElement
- HTMLTimeElement
- HTMLTitleElement
- HTMLTrackElement
- HTMLUListElement
- HTMLUnknownElement
- HTMLVideoElement
Noticably, not all class names correlate directly to the tagname.
from dom.
It turns out, it isn't possible to have a class for each type of HTMLElement. This is because of the native registerNodeClass
functionality - only one class can be used to construct.
Instead, because there can't be a subset of Element
as HTMLElement
, could we look at something like an HTMLElement trait
?
There certainly needs to be a class-like construct that can be used to provide the logic for each individual HTMLElement.
from dom.
Yes, subclassing is not possible with native PHP implementation. Few days ago, just for fun, I have started with custom PHP extension that exploits pugixml. https://github.com/ognjen-petrovic/php-dom-ext
from dom.
That looks an interesting project! As far as this issue is concerned, I think it will be OK to patch these subclasses in with traits. As long as the external-facing API is consistent with the W3C spec, it doesn't matter if there are some hacks behind the scenes (take LiveProperty
for example).
from dom.
Related Issues (20)
- Deprecation warnings for 8.1 HOT 1
- Test HTMLSelectElement::options when using optgroup
- escaped characters HOT 18
- PHPStan lies about types within certain traits
- Updating an ID attribute via its Node causes getElementById to fail
- Dataset automatic camel case to hyphen key conversion HOT 1
- Dependabot
- NodeList::forEach HOT 1
- AllowDynamicProperties
- Can't user this anymore on PHP 7.4? HOT 3
- Resolve deprecations HOT 12
- Dataset dynamic properties are not hyphen exploded properly
- Matrix builds & QA tools HOT 1
- PHP 8.2 introduces a bug where DOMElement::prepend does not retain same object reference
- querySelectorAll should return an array of Elements, not Nodes
- TextArea::value property
- HTMLSelectElement::disabled
- `DOMStringMap::get` and `DOMStringMap::set` should work with hyphens and numbers HOT 1
- Compatibility Error HOT 3
- DocumentFragment append() vs appendChild()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dom.