Skip to content

Add Element.Matches and Element.Closest #67

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

Merged
merged 1 commit into from
Apr 3, 2019

Conversation

inkeliz
Copy link
Contributor

@inkeliz inkeliz commented Dec 23, 2018

This change add support for:

element . matches(selectors)
Returns true if matching selectors against element’s root yields element, and false otherwise.

element . closest(selectors)
Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise.

@dmitshur dmitshur self-assigned this Apr 3, 2019
@dmitshur
Copy link
Collaborator

dmitshur commented Apr 3, 2019

Sorry about the delay.

This PR currently includes 4 commits, but the intention appears to have been to include only commit
ec897f4. The rest are not related and are a part of PR #66.

I'll push to your matches-closest branch to resolve drop the unrelated commits 6a71e80, 52bf9bb, and 2979c34.

Copy link
Collaborator

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@@ -1527,6 +1528,7 @@ type Element interface {
GetElementsByTagNameNS(ns string, name string) []Element
HasAttribute(string) bool
HasAttributeNS(ns string, name string) bool
Matches(string) bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding methods to an exported interface is technically a breaking API change (if anyone happened to implement this interface externally, their implementation would no longer satisfy it).

We have no choice but to allow this, because the Element interface is meant to map to the DOM Element interface, and the policy of this package allows for such API changes.

@dmitshur dmitshur merged commit d6d651d into dominikh:master Apr 3, 2019
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.

2 participants