This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Today I was greeted in my Chrome's console with this: 'Attr.ownerElement' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom). Having quickly skimmed through the document, and finding out that "Attr" interface no more has the property, I did a quick Google search, which resulted in: http://stackoverflow.com/questions/24214188/attr-ownerelement-meaning Specifically, this: "ownerElement" This property has been removed from Firefox 29. Since you can only get Attr objects from elements, you should already know the owner. But this is wrong, really wrong. What about XPath, which allows us to query for nodes of specific type? For instance, this query: descendant-or-self::*/attribute::*[starts-with(name(), "data-bind")] Which does, something like "selects all attributes which names start with "data-bind" (data-bind, data-bind-something, data-bind-other) that are defined on either the context or any of the context node descendants". Emphasis on "selects all attributes" - this returns a result set of "Attr" nodes. For instance, I have a JS model -> element binder library. I run the query, providing my element as the context and in return, I get all attributes that are responsible for binding. By iterating over each of them and getting their type ("data-bind" as value binder and "data-bind-*" as attribute binder) and values, I can easily change "innerHTML/nodeValue" or "setAttribute" on the boundable element by utilising "Attr.ownerElement": if (attribute.name === 'data-bind') { attribute.ownerElement.innerHTML = providedModelData[attribute.value]; // Using the attributes' value as key here. } else { var targetAttributeName = attribute.name.replace('data-bind-', ''); attribute.ownerElement.setAttribute(targetAttributeName, providedModelData[attribute.value]); // Again, using key and remainder of attributes value. } XPath is the only option that allows us to query for attributes with wildcard names. And the combination of XPath, Attr and ownerElement is a magical one. Clearly, the claim "Since you can only get Attr objects from elements, you should already know the owner." is wrong, at least in XPath context. Yes, with document.querySelector we will only get Element nodes, but hey - we got other querying possibilities! Yes, I know that in my example, I can query for elements, that have the matching attributes, but then I have to loop through all of the attributes and filter them by names. Feels wrong, given that the current XPath/Attr/ownerElement combo can help us handling such case. Maybe I have overlooked something and XPath will return a different Attr interface? Though, I highly doubt it. To be honest, I'm really shocked. I agree that separating Attr from Node is needed due to useless properties, but, please, oh please, leave the ownerElement intact. P.S. A working example can be seen here: http://jsfiddle.net/psycketom/0cucudgk/
https://dom.spec.whatwg.org/#dom-attr-ownerelement I recommend filing a bug against Chrome for linking to out-of-date copies of standards.
Oh my... Sorry for the false alert then. But it appears that they're not only linking, but are going/were going towards implementing those.
Hmm, but what about the information on MDN site? https://developer.mozilla.org/en-US/docs/Web/API/Attr Still marked as: ownerElement [Deprecated since Gecko 7.0] [Obsolete since Gecko 29.0].
We did recently change this. You might want to change the relevant content / file a bug on Firefox. We thought it could be removed among with a lot of other things, but in the end we needed the association since we could not make values immutable.
Is the idea of "ownerElement" removal still intact and may be removed in future?
No, not really. See bug 25086.