This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Either on Node or on Element -- probably on Element for consistency, since .attributes is there (although I don't get why .attributes was moved from Node). Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=849661 WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=113580 Do we have any data suggesting pages don't use this? There was one occurrence in Gecko's codebase, and also in <https://developer.mozilla.org/en-US/docs/JXON>. I don't see the value in getting rid of it. Testing "el.attributes" does the same thing, but only if you actually have an Element, which is a dicey assumption in JavaScript -- "el.hasAttributes()" will throw if you don't really have an Element, which some authors might well prefer. Are there any objections to restoring this to the spec?
.attributes was moved because it only returned something useful on Element. .hasAttributes() was removed because you can check .attributes.length on Element. The perceived value of moving things around was to make the DOM more JavaScript-y and less Java-prevent-casting-at-all-cost. If sicking wants this restored however I'm happy to put it back in.
Granted, now that you point it out, .attributes on non-Elements is really useless. I'm not so sure about .hasAttributes(); I suppose moving it to Element forces things to be more explicit. Anyway, bz WONTFIXed the Gecko bug, so I doubt anyone will actually remove this from implementations.
So WebKit/Blink just have it on Element. bz does not mind trying to remove it if we follow procedure as done elsewhere. Several people have requested to keep it removed as it's useless. I'm mostly *shrug* on this issue.
Arv, do you think we can remove hasAttributes() entirely or should we keep it on Element?
I'll add usage stats for this one too.
Erik, what can we conclude from http://www.chromestatus.com/metrics/feature/timeline/popularity/142 WONTFIX this bug?
(In reply to Anne from comment #6) > Erik, what can we conclude from > http://www.chromestatus.com/metrics/feature/timeline/popularity/142 WONTFIX > this bug? That our metrics had a hiccup? We have previously said that the cuttof is somewhere around 0.02% and this is much lower than that. At this point I'm not sure we care much about removing hasAttribute so if the spec adds it back I think we will just let this one rest.
I meant the opposite. Keep it out of the specification. Hmm.
Philip, care to remove hasAttributes() from Blink?
The usage is fairly low, but it's also very low cost to support: inline bool Element::hasAttributes() const { return !attributes().isEmpty(); } I do love removing things, but in this case I think spec'ing it might be better. Note that Node.hasChildNodes() is equally silly.
https://github.com/whatwg/dom/commit/d0ff369b1ccbbd428fd22c283d94535e5befe5c7 Put it on Element.