{"_id":"element-closest","_rev":"3281463","name":"element-closest","description":"Return the closest element matching a selector up the DOM tree","dist-tags":{"latest":"3.0.2"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"time":{"modified":"2024-05-16T05:28:26.000Z","created":"2015-06-08T12:59:54.443Z","3.0.2":"2019-10-31T05:37:58.579Z","3.0.1":"2019-02-05T12:52:11.051Z","3.0.0":"2018-12-20T19:43:51.914Z","2.0.2":"2016-10-27T02:03:01.879Z","2.0.1":"2016-04-09T12:44:08.431Z","2.0.0":"2016-04-08T02:01:45.443Z","1.0.3":"2015-06-23T14:02:45.727Z","1.0.2":"2015-06-08T12:59:54.443Z"},"users":{},"author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"versions":{"3.0.2":{"name":"element-closest","version":"3.0.2","description":"Return the closest element matching a selector up the DOM tree","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"homepage":"https://github.com/jonathantneal/closest#readme","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"main":"index.js","module":"index.mjs","unpkg":"browser.js","jsdelivr":"browser.js","scripts":{"build":"npm run build:node && npm run build:browser","build:node":"rollup --config","build:browser":"cross-env NODE_ENV=browser rollup --config","prepublish":"npm run test && npm run build","test":"eslint src/*.js --cache --ignore-path .gitignore --quiet"},"engines":{"node":">=0.12.0"},"devDependencies":{"@babel/core":"^7.6.4","@babel/preset-env":"^7.6.3","babel-eslint":"^10.0.3","cross-env":"^6.0.3","eslint":"^6.6.0","eslint-config-dev":"^2.0.0","pre-commit":"^1.2.2","rollup":"^1.26.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-terser":"^5.1.2"},"eslintConfig":{"extends":"dev","parser":"babel-eslint"},"keywords":["javascript","js","dom","document","element","node","closest","matches","polyfill","web","standard"],"gitHead":"c074fd7b0597c560174a8fa221fef9591a0ac4a3","_id":"element-closest@3.0.2","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","dist":{"shasum":"3814a69a84f30e48e63eaf57341f4dbf4227d2aa","size":6452,"noattachment":false,"key":"/element-closest/-/element-closest-3.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-3.0.2.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/element-closest_3.0.2_1572500278422_0.2961849385991169"},"_hasShrinkwrap":false,"publish_time":1572500278579,"_cnpm_publish_time":1572500278579,"_cnpmcore_publish_time":"2021-12-16T11:00:33.988Z"},"3.0.1":{"name":"element-closest","version":"3.0.1","description":"Return the closest element matching a selector up the DOM tree","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"homepage":"https://github.com/jonathantneal/closest#readme","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"main":"index.js","module":"index.mjs","scripts":{"build":"npm run build:node && npm run build:browser","build:node":"rollup --config","build:browser":"cross-env NODE_ENV=browser rollup --config","prepublish":"npm run test && npm run build","test":"eslint src/*.js --cache --ignore-path .gitignore --quiet"},"engines":{"node":">=6.0.0"},"devDependencies":{"@babel/core":"^7.2.2","@babel/preset-env":"^7.3.1","babel-eslint":"^10.0.1","cross-env":"^5.2.0","eslint":"^5.13.0","eslint-config-dev":"^2.0.0","pre-commit":"^1.2.2","rollup":"^1.1.2","rollup-plugin-babel":"^4.3.2","rollup-plugin-terser":"^4.0.4"},"eslintConfig":{"extends":"dev","parser":"babel-eslint"},"keywords":["postcss","css","postcss-plugin","dom","document","element","node","closest","matches","polyfill","web","standard"],"gitHead":"7a9f03cb3056fc498f2e51012ddf02e0a41076a8","_id":"element-closest@3.0.1","_npmVersion":"6.5.0","_nodeVersion":"11.6.0","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"shasum":"0b2000266ae43a800274401dc39486f5e4bfbce2","size":6491,"noattachment":false,"key":"/element-closest/-/element-closest-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-3.0.1.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/element-closest_3.0.1_1549371130948_0.47955988186068077"},"_hasShrinkwrap":false,"publish_time":1549371131051,"_cnpm_publish_time":1549371131051,"_cnpmcore_publish_time":"2021-12-16T11:00:34.174Z"},"3.0.0":{"name":"element-closest","version":"3.0.0","description":"Return the closest element matching a selector up the DOM tree","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"homepage":"https://github.com/jonathantneal/closest#readme","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"main":"index.js","module":"index.mjs","scripts":{"build":"npm run build:node && npm run build:browser","build:node":"rollup --config","build:browser":"cross-env NODE_ENV=browser rollup --config","prepublish":"npm run test && npm run build","test":"eslint src/*.js --cache --ignore-path .gitignore --quiet"},"engines":{"node":">=6.0.0"},"devDependencies":{"@babel/core":"^7.2.2","@babel/preset-env":"^7.2.3","babel-eslint":"^10.0.1","cross-env":"^5.2.0","eslint":"^5.10.0","eslint-config-dev":"^2.0.0","pre-commit":"^1.2.2","rollup":"^0.68.1","rollup-plugin-babel":"^4.1.0","rollup-plugin-terser":"^3.0.0"},"eslintConfig":{"extends":"dev","parser":"babel-eslint"},"keywords":["postcss","css","postcss-plugin","dom","document","element","node","closest","matches","polyfill","web","standard"],"gitHead":"ef15b628f7fcb354ac4020924eb5df85f34421d8","_id":"element-closest@3.0.0","_npmVersion":"6.5.0","_nodeVersion":"11.4.0","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"shasum":"4ce78e5b8c6db775cc5fa596193ad86f05ddc3e6","size":6454,"noattachment":false,"key":"/element-closest/-/element-closest-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-3.0.0.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/element-closest_3.0.0_1545335031764_0.20116333003679077"},"_hasShrinkwrap":false,"publish_time":1545335031914,"_cnpm_publish_time":1545335031914,"_cnpmcore_publish_time":"2021-12-16T11:00:34.420Z"},"2.0.2":{"name":"element-closest","version":"2.0.2","description":"Return the closest element matching a selector up the DOM tree","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com","url":"http://jonathantneal.com"},"license":"CC0-1.0","repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"homepage":"https://github.com/jonathantneal/closest#readme","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"main":"element-closest.js","files":["element-closest.js"],"scripts":{"test":"eslint *.js --ignore-path .gitignore && jscs *.js"},"engines":{"node":">=4.0.0"},"devDependencies":{"eslint":"^3.8.1","eslint-config-10up":"github:jonathantneal/eslint-config-10up","jscs":"^3.0.7","jscs-config-10up":"github:jonathantneal/jscs-config-10up"},"eslintConfig":{"extends":"10up"},"jscsConfig":{"preset":"10up"},"keywords":["polyfill","dom","document","element","closest","matches","standard","specification"],"gitHead":"234d75008cdcf9748a3086ab87e9c837ff926a9f","_id":"element-closest@2.0.2","_shasum":"72a740a107453382e28df9ce5dbb5a8df0f966ec","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"shasum":"72a740a107453382e28df9ce5dbb5a8df0f966ec","size":5905,"noattachment":false,"key":"/element-closest/-/element-closest-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-2.0.2.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/element-closest-2.0.2.tgz_1477533779809_0.04536187811754644"},"directories":{},"publish_time":1477533781879,"_hasShrinkwrap":false,"_cnpm_publish_time":1477533781879,"_cnpmcore_publish_time":"2021-12-16T11:00:34.633Z"},"2.0.1":{"name":"element-closest","version":"2.0.1","description":"Return the closest element matching a selector up the DOM tree","main":"closest.js","scripts":{"test":"eslint *.js --ignore-path .gitignore && jscs *.js"},"repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"keywords":["closest","dom","element","matches","polyfill","standard"],"author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com","url":"http://jonathantneal.com"},"license":"CC0-1.0","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"homepage":"https://github.com/jonathantneal/closest#readme","devDependencies":{"eslint":"^2.7.0","jscs":"^2.11.0"},"gitHead":"2d254568da098bdee1a2ddcdb39ac4cde37b0c56","_id":"element-closest@2.0.1","_shasum":"c56efe8db1a32ad24f32f4eb988b3502fc566c24","_from":".","_npmVersion":"3.7.5","_nodeVersion":"5.4.1","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"shasum":"c56efe8db1a32ad24f32f4eb988b3502fc566c24","size":6464,"noattachment":false,"key":"/element-closest/-/element-closest-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-2.0.1.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/element-closest-2.0.1.tgz_1460205846138_0.28395392186939716"},"directories":{},"publish_time":1460205848431,"_hasShrinkwrap":false,"_cnpm_publish_time":1460205848431,"_cnpmcore_publish_time":"2021-12-16T11:00:34.861Z"},"2.0.0":{"name":"element-closest","version":"2.0.0","description":"Return the closest element matching a selector up the DOM tree","main":"closest.js","scripts":{"test":"eslint *.js --ignore-path .gitignore && jscs *.js"},"repository":{"type":"git","url":"git+https://github.com/jonathantneal/closest.git"},"keywords":["closest","dom","element","matches","polyfill","standard"],"author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com","url":"http://jonathantneal.com"},"license":"CC0-1.0","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"homepage":"https://github.com/jonathantneal/closest#readme","devDependencies":{"eslint":"^2.7.0","jscs":"^2.11.0"},"gitHead":"a92c9675e82d5d0186ced05e29a363677ec61a91","_id":"element-closest@2.0.0","_shasum":"38036ed683b1c30a15a7c56b465b457215fb7f00","_from":".","_npmVersion":"3.7.5","_nodeVersion":"5.4.1","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"shasum":"38036ed683b1c30a15a7c56b465b457215fb7f00","size":6438,"noattachment":false,"key":"/element-closest/-/element-closest-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-2.0.0.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/element-closest-2.0.0.tgz_1460080902963_0.0792479629162699"},"directories":{},"publish_time":1460080905443,"_hasShrinkwrap":false,"_cnpm_publish_time":1460080905443,"_cnpmcore_publish_time":"2021-12-16T11:00:35.072Z"},"1.0.3":{"name":"element-closest","version":"1.0.3","description":"Get the closest element matching a selector up the DOM tree","keywords":["closest","dom","element","matches","polyfill","standard"],"license":"CC0-1.0","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com","url":"http://jonathantneal.com/"},"contributors":[{"name":"Bogdan Chadkin","email":"trysound@yandex.ru"}],"main":"closest.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://jonathantneal@github.com/jonathantneal/closest.git"},"bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"homepage":"https://github.com/jonathantneal/closest","gitHead":"228cd8c0e057bb9eb057c87a3c7f714b926876c7","_id":"element-closest@1.0.3","_shasum":"287e4de58433eb7e838a77503e0bac57ca0b4763","_from":".","_npmVersion":"2.4.1","_nodeVersion":"0.10.32","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"dist":{"shasum":"287e4de58433eb7e838a77503e0bac57ca0b4763","size":2614,"noattachment":false,"key":"/element-closest/-/element-closest-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-1.0.3.tgz"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"directories":{},"publish_time":1435068165727,"_hasShrinkwrap":false,"_cnpm_publish_time":1435068165727,"_cnpmcore_publish_time":"2021-12-16T11:00:35.292Z"},"1.0.2":{"name":"element-closest","version":"1.0.2","description":"Get the closest element matching a selector up the DOM tree","keywords":["closest","dom","element","matches","polyfill","standard"],"homepage":"https://github.com/jonathantneal/closest","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"license":"CC0-1.0","author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com","url":"http://jonathantneal.com/"},"contributors":[{"name":"Bogdan Chadkin","email":"trysound@yandex.ru"}],"main":"closest.js","repository":{"type":"git","url":"git://github.com/jonathan/browserstack-app.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"gitHead":"8bcccc00f08787bfb0fa1d8c7b3d8252fcb64da8","_id":"element-closest@1.0.2","_shasum":"af7e212f2c874e0b86a80993374a2eb360cb37cc","_from":".","_npmVersion":"2.4.1","_nodeVersion":"0.10.32","_npmUser":{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"trysound","email":"trysound@yandex.ru"}],"dist":{"shasum":"af7e212f2c874e0b86a80993374a2eb360cb37cc","size":2619,"noattachment":false,"key":"/element-closest/-/element-closest-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/element-closest/download/element-closest-1.0.2.tgz"},"directories":{},"publish_time":1433768394443,"_hasShrinkwrap":false,"_cnpm_publish_time":1433768394443,"_cnpmcore_publish_time":"2021-12-16T11:00:35.532Z"}},"readme":"# closest [<img src=\"https://jonneal.dev/dom-logo.svg\" alt=\"closest\" width=\"90\" height=\"90\" align=\"right\">][closest]\n\n[<img alt=\"npm version\" src=\"https://img.shields.io/npm/v/element-closest.svg\" height=\"20\">](https://www.npmjs.com/package/element-closest)\n[<img alt=\"build status\" src=\"https://img.shields.io/travis/jonathantneal/closest/master.svg\" height=\"20\">](https://travis-ci.org/jonathantneal/closest)\n[<img alt=\"support chat\" src=\"https://img.shields.io/badge/support-chat-blue.svg\" height=\"20\">](https://gitter.im/postcss/postcss)\n\n[closest] is a polyfill for [`#Element.closest`].\n\n```bash\nnpm install element-closest\n```\n\nThe [`#Element.closest`] method returns the closest element that matches a selector. It returns the element itself, one of its ancestor, or `null` if there isn't any match.\n\n```js\nelement.closest(selectorString) //=> Element or null\n```\n\nThis is especially useful for delegating events.\n\n```js\ndocument.addEventListener('click', function (event) {\n  // find nearest element up the tree that is an <a>\n  var link = event.target.closest('a');\n\n  if (link) {\n    // do something with the <a>\n    event.preventDefault();\n  }\n});\n```\n\nThe script is approximately 428 bytes, or 257 bytes when gzipped.\n\n## Usage\n\nFor immediate usage, add this script to your document:\n\n```html\n<script src=\"https://unpkg.com/element-closest\"></script>\n```\n\nFor usage in Node, including Browserify and Webpack, run [closest] with your `window` object:\n\n```js\nconst elementClosest = require('element-closest');\n\nelementClosest(window); // this is used to reference window.Element\n```\n\n## Browser compatibility\n\n| Browser           | Native Support | Polyfill Support |\n| ----------------- | -------------- | ---------------- |\n| Android           | 53             | 2.2+             |\n| Blackberry        | ✘              | 7+               |\n| Chrome            | 41+            | 4 - 40           |\n| Edge              | 15             | 12 - 14          |\n| Firefox           | 35+            | 3.5 - 34         |\n| Internet Explorer | ✘              | 8+               |\n| Opera             | 28+            | 10 - 27          |\n| Opera Mobile      | 37+            | 12+              |\n| Safari (iOS)      | 9.2+           | 3.2 - 8.4        |\n| Safari (MacOS)    | 9.1+           | 3.1 - 8          |\n\n### Internet Explorer 8\n\n`closest` is especially useful for delegating events, but remember that Internet Explorer 8 does not support [`#Element.addEventListener`].\n\n## matches\n\nThis library also polyfills [`#Element.matches`], which is widely supported but often vendor-prefixed.\n\n```js\nelement.matches(selectorString) //=> boolean\n```\n\n`matches` is especially useful for short-handing `hasAttribute` or `classList.contains` with selectors.\n\n```js\nconst widget = document.querySelector('.custom-widget');\n\nif (widget.matches('[data-active]') || widget.matches('.widget--active')) {\n  // do something with the active widget\n}\n```\n\n[`#Element.closest`]: https://dom.spec.whatwg.org/#dom-element-closest\n[`#Element.matches`]: https://dom.spec.whatwg.org/#dom-element-matches\n[`#Element.addEventListener`]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener#Browser_compatibility\n[closest]: https://github.com/jonathantneal/closest\n","_attachments":{},"homepage":"https://github.com/jonathantneal/closest#readme","bugs":{"url":"https://github.com/jonathantneal/closest/issues"},"license":"CC0-1.0"}