dom-closest

WebJar for dom-closest

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

dom-closest
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

dom-closest
WebJar for dom-closest
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/necolas/dom-closest

Download dom-closest

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/dom-closest/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>dom-closest</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/dom-closest/
implementation 'org.webjars.npm:dom-closest:0.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/dom-closest/
implementation ("org.webjars.npm:dom-closest:0.2.0")
'org.webjars.npm:dom-closest:jar:0.2.0'
<dependency org="org.webjars.npm" name="dom-closest" rev="0.2.0">
  <artifact name="dom-closest" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='dom-closest', version='0.2.0')
)
libraryDependencies += "org.webjars.npm" % "dom-closest" % "0.2.0"
[org.webjars.npm/dom-closest "0.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : dom-matches jar [1.0.1,)

Project Modules

There are no modules declared in this project.

dom-closest

Build Status

For a given DOM element, find the first ancestor that matches a given CSS selector.

Installation

npm install dom-closest

API

closest(elem, selector[, context])

  • element (Element): a starting DOM Element.
  • selector (String): the CSS selector of the ancestor to find.
  • context (Element): a DOM node to use as search context (optional).
var closest = require('dom-closest');

var photo = document.querySelector('.photo');
var timeline = document.querySelector('.timeline');

closest(photo, '.tweet');
// => Element

closest(photo, '.tweet', timeline);
// => Element

Browser support

  • Google Chrome
  • Firefox 4+
  • Internet Explorer 8+
  • Safari 5+
  • Opera

Versions

Version
0.2.0