Skip to content

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

mturnwall
Copy link
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
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.

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.
Copy link
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
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 |

lib/once.js Outdated
off(el, event);
function once(selector, event, run, capture = false) {
on(selector, event, e => {
off(selector, event);
Copy link
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
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
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?

import domassist from '../domassist';
import test from 'tape-rollup';

function addNode(el, num) {
Copy link
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
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
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
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