This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
If you have foo and want the next element sibling, it makes sense to just use nextElementSibling even if foo is not an element. Currently nextElementSibling is only defined on Element. The same argument goes for the other element traversal members. Specifically, I think the following makes sense: children firstElementChild lastElementChild childElementCount on Document, DocumentFragment, Element previousElementSibling nextElementSibling on DocumentType, Element, CharacterData I think this is similar to the new mutation methods (prepend() et al).
Reasonable.
Wouldn't previousElementSibling and nextElementSibling be useful on Node too?
Node - (DocumentType, Element, CharacterData) = (Document, DocumentFragment), so probably not?
But it sounds like in general you think this is a good idea?
(In reply to comment #4) > But it sounds like in general you think this is a good idea? Yes. It sounds like an improvement. The reason why I think nextElementSibling makes sense for all Nodes is that it would give the next sibling node that is an Element. Conceptually nextElementSibling is just: Object.defineProperty(Node.prototype, 'nextElementSibling', { get: function() { for (var next = this.nextSibling; next && next.nodeType !== Node.ELEMENT_NODE; next = next.nextSibling); return next; }, ... });
Maybe comment 3 was too cryptic. Simon is proposing to put previousElementSibling and nextElementSibling on all nodes, except for Document and DocumentFragment, where they are never useful, I think.
https://github.com/whatwg/dom/commit/4522273382af5950d19154e5bfa74d2ab8566033