Gathering detailed insights and metrics for blocking-elements
Gathering detailed insights and metrics for blocking-elements
Gathering detailed insights and metrics for blocking-elements
Gathering detailed insights and metrics for blocking-elements
set-blocking
set blocking stdio and stderr ensuring that terminal output does not truncate
blocking-proxy
WebDriver Proxy for testing rich clients. It block certain calls until Angular is done updating the page under test.
workerpool
Offload tasks to a pool of workers on node.js and in the browser
stdout-stream
Non-blocking stdout stream
npm install blocking-elements
89.6
Supply Chain
99.5
Quality
82.7
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
15 Stars
59 Commits
4 Forks
29 Watching
19 Branches
12 Contributors
Updated on 13 Jan 2023
Minified
Minified + Gzipped
JavaScript (48.06%)
TypeScript (45.21%)
HTML (6.74%)
Cumulative downloads
Total Downloads
Last day
-13.2%
1,635
Compared to previous day
Last week
3.7%
9,721
Compared to previous week
Last month
21.4%
43,269
Compared to previous month
Last year
-31.7%
427,369
Compared to previous year
Implementation of proposal https://github.com/whatwg/html/issues/897
The polyfill chooses a non-colliding name (
document.$blockingElements
instead ofdocument.blockingElements
) as the proposal is still work in progress and hasn't yet reached consensus on the semantics and functionality (see this discussion for more details).
document.$blockingElements
manages a stack of elements that inert the interaction outside them.
push(elem), remove(elem), pop()
document.$blockingElements.top
) and its subtree is the interactive part of the documenthas(elem)
returns if the element is a blocking elementThis polyfill will:
document.body
inert
to all the siblings of each parent, skipping the parents and the element's distributed content (if any)Use this polyfill together with the wicg-inert polyfill to disable interactions on the rest of the document. See the demo page as an example.
Another 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.
Wrapping 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.
This 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).
Blocking Elements relies on the inert
attribute and uses Set
objects, so make sure to include their polyfills as needed.
1npm install --save babel-polyfill 2npm install --save wicg-inert 3npm install --save blocking-elements
1<script src="./node_modules/babel-polyfill/dist/polyfill.min.js"></script> 2<script src="./node_modules/wicg-inert/dist/inert.min.js"></script> 3<script src="./node_modules/blocking-elements/dist/blocking-elements.min.js"></script> 4 5<div id="container"> 6 <button onclick="makeBlocking(container)">make blocking</button> 7 <button onclick="undoBlocking(container)">undo blocking</button> 8</div> 9 10<button>some button</button> 11 12<script> 13 function makeBlocking(element) { 14 document.$blockingElements.push(element); 15 } 16 function undoBlocking(element) { 17 document.$blockingElements.remove(element); 18 } 19</script>
Two scripts are included:
/dist/blocking-elements.min.js
: minified and transpiled to ES5.
/dist/blocking-elements.js
: un-minified ES2017.
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:
1import {DocumentWithBlockingElements} from 'blocking-elements'; 2 3const blockingElements = 4 (document as DocumentWithBlockingElements).$blockingElements; 5 6blockingElements.push(...); 7blockingElements.remove(...);
Install the dependencies with npm install
and serve the resources.
Run the tests locally by navigating to http://localhost:8080/test/
Performance is dependent on the inert
polyfill performance. Chrome recently landed the inert
attribute implementation behind a flag.
Let'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)
.
document.$blockingElements
with native inert is ~15x faster than polyfilled inert 🎉 🎉 🎉
with polyfilled inert (M58) | with native inert (M60) |
---|---|
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/5 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
39 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More