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
Missing prevUntil - $('#demo').prev('a'); #185
Comments
alvarotrigo
changed the title
Missing prevUntil - prev('a');
Missing prevUntil - $('#demo').prev('a');
Apr 12, 2018
I would suggest something on these lines: function prevUntil(item, selector){
var prev = item.previousElementSibling
while(prev && !prev.matches(selector)){
prev = prev.previousElementSibling;
}
return prev;
} |
Perhaps something like: function until(item, selector, fn){
var sibling = item[fn]
while(sibling && !sibling.matches(selector)){
sibling = sibling[fn];
}
return sibling;
}
function prevUntil(item, selector){
return until(item, selector, 'previousElementSibling')
}
function nextUntil(item, selector){
return until(item, selector, 'nextElementSibling')
} |
@alvarotrigo Since you are already proposing code solutions, I think you can directly open some pull requests. |
@alvarotrigo looks good to me, can you raise a PR? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having:
We want to return the prev
a
, not the<b>
element:In jQuery they call it internally
prevUntil
:The text was updated successfully, but these errors were encountered: