Skip to content

Update closest() to accept a css selector#29

Open
mturnwall wants to merge 5 commits into
masterfrom
closest
Open

Update closest() to accept a css selector#29
mturnwall wants to merge 5 commits into
masterfrom
closest

Conversation

@mturnwall
Copy link
Copy Markdown
Contributor

Move closest() and once() tests into separate files
Add additional once() tests

Move closest() and once() tests into separate files
Add additional once() tests
Copy link
Copy Markdown
Contributor

@Antonio-Laguna Antonio-Laguna left a 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.

Comment thread README.md Outdated
#### 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.
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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 |

Comment thread lib/once.js Outdated
off(el, event);
function once(selector, event, run, capture = false) {
on(selector, event, e => {
off(selector, event);
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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)

Copy link
Copy Markdown
Contributor

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?

Comment thread test/closest.test.js Outdated
import domassist from '../domassist';
import test from 'tape-rollup';

function addNode(el, num) {
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Antonio-Laguna
Copy link
Copy Markdown
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants