Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Add Element.closest #132

Merged
merged 3 commits into from
Jul 24, 2017
Merged

Add Element.closest #132

merged 3 commits into from
Jul 24, 2017

Conversation

alexandernanberg
Copy link
Contributor

Polyfill is taken directly from MDN

@alexandernanberg alexandernanberg changed the title Add Element.closest Add Element.closest #127 Jul 21, 2017
@alexandernanberg alexandernanberg changed the title Add Element.closest #127 Add Element.closest Jul 21, 2017
Copy link
Owner

@inexorabletash inexorabletash left a comment

Choose a reason for hiding this comment

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

Thanks for submitting! Looks good, a few suggestions for additional test cases.

Have you tried in IE8 to make sure it at least doesn't raise an exception? (I forget which incantations are needed around Element.prototype since I've dropped support for IE<10 in my hobby projects)

QUnit.test("closest", function(assert) {
assert.equal(document.querySelector('#bar').closest('#foo'), document.querySelector('#foo'));
assert.equal(document.querySelector('#baz').closest('#foo'), document.querySelector('#foo'));
});
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add a case for:

assert.equal(document.querySelector('#foo').closest('#foo'), document.querySelector('#foo'));

And a case where there is no closest ancestor?

(This will also serve as a reminder to re-review and merge this when I have more time)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do that! I'm having some problems getting Qunit to work, which version of Qunit and node are you using? It might be beneficial if we could add Qunit as a devDependency and a npm script to run the tests. Would make testing much simpler for new contributors.

Copy link
Owner

Choose a reason for hiding this comment

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

I don't use node myself. You can just hit load the test file directly in a browser, or e.g.:

https://rawgit.com/inexorabletash/polyfill/master/tests/dom.html

And yes, getting continuous integration would be swell. As noted I don't use node myself for any projects, but happy to field further PRs with tests, if there are appropriate instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, neat. I've added 2 more tests now, will that suffice? I tried to test it in IE 8 in BrowserStack but the tests wont run (got a blank page) even without my modifications. Work fine in IE 9 and up though. Can you check if you get the same problem?

If I get time sometime I might create a CI PR!

@inexorabletash
Copy link
Owner

inexorabletash commented Jul 24, 2017 via email

@inexorabletash inexorabletash merged commit b46b5c7 into inexorabletash:master Jul 24, 2017
@inexorabletash
Copy link
Owner

Thanks! I'll wait a couple days for any error reports to roll in, then make a release/push to npm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants