-
Notifications
You must be signed in to change notification settings - Fork 2
Update closest() to accept a css selector #29
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
base: master
Are you sure you want to change the base?
Conversation
Move closest() and once() tests into separate files Add additional once() tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff @mturnwall !
I left a couple of comments on some places. Please let me know of your thoughts.
README.md
Outdated
|
||
Find the closest parent element that matches the given selector | ||
|
||
#### Parameters: | ||
|
||
`element` - {Element} the element where you want to start looking from | ||
`origin` - {string:Element} - the element where you want to start looking from. It can be either a valid CSS selector or an Element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicky. Looking like JSDoc here. Can we have string|Element
(union type). Seems correct down below for once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a typo, it should have been |
lib/once.js
Outdated
off(el, event); | ||
function once(selector, event, run, capture = false) { | ||
on(selector, event, e => { | ||
off(selector, event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR but as per docs, the capture should be passed on to off
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
off()
doesn't receive a capture option since removeEventListener()
doesn't have one. The docs have this off(selector, event)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, according to MDN. Is there something I'm missing?
test/closest.test.js
Outdated
import domassist from '../domassist'; | ||
import test from 'tape-rollup'; | ||
|
||
function addNode(el, num) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this test is similar than the previous one, I think we should just have a template with a clear structure on how it looks and what's the expected result. Look at what we do with Domodules. What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you point me to what you are referring to? I'm not sure I understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM |
Move closest() and once() tests into separate files
Add additional once() tests