Skip to content

Element.matches + Element.closest #39

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
Jan 23, 2021

Conversation

toastal
Copy link
Contributor

@toastal toastal commented Jan 21, 2021

fixes #38. Copied querySelector-isms. It's looking like perhaps QuerySelector doesn't make a lot of sense stuck inside ParentNode with this though. 🤔

Prerequisites

  • Before opening a pull request, please check the DOM standard (https://dom.spec.whatwg.org/). If it doesn't appear in this spec, it may be present in the spec for one of the other purescript-web projects. Although MDN is a great resource, it is not a suitable reference for this project.

https://dom.spec.whatwg.org/#dom-element-matches
https://dom.spec.whatwg.org/#dom-element-closest

Description of the change

Add missing Element feature


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@toastal toastal force-pushed the element-closest branch 3 times, most recently from d033aa7 to b0bd845 Compare January 21, 2021 07:55
@garyb
Copy link
Member

garyb commented Jan 21, 2021

Yeah, we could perhaps move the QuerySelector type to its own module and have both this and ParentNode re-export it - but I dunno, ParentNode is already imported by Element and you're re-exporting QuerySelector here, so it perhaps doesn't matter too much where it comes from as long as it's convenient to use when importing either of modules in user code!

@toastal
Copy link
Contributor Author

toastal commented Jan 22, 2021

I getcha. How do you, @garyb, recommend fixing this build error?

 * Building project in /home/runner/work/purescript-web-dom/purescript-web-dom
[1/1 DuplicateSelectiveImport] src/Web/DOM/Element.purs:57:1

  57  import Web.DOM.ParentNode (ParentNode, QuerySelector)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  There is an existing import of Web.DOM.ParentNode, consider merging the import lists

@@ -52,6 +53,8 @@ import Web.DOM.Internal.Types (Element) as Exports
import Web.DOM.Internal.Types (Element, HTMLCollection, Node)
import Web.DOM.NonDocumentTypeChildNode (NonDocumentTypeChildNode)
import Web.DOM.ParentNode (ParentNode)
import Web.DOM.ParentNode (QuerySelector) as Exports
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import Web.DOM.ParentNode (QuerySelector) as Exports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't I still want to export it for convenience? (Sorry, I don't think I understand)

Copy link
Contributor

Choose a reason for hiding this comment

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

It’s also re-exported on the next line — this is the source of the duplicate error.

@toastal toastal changed the title Element.closest Element.matches + Element.closest Jan 22, 2021
@toastal toastal force-pushed the element-closest branch 3 times, most recently from 1296f09 to 18b5845 Compare January 22, 2021 04:43
@toastal
Copy link
Contributor Author

toastal commented Jan 22, 2021

I added matches as well since it's a related function and is a requirement for polyfills for closest.

@garyb
Copy link
Member

garyb commented Jan 23, 2021

Thanks!

@garyb garyb merged commit efabcbf into purescript-web:master Jan 23, 2021
@toastal toastal deleted the element-closest branch January 25, 2021 02:24
sigma-andex pushed a commit to working-group-purescript-es/purescript-web-dom that referenced this pull request Apr 14, 2022
…rs-warnings

Fix `HiddenConstructors` warnings
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.

Element.closest
3 participants