-
Notifications
You must be signed in to change notification settings - Fork 295
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
Adding .closest() to more nodes #161
Comments
Maybe @coonsta? |
Sounds reasonable to me too. |
If I were to fix this I'd probably include all possible children of |
ok, tend also to do the one below (since I'm using .closest on all sort of nodes that comes with range.commonAncestorContainer)
|
All possible children of Element + Document—does it make sense to put this on Node? I suppose Document, DocumentFragment, and ShadowRoot .closest return null? (/cc @hayatoito for ShadowRoot.) |
So, it does not make much sense for If we put it on node we should probably use |
Yeah, regarding ShadowRoot, it returns null because it is not an element and it is always the root. |
I think if you include Document and ShadowRoot you may as well include DocumentFragment? I agree leaving this off Attr makes sense. Are there any other properties like this, can the principle of consistency guide the decision? |
I think there are many properties like this, but for historical reasons they have ended up on I guess we have two options here:
I'm inclined to go with 2 if we still want to do this. |
Text nodes have no .closest method, when working with Range, I find useful to do
Text.prototype.closest = function(s) {return this.parentNode.closest(s); } //with this.parentNode&& if we want to be strict
For me it makes sense to be able to search from a textnode, .matches wouldn't make sense (edit: it could, by returning null), but .closest would
The text was updated successfully, but these errors were encountered: