{"name":"wicg-inert","version":"3.1.3","description":"A polyfill for the proposed inert API","main":"dist/inert.js","module":"dist/inert.esm.js","scripts":{"build":"rollup -c"},"repository":{"type":"git","url":"git+https://github.com/WICG/inert.git"},"keywords":["inert","polyfill","browser"],"author":{"name":"Alice Boxhall","email":"alice@chromium.org"},"contributors":[{"name":"Rob Dodson","email":"robdodson@chromium.org"},{"name":"Jesse Beach"},{"name":"Brian Kardell"},{"name":"Valdrin Koshi"}],"bugs":{"url":"https://github.com/WICG/inert/issues"},"homepage":"https://github.com/WICG/inert#readme","devDependencies":{"babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-es3":"^1.0.1","chai":"^4.1.2","eslint":"^5.0.0","eslint-config-google":"^0.9.1","eslint-plugin-es5":"^1.3.1","husky":"^0.14.3","karma":"^6.3.20","karma-chai":"^0.1.0","karma-chrome-launcher":"^2.2.0","karma-firefox-launcher":"^1.1.0","karma-fixture":"^0.2.6","karma-html2js-preprocessor":"^1.1.0","karma-mocha":"^2.0.1","karma-polyfill":"^1.0.0","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^1.2.0","karma-sourcemap-loader":"^0.3.7","karma-spec-reporter":"0.0.32","lint-staged":"^7.0.0","mocha":"^10.0.0","rollup":"^0.65.0","rollup-plugin-babel":"^3.0.4","rollup-plugin-uglify":"^4.0.0"},"license":"W3C-20150513","_id":"wicg-inert@3.1.3","gitHead":"9f876a8846ebb00ece87cc50f9e331fc79823557","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-5L0PKK7iP+0Q/jv2ccgmkz/pfXbumZtlEyWS/xnX+L+Og3f7WjL4+iEs18k4IuldOX3PgGpza3qGndL9xUBjCQ==","shasum":"e53dbc9ac1e0d7f8c60f25e707614a835986272a","tarball":"http://registry-npm.ywwl.com/wicg-inert/download/wicg-inert-3.1.3.tgz","fileCount":35,"unpackedSize":181072,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFcTqG56uKRMaMSJmzyVd9ypKlHxDaQRhgQMt/SUHOx1AiEAgWSuBp2V12S4skrkmn8zaE0nIQLfPDBwUxgcxiJ0muc="}],"size":38860,"noattachment":false,"key":"/wicg-inert/-/wicg-inert-3.1.3.tgz"},"_npmUser":{"name":"robdodson","email":"lets.email.rob@gmail.com"},"directories":{},"maintainers":[{"name":"robdodson","email":"lets.email.rob@gmail.com"},{"name":"sundress","email":"aliceboxhall@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wicg-inert_3.1.3_1723480141465_0.4477006973157929"},"_hasShrinkwrap":false,"readme":"The `inert` attribute/property allows web authors to mark parts of the DOM tree\nas [inert](https://html.spec.whatwg.org/multipage/interaction.html#inert):\n\n> When a node is inert, then the user agent must act as if the node was absent\n> for the purposes of targeting user interaction events, may ignore the node for\n> the purposes of text search user interfaces (commonly known as \"find in\n> page\"), and may prevent the user from selecting text in that node.\n\nFurthermore, a node which is **inert** should also be hidden from assistive\ntechnology.\n\n# Details\n\n- Read the [Explainer](explainer.md).\n- Read the [Spec](https://whatpr.org/html/4288/interaction.html#the-inert-attribute).\n- Try the [Demo](https://wicg.github.io/inert/demo/).\n- [Give feedback!](https://github.com/WICG/inert/issues)\n\n# Polyfill\n\n## Installation\n\n`npm install --save wicg-inert`\n\nWe recommend only using versions of the polyfill that have been published to\nnpm, rather than cloning the repo and using the source directly. This helps\nensure the version you're using is stable and thoroughly tested.\n\nThis project provides two versions of the polyfill in `package.json`.\n\n- `main`: Points at `dist/inert.js` which is transpiled to ES3.\n- `module`: Points at `dist/inert.esm.js` which is transpiled to ES3.\n\n_If you do want to build from source, make sure you clone the latest tag!_\n\n## Usage\n\n### 1. Either import the polyfill, or add the script to your page\n\n```\nimport \"wicg-inert\";\n```\n\nOR…\n\n```html\n    ...\n    <script src=\"/node_modules/wicg-inert/dist/inert.min.js\"></script>\n  </body>\n</html>\n```\n\n### 2. Toggle `inert` on an element\n\n```js\nconst el = document.querySelector('#my-element');\nel.inert = true; // alternatively, el.setAttribute('inert', '');\n```\n\n### Legacy Browser Support\n\nIf you want to use `inert` with an older browser you'll need to include\nadditional polyfills for\n[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map),\n[Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set),\n[Element.prototype.matches](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches),\nand [Node.prototype.contains](https://developer.mozilla.org/en-US/docs/Web/API/Node/contains).\n\nIn accordance with the W3C's new [polyfill\nguidance](https://www.w3.org/2001/tag/doc/polyfills/#don-t-serve-unnecessary-polyfills),\nthe `inert` polyfill does not bundle other polyfills.\n\nYou can use a service like [https://cdnjs.cloudflare.com/polyfill](https://cdnjs.cloudflare.com/polyfill)\nto download only the polyfills needed by the current browser. Just add the\nfollowing line to the start of your page:\n\n```html\n<script src=\"https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=Map%2CSet%2CElement.prototype.matches%2CNode.prototype.contains\"></script>\n```\n\n### Strict Content Security Policy\n\nBy default, this polyfill will dynamically insert some CSS, which requires the\nstyle-src rule of your Content Security Policy to allow 'unsafe-inline'.\n\nIt is possible avoid doing so by including those rules from a CSS stylesheet, as\nfollows (the `id` property is used by the polyfill to know if it needs to\ndynamically add the missing rules):\n\n```html\n<link rel=\"stylesheet\" type=\"text/css\" href=\"inert.css\" id=\"inert-style\" />\n```\n\nThe stylesheet should include the following rules:\n\n```css\n[inert] {\n  pointer-events: none;\n  cursor: default;\n}\n\n[inert], [inert] * {\n  user-select: none;\n  -webkit-user-select: none;\n  -ms-user-select: none;\n}\n```\n\n### Performance and gotchas\n\nThe polyfill attempts to provide a reasonable fidelity polyfill for the `inert`\n**attribute**, however please note:\n\n- It relies on mutation observers to detect the addition of the `inert`\n  attribute, and to detect dynamically added content within inert subtrees.\n  Testing for _inert_-ness in any way immediately after either type of mutation\n  will therefore give inconsistent results; please allow the current task to end\n  before relying on mutation-related changes to take effect, for example via\n  `setTimeout(fn, 0)` or `Promise.resolve()`.\n\n  Example:\n```js\nconst newButton = document.createElement('button');\nconst inertContainer = document.querySelector('[inert]');\ninertContainer.appendChild(newButton);\n// Wait for the next microtask to allow mutation observers to react to the\n// DOM change\nPromise.resolve().then(() => {\n  expect(isUnfocusable(newButton)).to.equal(true);\n});\n```\n- Using the `inert` **property**, however, is synchronous.\n\n- The polyfill will be expensive, performance-wise, compared to a native `inert`\n  implementation, because it requires a fair amount of tree-walking. To mitigate\n  this, we recommend not using `inert` during performance sensitive actions\n  (like during animations or scrolling). Instead, wait till these events are\n  complete, or consider using\n  [requestIdleCallback](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback)\n  to set `inert`.\n\n# Testing\n\nTests are written using ES5 syntax. This is to avoid needing to transpile them\nfor older browsers. There are a few modern features they rely upon, e.g.\n`Array.from` and `Promises`. These are polyfilled for the tests using\n[https://cdnjs.cloudflare.com/polyfill](https://cdnjs.cloudflare.com/polyfill). For a list of polyfilled features, check out\nthe `polyfill` section in `karma.conf.js`.\n\n### Big Thanks\n\nCross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][homepage]\n\n<a href=\"https://saucelabs.com\"><img src=\"https://i.imgur.com/f2cK9ZQ.jpg\" width=\"200\"></a>\n\n[homepage]: https://saucelabs.com\n\n","publish_time":1723480141627,"_cnpm_publish_time":1723480141627,"dist-tags":{"latest":"3.1.3"}}