You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parents(selector) does not behave as expected. It does not always terminate at the closest matching ancestor; instead, this behaviour only occurs if the first element matching the selector in the document is a direct ancestor of the calling element.
parents(selector) should return the ancestors of the current element up until an element that matches selector, as documented. In the supplied fiddle, both circles should turn green.
Actual behaviour
The returned list of elements only terminates if the first element in the document that matches selector is a direct ancestor of the calling element. In other words, if element.root().findOne(selector) is in element.parents(), then element.parents(selector) works (almost) as expected. However:
If there are multiple elements in the parent chain that match the selector, parents(selector) matches the furthest element, not the closest one (https://jsfiddle.net/gormster/erhwjv1c/)
If there are multiple elements in the document that match the selector, and the first such element is not in the parent chain, parents(selector) returns all parents including the elements in the containing HTML document (https://jsfiddle.net/gormster/2xw7sape/)
Bug report
parents(selector)
does not behave as expected. It does not always terminate at the closest matching ancestor; instead, this behaviour only occurs if the first element matching the selector in the document is a direct ancestor of the calling element.Fiddle
https://jsfiddle.net/gormster/2xw7sape/
Explanation
Expected behaviour
parents(selector)
should return the ancestors of the current element up until an element that matchesselector
, as documented. In the supplied fiddle, both circles should turn green.Actual behaviour
The returned list of elements only terminates if the first element in the document that matches
selector
is a direct ancestor of the calling element. In other words, ifelement.root().findOne(selector)
is inelement.parents()
, thenelement.parents(selector)
works (almost) as expected. However:parents(selector)
matches the furthest element, not the closest one (https://jsfiddle.net/gormster/erhwjv1c/)parents(selector)
returns all parents including the elements in the containing HTML document (https://jsfiddle.net/gormster/2xw7sape/)parents(selector)
throws a TypeError (https://jsfiddle.net/gormster/c7k23vt0/)The text was updated successfully, but these errors were encountered: