wicg-inert 3.0.3 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/inert.esm.js +832 -0
- package/dist/inert.js +17 -17
- package/dist/inert.min.js +1 -1
- package/dist/inert.min.js.map +1 -1
- package/karma.conf.js +7 -65
- package/package.json +9 -6
- package/rollup.config.js +12 -0
- package/security-privacy.md +90 -0
- package/src/inert.js +18 -18
- package/test/specs/element.spec.js +3 -3
- package/test/specs/helpers/index.js +1 -1
- package/w3c.json +1 -1
package/src/inert.js
CHANGED
@@ -52,14 +52,14 @@
|
|
52
52
|
*/
|
53
53
|
class InertRoot {
|
54
54
|
/**
|
55
|
-
* @param {!
|
55
|
+
* @param {!HTMLElement} rootElement The HTMLElement at the root of the inert subtree.
|
56
56
|
* @param {!InertManager} inertManager The global singleton InertManager object.
|
57
57
|
*/
|
58
58
|
constructor(rootElement, inertManager) {
|
59
59
|
/** @type {!InertManager} */
|
60
60
|
this._inertManager = inertManager;
|
61
61
|
|
62
|
-
/** @type {!
|
62
|
+
/** @type {!HTMLElement} */
|
63
63
|
this._rootElement = rootElement;
|
64
64
|
|
65
65
|
/**
|
@@ -184,7 +184,7 @@
|
|
184
184
|
if (node.nodeType !== Node.ELEMENT_NODE) {
|
185
185
|
return;
|
186
186
|
}
|
187
|
-
const element = /** @type {!
|
187
|
+
const element = /** @type {!HTMLElement} */ (node);
|
188
188
|
|
189
189
|
// If a descendant inert root becomes un-inert, its descendants will still be inert because of
|
190
190
|
// this inert root, so all of its managed nodes need to be adopted by this InertRoot.
|
@@ -227,7 +227,7 @@
|
|
227
227
|
|
228
228
|
/**
|
229
229
|
* If a descendant node is found with an `inert` attribute, adopt its managed nodes.
|
230
|
-
* @param {!
|
230
|
+
* @param {!HTMLElement} node
|
231
231
|
*/
|
232
232
|
_adoptInertRoot(node) {
|
233
233
|
let inertSubroot = this._inertManager.getInertRoot(node);
|
@@ -251,7 +251,7 @@
|
|
251
251
|
*/
|
252
252
|
_onMutation(records, self) {
|
253
253
|
records.forEach(function(record) {
|
254
|
-
const target = /** @type {!
|
254
|
+
const target = /** @type {!HTMLElement} */ (record.target);
|
255
255
|
if (record.type === 'childList') {
|
256
256
|
// Manage added nodes
|
257
257
|
slice.call(record.addedNodes).forEach(function(node) {
|
@@ -334,7 +334,7 @@
|
|
334
334
|
this._throwIfDestroyed();
|
335
335
|
|
336
336
|
if (this._node && this._node.nodeType === Node.ELEMENT_NODE) {
|
337
|
-
const element = /** @type {!
|
337
|
+
const element = /** @type {!HTMLElement} */ (this._node);
|
338
338
|
if (this._savedTabIndex !== null) {
|
339
339
|
element.setAttribute('tabindex', this._savedTabIndex);
|
340
340
|
} else {
|
@@ -398,7 +398,7 @@
|
|
398
398
|
if (this.node.nodeType !== Node.ELEMENT_NODE) {
|
399
399
|
return;
|
400
400
|
}
|
401
|
-
const element = /** @type {!
|
401
|
+
const element = /** @type {!HTMLElement} */ (this.node);
|
402
402
|
if (matches.call(element, _focusableElementsString)) {
|
403
403
|
if (/** @type {!HTMLElement} */ (element).tabIndex === -1 &&
|
404
404
|
this.hasSavedTabIndex) {
|
@@ -495,7 +495,7 @@
|
|
495
495
|
|
496
496
|
/**
|
497
497
|
* Set whether the given element should be an inert root or not.
|
498
|
-
* @param {!
|
498
|
+
* @param {!HTMLElement} root
|
499
499
|
* @param {boolean} inert
|
500
500
|
*/
|
501
501
|
setInert(root, inert) {
|
@@ -624,7 +624,7 @@
|
|
624
624
|
if (record.attributeName !== 'inert') {
|
625
625
|
return;
|
626
626
|
}
|
627
|
-
const target = /** @type {!
|
627
|
+
const target = /** @type {!HTMLElement} */ (record.target);
|
628
628
|
const inert = target.hasAttribute('inert');
|
629
629
|
_this.setInert(target, inert);
|
630
630
|
break;
|
@@ -636,13 +636,13 @@
|
|
636
636
|
/**
|
637
637
|
* Recursively walk the composed tree from |node|.
|
638
638
|
* @param {!Node} node
|
639
|
-
* @param {(function (!
|
639
|
+
* @param {(function (!HTMLElement))=} callback Callback to be called for each element traversed,
|
640
640
|
* before descending into child nodes.
|
641
641
|
* @param {?ShadowRoot=} shadowRootAncestor The nearest ShadowRoot ancestor, if any.
|
642
642
|
*/
|
643
643
|
function composedTreeWalk(node, callback, shadowRootAncestor) {
|
644
644
|
if (node.nodeType == Node.ELEMENT_NODE) {
|
645
|
-
const element = /** @type {!
|
645
|
+
const element = /** @type {!HTMLElement} */ (node);
|
646
646
|
if (callback) {
|
647
647
|
callback(element);
|
648
648
|
}
|
@@ -720,17 +720,17 @@
|
|
720
720
|
node.appendChild(style);
|
721
721
|
}
|
722
722
|
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
Object.defineProperty(
|
723
|
+
if (!HTMLElement.prototype.hasOwnProperty('inert')) {
|
724
|
+
/** @type {!InertManager} */
|
725
|
+
const inertManager = new InertManager(document);
|
726
|
+
|
727
|
+
Object.defineProperty(HTMLElement.prototype, 'inert', {
|
728
728
|
enumerable: true,
|
729
|
-
/** @this {!
|
729
|
+
/** @this {!HTMLElement} */
|
730
730
|
get: function() {
|
731
731
|
return this.hasAttribute('inert');
|
732
732
|
},
|
733
|
-
/** @this {!
|
733
|
+
/** @this {!HTMLElement} */
|
734
734
|
set: function(inert) {
|
735
735
|
inertManager.setInert(this, inert);
|
736
736
|
},
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('
|
2
|
-
it('should patch the
|
3
|
-
expect(
|
1
|
+
describe('HTMLElement.prototype', function() {
|
2
|
+
it('should patch the HTMLElement prototype', function() {
|
3
|
+
expect(HTMLElement.prototype.hasOwnProperty('inert')).to.be.ok;
|
4
4
|
});
|
5
5
|
});
|
@@ -14,7 +14,7 @@ LOG.info = function() {
|
|
14
14
|
* Check if an element is not focusable.
|
15
15
|
* Note: This will be injected into the global scope by the test runner.
|
16
16
|
* See the files array in karma.conf.js.
|
17
|
-
* @param {
|
17
|
+
* @param {HTMLElement} el
|
18
18
|
* @return {Boolean}
|
19
19
|
*/
|
20
20
|
function isUnfocusable(el) { // eslint-disable-line no-unused-vars
|
package/w3c.json
CHANGED