{"_id":"blocking-elements","_rev":"11-1c34a64ad79c2711d7cedff1ada13710","name":"blocking-elements","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.1":{"name":"blocking-elements","version":"0.0.1","keywords":["blocking-elements","polyfill","browser"],"author":{"name":"Valdrin Koshi","email":"valdrin@google.com"},"license":"BSD-3-Clause","_id":"blocking-elements@0.0.1","maintainers":[{"name":"valdrinkoshi","email":"valdrinkoshi@gmail.com"}],"homepage":"https://github.com/PolymerLabs/blockingElements#readme","bugs":{"url":"https://github.com/PolymerLabs/blockingElements/issues"},"dist":{"shasum":"16c7a97b376a92e9130f84d633c1834fc6f060b8","tarball":"https://registry.npmjs.org/blocking-elements/-/blocking-elements-0.0.1.tgz","fileCount":32,"integrity":"sha512-ajByYh2BEqTtxsNp/+fPZKinM3W6iT0GurrMfpr0/699i97airB5UEQsoAwA0pi7vQCWcZVhx7YxvzMe6j9MpA==","signatures":[{"sig":"MEYCIQCWZakFM6dxAhjePGxrHfLMp6wjt4gSRInCE5vmHrKOQgIhALR9HTXxQ1yEpFfjIIdNcGu8z8HcDe/FwUCgEcWyGgn7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1134041},"main":"dist/blocking-elements.js","gitHead":"c2dc499750a893a562b8ae9ad7e7f317f6df00ee","scripts":{"lint":"eslint blocking-elements.js","test":"npm run lint && npm run build && easy-sauce","build":"rollem"},"_npmUser":{"name":"valdrinkoshi","email":"valdrinkoshi@gmail.com"},"easySauce":{"port":"8080","service":"sauce-connect","testPath":"/test/","platforms":[["Windows 10","chrome","latest"],["Linux","firefox","latest"],["Windows 10","microsoftedge","14"],["OS X 10.11","safari","9"],["OS X 10.12","safari","10"]],"max-duration":120},"repository":{"url":"git+https://github.com/PolymerLabs/blockingElements.git","type":"git"},"_npmVersion":"5.7.1","description":"A polyfill for the proposed blocking elments stack API","directories":{},"_nodeVersion":"8.0.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.0.2","mocha":"^4.0.1","eslint":"^4.0.0","rollem":"^1.11.0","rollup":"^0.53.0","babel-core":"^6.26.0","easy-sauce":"^0.4.1","wicg-inert":"^1.1.6","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","rollup-plugin-babel":"^3.0.2","eslint-config-google":"^0.9.1","rollup-plugin-uglify":"^2.0.1","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-node-resolve":"^3.0.0","babel-plugin-external-helpers":"^6.22.0","@webcomponents/webcomponentsjs":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/blocking-elements_0.0.1_1521579059790_0.6364718148999964","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"blocking-elements","version":"0.0.2","keywords":["blocking-elements","polyfill","browser"],"author":{"name":"Valdrin Koshi","email":"valdrin@google.com"},"license":"BSD-3-Clause","_id":"blocking-elements@0.0.2","maintainers":[{"name":"valdrinkoshi","email":"valdrinkoshi@gmail.com"}],"homepage":"https://github.com/PolymerLabs/blockingElements#readme","bugs":{"url":"https://github.com/PolymerLabs/blockingElements/issues"},"dist":{"shasum":"fd1fb73c090415039e7ad497879decc7c54f20bf","tarball":"https://registry.npmjs.org/blocking-elements/-/blocking-elements-0.0.2.tgz","fileCount":32,"integrity":"sha512-sMYXYkCAAV4hBrKGZ8ylp761A02uRDjpueW23W43/YvYR6gFD/Z7cIHWvJbSUDmnpzws9VQxSMHdm4/UbL4PKg==","signatures":[{"sig":"MEQCIHm0clZxSxrQdISyY5VQ/Zy1l+Czcb2qfTk+5xB29RcGAiBDcfrZJEshXdlOkp6VpE2GH6mbh/UciBt9cC1d4pupPg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1143054},"main":"dist/blocking-elements.js","gitHead":"ddf580695e54c9db9a2f70a665de0f6d1a8442b5","scripts":{"lint":"eslint blocking-elements.js","test":"npm run lint && npm run build && easy-sauce","build":"rollem"},"_npmUser":{"name":"valdrinkoshi","email":"valdrinkoshi@gmail.com"},"easySauce":{"port":"8080","service":"sauce-connect","testPath":"/test/","platforms":[["Windows 10","chrome","latest"],["Linux","firefox","latest"],["Windows 10","microsoftedge","14"],["OS X 10.11","safari","9"],["OS X 10.12","safari","10"]],"max-duration":120},"repository":{"url":"git+https://github.com/PolymerLabs/blockingElements.git","type":"git"},"_npmVersion":"5.7.1","description":"A polyfill for the proposed blocking elments stack API","directories":{},"_nodeVersion":"8.0.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.0.2","mocha":"^4.0.1","eslint":"^4.0.0","rollem":"^1.11.0","rollup":"^0.53.0","babel-core":"^6.26.0","easy-sauce":"^0.4.1","wicg-inert":"^1.1.6","babel-polyfill":"^6.26.0","babel-preset-env":"^1.6.1","rollup-plugin-babel":"^3.0.2","eslint-config-google":"^0.9.1","rollup-plugin-uglify":"^2.0.1","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-node-resolve":"^3.0.0","babel-plugin-external-helpers":"^6.22.0","@webcomponents/webcomponentsjs":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/blocking-elements_0.0.2_1521593138370_0.6673738302685974","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"blocking-elements","version":"0.1.0","keywords":["blocking-elements","polyfill","browser"],"author":{"name":"Valdrin Koshi","email":"valdrin@google.com"},"license":"Apache-2.0","_id":"blocking-elements@0.1.0","maintainers":[{"name":"valdrinkoshi","email":"valdrinkoshi@gmail.com"}],"homepage":"https://github.com/PolymerLabs/blocking-elements#readme","bugs":{"url":"https://github.com/PolymerLabs/blocking-elements/issues"},"dist":{"shasum":"e590b35969bb2eea571c95407e9843a80bd113a8","tarball":"https://registry.npmjs.org/blocking-elements/-/blocking-elements-0.1.0.tgz","fileCount":16,"integrity":"sha512-m9UvynAHLhlWH4vSovSDAopW7DyJ91qeDnNrJqy+DE+tjhUYiXW1x7pOm3DZBczlQPPypWpOwOz5xd5A76vNvg==","signatures":[{"sig":"MEUCIHvTGQlKnuH2oc7oldH9SxgplYeM4iV2LOKMpeqVB2zfAiEAnrjcjBknkFFUT6EOAMIf+3dQWPNsTvzWqsQPo19x16I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":977392,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQHj9CRA9TVsSAnZWagAADOoP/0Eeye2OfGkJOKUAbL+v\nvNyQTQ7x9NNYH8EUiqA/Tn9KOyCk2/p9mB8gqImMdKeTIo+gcjgfhdgzY+Iq\nvHB78T7AosKabIO5qZv70InoYtNObZSCIv26TJxvrBGT+iLMA5dRNoM33P7d\nRl2ySw3yLwY48dIgrM49kpJVwlgmT25GUiNew6HXlKTSyHIbtoO0HW21eObD\nbcv1k7mEEOmL5E6OsNqhKuDnWMP33h6GWrvTWfPPCD0k0Uewugz7ocIG10EN\nukyG6PDQVSRoZIrRInL0hf8x2wMKY7HoL2OKZmt1BHnYe6IZw8wn8Zce5cd9\n+0ROBWb4MKMV9cpeJ+bq5ob44PKzacSkjEOzLGTkoXfUle5rCwFn7RsSJHTm\nahvWlM0Bua+ETcSmyTEIhwghP/BH42AJyQj6madCSyj2ownTPoHmPlo6vXJ/\nvQJ4397UP5wfjQ0Sp8+UQcPdbSFeMRv9Sl9wKPVe5C4hfPf8hjO2wgL0i5T7\nqgDri62hHoOxADiv7Ng8KgkIEMucnNmHLrPWUkOg/24bYicePk18zz5zaEHs\ndhXFp5PPEdjMckX2y//Nq6IgbII0NujmydeWub2kiGXATqKDy1U3CTt+CTGF\nn2n4e75IZZ0ffzp15EnaRRbovB6a3+KFVBsce5/mwl7pm9d7zkIeoaQvkytS\n10DI\r\n=PPvB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/blocking-elements.js","gitHead":"0bb03a0d34aaed2564974d65928f38f4e0f26153","scripts":{"lint":"tslint --project ./","test":"npm run lint && npm run build && easy-sauce","build":"rm -rf dist/* && tsc && rollup -c","format":"clang-format --style=file -i src/*.ts","prepack":"npm run build"},"_npmUser":{"name":"aomarks","email":"aomarks@google.com"},"easySauce":{"port":"8080","service":"sauce-connect","testPath":"/test/","platforms":[["Windows 10","chrome","latest"],["Linux","firefox","latest"],["Windows 10","microsoftedge","latest"]],"max-duration":300},"repository":{"url":"git+https://github.com/PolymerLabs/blocking-elements.git","type":"git"},"_npmVersion":"6.10.2","description":"A polyfill for the proposed blocking elements stack API","directories":{},"_nodeVersion":"12.7.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.0.2","mocha":"^6.2.0","rollup":"^1.17.0","tslint":"^5.18.0","easy-sauce":"^0.4.1","typescript":"^3.5.3","wicg-inert":"^2.1.2","@babel/core":"^7.5.5","clang-format":"^1.2.4","babel-polyfill":"^6.26.0","@babel/preset-env":"^7.5.5","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2","rollup-plugin-commonjs":"^10.0.1","rollup-plugin-node-resolve":"^5.2.0","@webcomponents/webcomponentsjs":"^2.2.10"},"_npmOperationalInternal":{"tmp":"tmp/blocking-elements_0.1.0_1564506364283_0.5846812620185549","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"blocking-elements","version":"0.1.1","keywords":["blocking-elements","polyfill","browser"],"author":{"name":"Valdrin Koshi","email":"valdrin@google.com"},"license":"Apache-2.0","_id":"blocking-elements@0.1.1","maintainers":[{"name":"aomarks","email":"aomarks@google.com"},{"name":"azakus","email":"dfreedm2@gmail.com"},{"name":"bicknellr","email":"bicknellr@gmail.com"},{"name":"emarquez","email":"emarquez@google.com"},{"name":"justinfagnani","email":"justin@fagnani.com"},{"name":"polymer-devs","email":"admin@polymer-project.org"},{"name":"sorvell","email":"sorvell@google.com"},{"name":"straversi","email":"straversi@berkeley.edu"},{"name":"tvanderlippe","email":"tvanderlippe@google.com"},{"name":"usergenic","email":"brendan@usergenic.com"}],"homepage":"https://github.com/PolymerLabs/blocking-elements#readme","bugs":{"url":"https://github.com/PolymerLabs/blocking-elements/issues"},"dist":{"shasum":"6acddbe2714a029a1774e9219bcf38736e07ded3","tarball":"https://registry.npmjs.org/blocking-elements/-/blocking-elements-0.1.1.tgz","fileCount":16,"integrity":"sha512-/SLWbEzMoVIMZACCyhD/4Ya2M1PWP1qMKuiymowPcI+PdWDARqeARBjhj73kbUBCxEmTZCUu5TAqxtwUO9C1Ig==","signatures":[{"sig":"MEYCIQD9AdDSVStzQF3U7GRWaHAe2MuOP4WkAqPb5vOqGlkklAIhAO4s+5uJRPPgi660r1us2B0cPyier7+NmnW2Gmj88MjK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":977433,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2k3PCRA9TVsSAnZWagAAqwYP/RcY9MWy4sD/Kv2TvVQe\nYmcuw6Gnb6+U+OBDuijEdeVRHE7ssXsqFjOcVwpMEucWLcn2r+fraN3SlO7+\ndZ99B74nLgPEKcSKtk2UwQMNZ8mP1rcQtRAqFbSdv9baVzFSaLeaAy8kAwQb\n+hyMCMR0Pt5urwJbZH2avqY1tW3skRhej8AgL3xPFEXUMCBnBm/Qpjl1PFco\nCH4aXaiQdrF539rbYteLupHPiwYVL9szExbVOPNNLx7aQDHLBq4cWhv69R0r\nsHxjpzfEihcpy0Un6E6SSi2ZpVpUGSyDRsj6Fv3rmhVYBbhBIOj0uRaeflKL\n5b1RNGaSiBoEtxN2VaIVoA/oCCvhqPw8IsrOMJg0LLxsVmLcCgsnkRqMR4Qu\nb32km3H/dB8uNeIHKTqRb695Nbn8kJUsVVS7H+Hziq8utOKi6DV6Ry5dA5Qs\naIbAZqNeFTilvkTBpl2/YSayMpxdALTzaUJ3P+eAm1kT1cgSpigAm/8Dx7wy\nVlN41iLkvF3iJRVHU1+fbC02wrzbmZcm/LcAd9K//dhjaVVlJ5RYI9XR5bwj\nU+5wNz3j3f+Dx1+89rhew1T//XG/qjgdmEG0LHGAW8mzKktolhcK5B56uCy3\nDgiaqDEKl+TkPZNb7DkfW/kNv27ZKxbaUSvtsMEcYg2KiOjXL3rnRhrLA1l+\nhMiy\r\n=Zpt0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/blocking-elements.js","module":"dist/blocking-elements.js","gitHead":"af46699b5f3094e851d3678448a7b31f01f6834e","scripts":{"lint":"tslint --project ./","test":"npm run lint && npm run build && easy-sauce","build":"rm -rf dist/* && tsc && rollup -c","format":"clang-format --style=file -i src/*.ts","prepack":"npm run build"},"_npmUser":{"name":"emarquez","email":"emarquez@google.com"},"easySauce":{"port":"8080","service":"sauce-connect","testPath":"/test/","platforms":[["Windows 10","chrome","latest"],["Linux","firefox","latest"],["Windows 10","microsoftedge","latest"]],"max-duration":300},"repository":{"url":"git+https://github.com/PolymerLabs/blocking-elements.git","type":"git"},"_npmVersion":"6.13.6","description":"A polyfill for the proposed blocking elements stack API","directories":{},"_nodeVersion":"13.8.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.0.2","mocha":"^6.2.0","rollup":"^1.17.0","tslint":"^5.18.0","easy-sauce":"^0.4.1","typescript":"^3.5.3","wicg-inert":"^2.1.2","@babel/core":"^7.5.5","clang-format":"^1.2.4","babel-polyfill":"^6.26.0","@babel/preset-env":"^7.5.5","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2","rollup-plugin-commonjs":"^10.0.1","rollup-plugin-node-resolve":"^5.2.0","@webcomponents/webcomponentsjs":"^2.2.10"},"_npmOperationalInternal":{"tmp":"tmp/blocking-elements_0.1.1_1586482504134_0.8685736595353388","host":"s3://npm-registry-packages"}}},"time":{"created":"2018-03-20T20:50:59.789Z","modified":"2024-10-07T21:27:00.486Z","0.0.1":"2018-03-20T20:50:59.961Z","0.0.2":"2018-03-21T00:45:38.465Z","0.1.0":"2019-07-30T17:06:04.887Z","0.1.1":"2020-04-10T01:35:04.448Z"},"bugs":{"url":"https://github.com/PolymerLabs/blocking-elements/issues"},"author":{"name":"Valdrin Koshi","email":"valdrin@google.com"},"license":"Apache-2.0","homepage":"https://github.com/PolymerLabs/blocking-elements#readme","keywords":["blocking-elements","polyfill","browser"],"repository":{"url":"git+https://github.com/PolymerLabs/blocking-elements.git","type":"git"},"description":"A polyfill for the proposed blocking elements stack API","maintainers":[{"email":"rictic@gmail.com","name":"rictic"},{"email":"aomarks@gmail.com","name":"aomarks"},{"email":"emarquez@google.com","name":"emarquez"},{"email":"sorvell@google.com","name":"sorvell"},{"email":"bicknellr@gmail.com","name":"bicknellr"},{"email":"brendan@usergenic.com","name":"usergenic"},{"email":"admin@polymer-project.org","name":"polymer-devs"},{"email":"dfreedm2@gmail.com","name":"azakus"},{"email":"kevinpschaaf@gmail.com","name":"kevinpschaaf"},{"email":"justin@fagnani.com","name":"justinfagnani"}],"readme":"[![Build Status](https://travis-ci.org/PolymerLabs/blocking-elements.svg?branch=master)](https://travis-ci.org/PolymerLabs/blocking-elements)\n[![Published on npm](https://img.shields.io/npm/v/blocking-elements.svg)](https://www.npmjs.com/package/blocking-elements)\n\n# Blocking Elements stack API\n\nImplementation of proposal https://github.com/whatwg/html/issues/897\n\n> The polyfill chooses a non-colliding name (`document.$blockingElements` instead of `document.blockingElements`) as the proposal is still work in progress and hasn't yet reached consensus on the semantics and functionality (see [this discussion](https://github.com/PolymerLabs/blocking-elements/pull/1#issuecomment-235102344) for more details).\n\n`document.$blockingElements` manages a stack of elements that inert the interaction outside them.\n\n- the stack can be updated with the methods `push(elem), remove(elem), pop()`\n- the top element (`document.$blockingElements.top`) and its subtree is the interactive part of the document\n- `has(elem)` returns if the element is a blocking element\n\nThis polyfill will:\n\n- search for the path of the element to block up to `document.body`\n- set `inert` to all the siblings of each parent, skipping the parents and the element's distributed content (if any)\n\nUse this polyfill together with the [wicg-inert](https://github.com/WICG/inert) polyfill to disable interactions on the rest of the document. See the [demo page](https://github.com/PolymerLabs/blocking-elements/blob/master/demo/index.html) as an example.\n\n## Why not listening to events that trigger focus change?\n\nAnother approach could be to listen for events that trigger focus change (e.g. `focus, blur, keydown`) and prevent those if focus moves out of the blocking element.\n\nWrapping the focus requires to find all the focusable nodes within the top blocking element, eventually sort by tabindex, in order to find first and last focusable node.\n\nThis approach doesn't allow the focus to move outside the window (e.g. to the browser's url bar, dev console if opened, etc.), and is less robust when used with assistive technology (e.g. android talkback allows to move focus with swipe on screen, Apple Voiceover allows to move focus with special keyboard combinations).\n\n## Install & use\n\nBlocking Elements relies on the [`inert` attribute](https://github.com/WICG/inert) and uses [`Set` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set), so make sure to include their polyfills as needed.\n\n```bash\nnpm install --save babel-polyfill\nnpm install --save wicg-inert\nnpm install --save blocking-elements\n```\n\n```html\n<script src=\"./node_modules/babel-polyfill/dist/polyfill.min.js\"></script>\n<script src=\"./node_modules/wicg-inert/dist/inert.min.js\"></script>\n<script src=\"./node_modules/blocking-elements/dist/blocking-elements.min.js\"></script>\n\n<div id=\"container\">\n  <button onclick=\"makeBlocking(container)\">make blocking</button>\n  <button onclick=\"undoBlocking(container)\">undo blocking</button>\n</div>\n\n<button>some button</button>\n\n<script>\n  function makeBlocking(element) {\n    document.$blockingElements.push(element);\n  }\n  function undoBlocking(element) {\n    document.$blockingElements.remove(element);\n  }\n</script>\n```\n\n## Files\n\nTwo scripts are included:\n\n1. `/dist/blocking-elements.min.js`: minified and transpiled to ES5.\n\n2. `/dist/blocking-elements.js`: un-minified ES2017.\n\n   If your toolchain supports Node-style module resolution (e.g. TypeScript's `--moduleResolution=node`), then the main `blocking-elements` bare module specifier resolves to this file. TypeScript declarations are also included for this module:\n   \n   ```ts\n   import {DocumentWithBlockingElements} from 'blocking-elements';\n\n   const blockingElements =\n       (document as DocumentWithBlockingElements).$blockingElements;\n\n   blockingElements.push(...);\n   blockingElements.remove(...);\n   ```\n\n\n## Local development\n\nInstall the dependencies with `npm install` and serve the resources.\n\nRun the tests locally by navigating to http://localhost:8080/test/\n\n## Performance\n\nPerformance is dependent on the `inert` polyfill performance. Chrome recently landed [the `inert` attribute implementation](https://codereview.chromium.org/2088453002/) behind a flag.\n\nLet's compare the how long it takes to toggle the deepest `x-trap-focus` inside nested `x-b` of the demo page (<http://localhost:8080/demo/ce.html?ce=v1>)\n\n![results](https://cloud.githubusercontent.com/assets/6173664/17538133/914f365a-5e57-11e6-9b91-1c6b7eb22d57.png).\n\n`document.$blockingElements` with native inert is **~15x faster** than polyfilled inert 🎉 🎉 🎉\n\n| with polyfilled inert (M58) | with native inert (M60) |\n|----------|--------|\n| ![polyfill-inert-1.png](assets/polyfill-inert-1.png) | ![native-inert-1.png](assets/native-inert-1.png) |\n| ![polyfill-inert-2.png](assets/polyfill-inert-2.png) | ![native-inert-2.png](assets/native-inert-2.png) |\n| ![polyfill-inert-3.png](assets/polyfill-inert-3.png) | ![native-inert-3.png](assets/native-inert-3.png) |\n| ![polyfill-inert-4.png](assets/polyfill-inert-4.png) | ![native-inert-4.png](assets/native-inert-4.png) |\n","readmeFilename":"README.md"}