@wordpress/dom 4.32.0 → 4.32.1-next.b8c8708f3.0
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/build/data-transfer.js +30 -18
- package/build/data-transfer.js.map +7 -1
- package/build/dom/caret-range-from-point.js +22 -25
- package/build/dom/caret-range-from-point.js.map +7 -1
- package/build/dom/clean-node-list.js +122 -129
- package/build/dom/clean-node-list.js.map +7 -1
- package/build/dom/compute-caret-rect.js +36 -21
- package/build/dom/compute-caret-rect.js.map +7 -1
- package/build/dom/document-has-selection.js +36 -22
- package/build/dom/document-has-selection.js.map +7 -1
- package/build/dom/document-has-text-selection.js +25 -23
- package/build/dom/document-has-text-selection.js.map +7 -1
- package/build/dom/document-has-uncollapsed-selection.js +35 -22
- package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/get-computed-style.js +27 -17
- package/build/dom/get-computed-style.js.map +7 -1
- package/build/dom/get-offset-parent.js +43 -32
- package/build/dom/get-offset-parent.js.map +7 -1
- package/build/dom/get-range-height.js +24 -18
- package/build/dom/get-range-height.js.map +7 -1
- package/build/dom/get-rectangle-from-range.js +47 -68
- package/build/dom/get-rectangle-from-range.js.map +7 -1
- package/build/dom/get-scroll-container.js +44 -37
- package/build/dom/get-scroll-container.js.map +7 -1
- package/build/dom/hidden-caret-range-from-point.js +39 -33
- package/build/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build/dom/index.js +116 -195
- package/build/dom/index.js.map +7 -1
- package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
- package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/insert-after.js +24 -19
- package/build/dom/insert-after.js.map +7 -1
- package/build/dom/is-edge.js +57 -67
- package/build/dom/is-edge.js.map +7 -1
- package/build/dom/is-element.js +22 -11
- package/build/dom/is-element.js.map +7 -1
- package/build/dom/is-empty.js +27 -17
- package/build/dom/is-empty.js.map +7 -1
- package/build/dom/is-entirely-selected.js +46 -50
- package/build/dom/is-entirely-selected.js.map +7 -1
- package/build/dom/is-form-element.js +36 -24
- package/build/dom/is-form-element.js.map +7 -1
- package/build/dom/is-horizontal-edge.js +34 -20
- package/build/dom/is-horizontal-edge.js.map +7 -1
- package/build/dom/is-html-input-element.js +23 -12
- package/build/dom/is-html-input-element.js.map +7 -1
- package/build/dom/is-input-or-text-area.js +23 -12
- package/build/dom/is-input-or-text-area.js.map +7 -1
- package/build/dom/is-number-input.js +38 -29
- package/build/dom/is-number-input.js.map +7 -1
- package/build/dom/is-rtl.js +34 -19
- package/build/dom/is-rtl.js.map +7 -1
- package/build/dom/is-selection-forward.js +26 -40
- package/build/dom/is-selection-forward.js.map +7 -1
- package/build/dom/is-text-field.js +49 -24
- package/build/dom/is-text-field.js.map +7 -1
- package/build/dom/is-vertical-edge.js +34 -20
- package/build/dom/is-vertical-edge.js.map +7 -1
- package/build/dom/place-caret-at-edge.js +52 -55
- package/build/dom/place-caret-at-edge.js.map +7 -1
- package/build/dom/place-caret-at-horizontal-edge.js +34 -18
- package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build/dom/place-caret-at-vertical-edge.js +34 -19
- package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build/dom/remove-invalid-html.js +35 -22
- package/build/dom/remove-invalid-html.js.map +7 -1
- package/build/dom/remove.js +24 -17
- package/build/dom/remove.js.map +7 -1
- package/build/dom/replace-tag.js +24 -19
- package/build/dom/replace-tag.js.map +7 -1
- package/build/dom/replace.js +38 -23
- package/build/dom/replace.js.map +7 -1
- package/build/dom/safe-html.js +39 -28
- package/build/dom/safe-html.js.map +7 -1
- package/build/dom/scroll-if-no-range.js +26 -18
- package/build/dom/scroll-if-no-range.js.map +7 -1
- package/build/dom/strip-html.js +36 -23
- package/build/dom/strip-html.js.map +7 -1
- package/build/dom/unwrap.js +24 -18
- package/build/dom/unwrap.js.map +7 -1
- package/build/dom/wrap.js +24 -17
- package/build/dom/wrap.js.map +7 -1
- package/build/focusable.js +52 -85
- package/build/focusable.js.map +7 -1
- package/build/index.js +44 -58
- package/build/index.js.map +7 -1
- package/build/phrasing-content.js +88 -128
- package/build/phrasing-content.js.map +7 -1
- package/build/tabbable.js +52 -137
- package/build/tabbable.js.map +7 -1
- package/build/utils/assert-is-defined.js +30 -7
- package/build/utils/assert-is-defined.js.map +7 -1
- package/build-module/data-transfer.js +9 -15
- package/build-module/data-transfer.js.map +7 -1
- package/build-module/dom/caret-range-from-point.js +5 -22
- package/build-module/dom/caret-range-from-point.js.map +7 -1
- package/build-module/dom/clean-node-list.js +94 -123
- package/build-module/dom/clean-node-list.js.map +7 -1
- package/build-module/dom/compute-caret-rect.js +8 -16
- package/build-module/dom/compute-caret-rect.js.map +7 -1
- package/build-module/dom/document-has-selection.js +8 -17
- package/build-module/dom/document-has-selection.js.map +7 -1
- package/build-module/dom/document-has-text-selection.js +8 -20
- package/build-module/dom/document-has-text-selection.js.map +7 -1
- package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
- package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/get-computed-style.js +10 -14
- package/build-module/dom/get-computed-style.js.map +7 -1
- package/build-module/dom/get-offset-parent.js +16 -28
- package/build-module/dom/get-offset-parent.js.map +7 -1
- package/build-module/dom/get-range-height.js +7 -15
- package/build-module/dom/get-range-height.js.map +7 -1
- package/build-module/dom/get-rectangle-from-range.js +30 -65
- package/build-module/dom/get-rectangle-from-range.js.map +7 -1
- package/build-module/dom/get-scroll-container.js +16 -32
- package/build-module/dom/get-scroll-container.js.map +7 -1
- package/build-module/dom/hidden-caret-range-from-point.js +11 -28
- package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build-module/dom/index.js +57 -28
- package/build-module/dom/index.js.map +7 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
- package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/insert-after.js +7 -16
- package/build-module/dom/insert-after.js.map +7 -1
- package/build-module/dom/is-edge.js +24 -57
- package/build-module/dom/is-edge.js.map +7 -1
- package/build-module/dom/is-element.js +5 -8
- package/build-module/dom/is-element.js.map +7 -1
- package/build-module/dom/is-empty.js +10 -14
- package/build-module/dom/is-empty.js.map +7 -1
- package/build-module/dom/is-entirely-selected.js +18 -45
- package/build-module/dom/is-entirely-selected.js.map +7 -1
- package/build-module/dom/is-form-element.js +8 -19
- package/build-module/dom/is-form-element.js.map +7 -1
- package/build-module/dom/is-horizontal-edge.js +6 -15
- package/build-module/dom/is-horizontal-edge.js.map +7 -1
- package/build-module/dom/is-html-input-element.js +6 -9
- package/build-module/dom/is-html-input-element.js.map +7 -1
- package/build-module/dom/is-input-or-text-area.js +6 -9
- package/build-module/dom/is-input-or-text-area.js.map +7 -1
- package/build-module/dom/is-number-input.js +11 -25
- package/build-module/dom/is-number-input.js.map +7 -1
- package/build-module/dom/is-rtl.js +7 -15
- package/build-module/dom/is-rtl.js.map +7 -1
- package/build-module/dom/is-selection-forward.js +9 -37
- package/build-module/dom/is-selection-forward.js.map +7 -1
- package/build-module/dom/is-text-field.js +22 -20
- package/build-module/dom/is-text-field.js.map +7 -1
- package/build-module/dom/is-vertical-edge.js +6 -15
- package/build-module/dom/is-vertical-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-edge.js +22 -48
- package/build-module/dom/place-caret-at-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
- package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
- package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build-module/dom/remove-invalid-html.js +7 -17
- package/build-module/dom/remove-invalid-html.js.map +7 -1
- package/build-module/dom/remove.js +7 -14
- package/build-module/dom/remove.js.map +7 -1
- package/build-module/dom/replace-tag.js +7 -16
- package/build-module/dom/replace-tag.js.map +7 -1
- package/build-module/dom/replace.js +9 -17
- package/build-module/dom/replace.js.map +7 -1
- package/build-module/dom/safe-html.js +11 -23
- package/build-module/dom/safe-html.js.map +7 -1
- package/build-module/dom/scroll-if-no-range.js +5 -15
- package/build-module/dom/scroll-if-no-range.js.map +7 -1
- package/build-module/dom/strip-html.js +8 -18
- package/build-module/dom/strip-html.js.map +7 -1
- package/build-module/dom/unwrap.js +7 -15
- package/build-module/dom/unwrap.js.map +7 -1
- package/build-module/dom/wrap.js +7 -14
- package/build-module/dom/wrap.js.map +7 -1
- package/build-module/focusable.js +30 -81
- package/build-module/focusable.js.map +7 -1
- package/build-module/index.js +9 -17
- package/build-module/index.js.map +7 -1
- package/build-module/phrasing-content.js +67 -125
- package/build-module/phrasing-content.js.map +7 -1
- package/build-module/tabbable.js +30 -133
- package/build-module/tabbable.js.map +7 -1
- package/build-module/utils/assert-is-defined.js +9 -4
- package/build-module/utils/assert-is-defined.js.map +7 -1
- package/package.json +11 -4
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* If no range range can be created or it is outside the container, the element
|
|
3
|
-
* may be out of view, so scroll it into view and try again.
|
|
4
|
-
*
|
|
5
|
-
* @param {HTMLElement} container The container to scroll.
|
|
6
|
-
* @param {boolean} alignToTop True to align to top, false to bottom.
|
|
7
|
-
* @param {Function} callback The callback to create the range.
|
|
8
|
-
*
|
|
9
|
-
* @return {?Range} The range returned by the callback.
|
|
10
|
-
*/
|
|
11
|
-
export function scrollIfNoRange(container, alignToTop, callback) {
|
|
1
|
+
function scrollIfNoRange(container, alignToTop, callback) {
|
|
12
2
|
let range = callback();
|
|
13
|
-
|
|
14
|
-
// If no range range can be created or it is outside the container, the
|
|
15
|
-
// element may be out of view.
|
|
16
3
|
if (!range || !range.startContainer || !container.contains(range.startContainer)) {
|
|
17
4
|
container.scrollIntoView(alignToTop);
|
|
18
5
|
range = callback();
|
|
@@ -22,4 +9,7 @@ export function scrollIfNoRange(container, alignToTop, callback) {
|
|
|
22
9
|
}
|
|
23
10
|
return range;
|
|
24
11
|
}
|
|
25
|
-
|
|
12
|
+
export {
|
|
13
|
+
scrollIfNoRange
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=scroll-if-no-range.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/scroll-if-no-range.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * If no range range can be created or it is outside the container, the element\n * may be out of view, so scroll it into view and try again.\n *\n * @param {HTMLElement} container The container to scroll.\n * @param {boolean} alignToTop True to align to top, false to bottom.\n * @param {Function} callback The callback to create the range.\n *\n * @return {?Range} The range returned by the callback.\n */\nexport function scrollIfNoRange( container, alignToTop, callback ) {\n\tlet range = callback();\n\n\t// If no range range can be created or it is outside the container, the\n\t// element may be out of view.\n\tif (\n\t\t! range ||\n\t\t! range.startContainer ||\n\t\t! container.contains( range.startContainer )\n\t) {\n\t\tcontainer.scrollIntoView( alignToTop );\n\t\trange = callback();\n\n\t\tif (\n\t\t\t! range ||\n\t\t\t! range.startContainer ||\n\t\t\t! container.contains( range.startContainer )\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn range;\n}\n"],
|
|
5
|
+
"mappings": "AAUO,SAAS,gBAAiB,WAAW,YAAY,UAAW;AAClE,MAAI,QAAQ,SAAS;AAIrB,MACC,CAAE,SACF,CAAE,MAAM,kBACR,CAAE,UAAU,SAAU,MAAM,cAAe,GAC1C;AACD,cAAU,eAAgB,UAAW;AACrC,YAAQ,SAAS;AAEjB,QACC,CAAE,SACF,CAAE,MAAM,kBACR,CAAE,UAAU,SAAU,MAAM,cAAe,GAC1C;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import safeHTML from './safe-html';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Removes any HTML tags from the provided string.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} html The string containing html.
|
|
10
|
-
*
|
|
11
|
-
* @return {string} The text content with any html removed.
|
|
12
|
-
*/
|
|
13
|
-
export default function stripHTML(html) {
|
|
14
|
-
// Remove any script tags or on* attributes otherwise their *contents* will be left
|
|
15
|
-
// in place following removal of HTML tags.
|
|
1
|
+
import safeHTML from "./safe-html";
|
|
2
|
+
function stripHTML(html) {
|
|
16
3
|
html = safeHTML(html);
|
|
17
|
-
const doc = document.implementation.createHTMLDocument(
|
|
4
|
+
const doc = document.implementation.createHTMLDocument("");
|
|
18
5
|
doc.body.innerHTML = html;
|
|
19
|
-
return doc.body.textContent ||
|
|
6
|
+
return doc.body.textContent || "";
|
|
20
7
|
}
|
|
21
|
-
|
|
8
|
+
export {
|
|
9
|
+
stripHTML as default
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=strip-html.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/strip-html.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport safeHTML from './safe-html';\n\n/**\n * Removes any HTML tags from the provided string.\n *\n * @param {string} html The string containing html.\n *\n * @return {string} The text content with any html removed.\n */\nexport default function stripHTML( html ) {\n\t// Remove any script tags or on* attributes otherwise their *contents* will be left\n\t// in place following removal of HTML tags.\n\thtml = safeHTML( html );\n\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\tdoc.body.innerHTML = html;\n\treturn doc.body.textContent || '';\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,cAAc;AASN,SAAR,UAA4B,MAAO;AAGzC,SAAO,SAAU,IAAK;AAEtB,QAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;AAC3D,MAAI,KAAK,YAAY;AACrB,SAAO,IAAI,KAAK,eAAe;AAChC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { assertIsDefined } from '../utils/assert-is-defined';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Unwrap the given node. This means any child nodes are moved to the parent.
|
|
8
|
-
*
|
|
9
|
-
* @param {Node} node The node to unwrap.
|
|
10
|
-
*
|
|
11
|
-
* @return {void}
|
|
12
|
-
*/
|
|
13
|
-
export default function unwrap(node) {
|
|
1
|
+
import { assertIsDefined } from "../utils/assert-is-defined";
|
|
2
|
+
function unwrap(node) {
|
|
14
3
|
const parent = node.parentNode;
|
|
15
|
-
assertIsDefined(parent,
|
|
4
|
+
assertIsDefined(parent, "node.parentNode");
|
|
16
5
|
while (node.firstChild) {
|
|
17
6
|
parent.insertBefore(node.firstChild, node);
|
|
18
7
|
}
|
|
19
8
|
parent.removeChild(node);
|
|
20
9
|
}
|
|
21
|
-
|
|
10
|
+
export {
|
|
11
|
+
unwrap as default
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=unwrap.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/unwrap.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Unwrap the given node. This means any child nodes are moved to the parent.\n *\n * @param {Node} node The node to unwrap.\n *\n * @return {void}\n */\nexport default function unwrap( node ) {\n\tconst parent = node.parentNode;\n\n\tassertIsDefined( parent, 'node.parentNode' );\n\n\twhile ( node.firstChild ) {\n\t\tparent.insertBefore( node.firstChild, node );\n\t}\n\n\tparent.removeChild( node );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,uBAAuB;AASjB,SAAR,OAAyB,MAAO;AACtC,QAAM,SAAS,KAAK;AAEpB,kBAAiB,QAAQ,iBAAkB;AAE3C,SAAQ,KAAK,YAAa;AACzB,WAAO,aAAc,KAAK,YAAY,IAAK;AAAA,EAC5C;AAEA,SAAO,YAAa,IAAK;AAC1B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/dom/wrap.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { assertIsDefined } from '../utils/assert-is-defined';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Wraps the given node with a new node with the given tag name.
|
|
8
|
-
*
|
|
9
|
-
* @param {Element} newNode The node to insert.
|
|
10
|
-
* @param {Element} referenceNode The node to wrap.
|
|
11
|
-
*/
|
|
12
|
-
export default function wrap(newNode, referenceNode) {
|
|
13
|
-
assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode');
|
|
1
|
+
import { assertIsDefined } from "../utils/assert-is-defined";
|
|
2
|
+
function wrap(newNode, referenceNode) {
|
|
3
|
+
assertIsDefined(referenceNode.parentNode, "referenceNode.parentNode");
|
|
14
4
|
referenceNode.parentNode.insertBefore(newNode, referenceNode);
|
|
15
5
|
newNode.appendChild(referenceNode);
|
|
16
6
|
}
|
|
17
|
-
|
|
7
|
+
export {
|
|
8
|
+
wrap as default
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=wrap.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/wrap.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Wraps the given node with a new node with the given tag name.\n *\n * @param {Element} newNode The node to insert.\n * @param {Element} referenceNode The node to wrap.\n */\nexport default function wrap( newNode, referenceNode ) {\n\tassertIsDefined( referenceNode.parentNode, 'referenceNode.parentNode' );\n\treferenceNode.parentNode.insertBefore( newNode, referenceNode );\n\tnewNode.appendChild( referenceNode );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,uBAAuB;AAQjB,SAAR,KAAuB,SAAS,eAAgB;AACtD,kBAAiB,cAAc,YAAY,0BAA2B;AACtE,gBAAc,WAAW,aAAc,SAAS,aAAc;AAC9D,UAAQ,YAAa,aAAc;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,100 +1,49 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* References:
|
|
3
|
-
*
|
|
4
|
-
* Focusable:
|
|
5
|
-
* - https://www.w3.org/TR/html5/editing.html#focus-management
|
|
6
|
-
*
|
|
7
|
-
* Sequential focus navigation:
|
|
8
|
-
* - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute
|
|
9
|
-
*
|
|
10
|
-
* Disabled elements:
|
|
11
|
-
* - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements
|
|
12
|
-
*
|
|
13
|
-
* getClientRects algorithm (requiring layout box):
|
|
14
|
-
* - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface
|
|
15
|
-
*
|
|
16
|
-
* AREA elements associated with an IMG:
|
|
17
|
-
* - https://w3c.github.io/html/editing.html#data-model
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Returns a CSS selector used to query for focusable elements.
|
|
22
|
-
*
|
|
23
|
-
* @param {boolean} sequential If set, only query elements that are sequentially
|
|
24
|
-
* focusable. Non-interactive elements with a
|
|
25
|
-
* negative `tabindex` are focusable but not
|
|
26
|
-
* sequentially focusable.
|
|
27
|
-
* https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
|
|
28
|
-
*
|
|
29
|
-
* @return {string} CSS selector.
|
|
30
|
-
*/
|
|
31
1
|
function buildSelector(sequential) {
|
|
32
|
-
return [
|
|
2
|
+
return [
|
|
3
|
+
sequential ? '[tabindex]:not([tabindex^="-"])' : "[tabindex]",
|
|
4
|
+
"a[href]",
|
|
5
|
+
"button:not([disabled])",
|
|
6
|
+
'input:not([type="hidden"]):not([disabled])',
|
|
7
|
+
"select:not([disabled])",
|
|
8
|
+
"textarea:not([disabled])",
|
|
9
|
+
'iframe:not([tabindex^="-"])',
|
|
10
|
+
"object",
|
|
11
|
+
"embed",
|
|
12
|
+
"summary",
|
|
13
|
+
"area[href]",
|
|
14
|
+
"[contenteditable]:not([contenteditable=false])"
|
|
15
|
+
].join(",");
|
|
33
16
|
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Returns true if the specified element is visible (i.e. neither display: none
|
|
37
|
-
* nor visibility: hidden).
|
|
38
|
-
*
|
|
39
|
-
* @param {HTMLElement} element DOM element to test.
|
|
40
|
-
*
|
|
41
|
-
* @return {boolean} Whether element is visible.
|
|
42
|
-
*/
|
|
43
17
|
function isVisible(element) {
|
|
44
18
|
return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
|
|
45
19
|
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Returns true if the specified area element is a valid focusable element, or
|
|
49
|
-
* false otherwise. Area is only focusable if within a map where a named map
|
|
50
|
-
* referenced by an image somewhere in the document.
|
|
51
|
-
*
|
|
52
|
-
* @param {HTMLAreaElement} element DOM area element to test.
|
|
53
|
-
*
|
|
54
|
-
* @return {boolean} Whether area element is valid for focus.
|
|
55
|
-
*/
|
|
56
20
|
function isValidFocusableArea(element) {
|
|
57
|
-
|
|
58
|
-
const map = element.closest('map[name]');
|
|
21
|
+
const map = element.closest("map[name]");
|
|
59
22
|
if (!map) {
|
|
60
23
|
return false;
|
|
61
24
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
25
|
+
const img = element.ownerDocument.querySelector(
|
|
26
|
+
'img[usemap="#' + map.name + '"]'
|
|
27
|
+
);
|
|
65
28
|
return !!img && isVisible(img);
|
|
66
29
|
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Returns all focusable elements within a given context.
|
|
70
|
-
*
|
|
71
|
-
* @param {Element} context Element in which to search.
|
|
72
|
-
* @param {Object} options
|
|
73
|
-
* @param {boolean} [options.sequential] If set, only return elements that are
|
|
74
|
-
* sequentially focusable.
|
|
75
|
-
* Non-interactive elements with a
|
|
76
|
-
* negative `tabindex` are focusable but
|
|
77
|
-
* not sequentially focusable.
|
|
78
|
-
* https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
|
|
79
|
-
*
|
|
80
|
-
* @return {HTMLElement[]} Focusable elements.
|
|
81
|
-
*/
|
|
82
|
-
export function find(context, {
|
|
83
|
-
sequential = false
|
|
84
|
-
} = {}) {
|
|
85
|
-
/** @type {NodeListOf<HTMLElement>} */
|
|
30
|
+
function find(context, { sequential = false } = {}) {
|
|
86
31
|
const elements = context.querySelectorAll(buildSelector(sequential));
|
|
87
|
-
return Array.from(elements).filter(element => {
|
|
32
|
+
return Array.from(elements).filter((element) => {
|
|
88
33
|
if (!isVisible(element)) {
|
|
89
34
|
return false;
|
|
90
35
|
}
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
36
|
+
const { nodeName } = element;
|
|
37
|
+
if ("AREA" === nodeName) {
|
|
38
|
+
return isValidFocusableArea(
|
|
39
|
+
/** @type {HTMLAreaElement} */
|
|
40
|
+
element
|
|
41
|
+
);
|
|
96
42
|
}
|
|
97
43
|
return true;
|
|
98
44
|
});
|
|
99
45
|
}
|
|
100
|
-
|
|
46
|
+
export {
|
|
47
|
+
find
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=focusable.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/focusable.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * References:\n *\n * Focusable:\n * - https://www.w3.org/TR/html5/editing.html#focus-management\n *\n * Sequential focus navigation:\n * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute\n *\n * Disabled elements:\n * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements\n *\n * getClientRects algorithm (requiring layout box):\n * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface\n *\n * AREA elements associated with an IMG:\n * - https://w3c.github.io/html/editing.html#data-model\n */\n\n/**\n * Returns a CSS selector used to query for focusable elements.\n *\n * @param {boolean} sequential If set, only query elements that are sequentially\n * focusable. Non-interactive elements with a\n * negative `tabindex` are focusable but not\n * sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {string} CSS selector.\n */\nfunction buildSelector( sequential ) {\n\treturn [\n\t\tsequential ? '[tabindex]:not([tabindex^=\"-\"])' : '[tabindex]',\n\t\t'a[href]',\n\t\t'button:not([disabled])',\n\t\t'input:not([type=\"hidden\"]):not([disabled])',\n\t\t'select:not([disabled])',\n\t\t'textarea:not([disabled])',\n\t\t'iframe:not([tabindex^=\"-\"])',\n\t\t'object',\n\t\t'embed',\n\t\t'summary',\n\t\t'area[href]',\n\t\t'[contenteditable]:not([contenteditable=false])',\n\t].join( ',' );\n}\n\n/**\n * Returns true if the specified element is visible (i.e. neither display: none\n * nor visibility: hidden).\n *\n * @param {HTMLElement} element DOM element to test.\n *\n * @return {boolean} Whether element is visible.\n */\nfunction isVisible( element ) {\n\treturn (\n\t\telement.offsetWidth > 0 ||\n\t\telement.offsetHeight > 0 ||\n\t\telement.getClientRects().length > 0\n\t);\n}\n\n/**\n * Returns true if the specified area element is a valid focusable element, or\n * false otherwise. Area is only focusable if within a map where a named map\n * referenced by an image somewhere in the document.\n *\n * @param {HTMLAreaElement} element DOM area element to test.\n *\n * @return {boolean} Whether area element is valid for focus.\n */\nfunction isValidFocusableArea( element ) {\n\t/** @type {HTMLMapElement | null} */\n\tconst map = element.closest( 'map[name]' );\n\tif ( ! map ) {\n\t\treturn false;\n\t}\n\n\t/** @type {HTMLImageElement | null} */\n\tconst img = element.ownerDocument.querySelector(\n\t\t'img[usemap=\"#' + map.name + '\"]'\n\t);\n\treturn !! img && isVisible( img );\n}\n\n/**\n * Returns all focusable elements within a given context.\n *\n * @param {Element} context Element in which to search.\n * @param {Object} options\n * @param {boolean} [options.sequential] If set, only return elements that are\n * sequentially focusable.\n * Non-interactive elements with a\n * negative `tabindex` are focusable but\n * not sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {HTMLElement[]} Focusable elements.\n */\nexport function find( context, { sequential = false } = {} ) {\n\t/** @type {NodeListOf<HTMLElement>} */\n\tconst elements = context.querySelectorAll( buildSelector( sequential ) );\n\n\treturn Array.from( elements ).filter( ( element ) => {\n\t\tif ( ! isVisible( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { nodeName } = element;\n\t\tif ( 'AREA' === nodeName ) {\n\t\t\treturn isValidFocusableArea(\n\t\t\t\t/** @type {HTMLAreaElement} */ ( element )\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n"],
|
|
5
|
+
"mappings": "AA8BA,SAAS,cAAe,YAAa;AACpC,SAAO;AAAA,IACN,aAAa,oCAAoC;AAAA,IACjD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EAAE,KAAM,GAAI;AACb;AAUA,SAAS,UAAW,SAAU;AAC7B,SACC,QAAQ,cAAc,KACtB,QAAQ,eAAe,KACvB,QAAQ,eAAe,EAAE,SAAS;AAEpC;AAWA,SAAS,qBAAsB,SAAU;AAExC,QAAM,MAAM,QAAQ,QAAS,WAAY;AACzC,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,QAAM,MAAM,QAAQ,cAAc;AAAA,IACjC,kBAAkB,IAAI,OAAO;AAAA,EAC9B;AACA,SAAO,CAAC,CAAE,OAAO,UAAW,GAAI;AACjC;AAgBO,SAAS,KAAM,SAAS,EAAE,aAAa,MAAM,IAAI,CAAC,GAAI;AAE5D,QAAM,WAAW,QAAQ,iBAAkB,cAAe,UAAW,CAAE;AAEvE,SAAO,MAAM,KAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACpD,QAAK,CAAE,UAAW,OAAQ,GAAI;AAC7B,aAAO;AAAA,IACR;AAEA,UAAM,EAAE,SAAS,IAAI;AACrB,QAAK,WAAW,UAAW;AAC1B,aAAO;AAAA;AAAA,QAC2B;AAAA,MAClC;AAAA,IACD;AAEA,WAAO;AAAA,EACR,CAAE;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* under the keys with the same name.
|
|
10
|
-
*/
|
|
11
|
-
export const focus = {
|
|
12
|
-
focusable,
|
|
13
|
-
tabbable
|
|
1
|
+
import * as focusable from "./focusable";
|
|
2
|
+
import * as tabbable from "./tabbable";
|
|
3
|
+
const focus = { focusable, tabbable };
|
|
4
|
+
export * from "./dom";
|
|
5
|
+
export * from "./phrasing-content";
|
|
6
|
+
export * from "./data-transfer";
|
|
7
|
+
export {
|
|
8
|
+
focus
|
|
14
9
|
};
|
|
15
|
-
|
|
16
|
-
export * from './phrasing-content';
|
|
17
|
-
export * from './data-transfer';
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport * as focusable from './focusable';\nimport * as tabbable from './tabbable';\n\n/**\n * Object grouping `focusable` and `tabbable` utils\n * under the keys with the same name.\n */\nexport const focus = { focusable, tabbable };\n\nexport * from './dom';\nexport * from './phrasing-content';\nexport * from './data-transfer';\n"],
|
|
5
|
+
"mappings": "AAGA,YAAY,eAAe;AAC3B,YAAY,cAAc;AAMnB,MAAM,QAAQ,EAAE,WAAW,SAAS;AAE3C,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,57 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All phrasing content elements.
|
|
3
|
-
*
|
|
4
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Record<string,SemanticElementDefinition>} ContentSchema
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef SemanticElementDefinition
|
|
13
|
-
* @property {string[]} [attributes] Content attributes
|
|
14
|
-
* @property {ContentSchema} [children] Content attributes
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* All text-level semantic elements.
|
|
19
|
-
*
|
|
20
|
-
* @see https://html.spec.whatwg.org/multipage/text-level-semantics.html
|
|
21
|
-
*
|
|
22
|
-
* @type {ContentSchema}
|
|
23
|
-
*/
|
|
24
1
|
const textContentSchema = {
|
|
25
2
|
strong: {},
|
|
26
3
|
em: {},
|
|
27
4
|
s: {},
|
|
28
5
|
del: {},
|
|
29
6
|
ins: {},
|
|
30
|
-
a: {
|
|
31
|
-
attributes: ['href', 'target', 'rel', 'id']
|
|
32
|
-
},
|
|
7
|
+
a: { attributes: ["href", "target", "rel", "id"] },
|
|
33
8
|
code: {},
|
|
34
|
-
abbr: {
|
|
35
|
-
attributes: ['title']
|
|
36
|
-
},
|
|
9
|
+
abbr: { attributes: ["title"] },
|
|
37
10
|
sub: {},
|
|
38
11
|
sup: {},
|
|
39
12
|
br: {},
|
|
40
13
|
small: {},
|
|
41
14
|
// To do: fix blockquote.
|
|
42
15
|
// cite: {},
|
|
43
|
-
q: {
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
attributes: ['title']
|
|
48
|
-
},
|
|
49
|
-
data: {
|
|
50
|
-
attributes: ['value']
|
|
51
|
-
},
|
|
52
|
-
time: {
|
|
53
|
-
attributes: ['datetime']
|
|
54
|
-
},
|
|
16
|
+
q: { attributes: ["cite"] },
|
|
17
|
+
dfn: { attributes: ["title"] },
|
|
18
|
+
data: { attributes: ["value"] },
|
|
19
|
+
time: { attributes: ["datetime"] },
|
|
55
20
|
var: {},
|
|
56
21
|
samp: {},
|
|
57
22
|
kbd: {},
|
|
@@ -62,84 +27,75 @@ const textContentSchema = {
|
|
|
62
27
|
ruby: {},
|
|
63
28
|
rt: {},
|
|
64
29
|
rp: {},
|
|
65
|
-
bdi: {
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
bdo: {
|
|
69
|
-
attributes: ['dir']
|
|
70
|
-
},
|
|
30
|
+
bdi: { attributes: ["dir"] },
|
|
31
|
+
bdo: { attributes: ["dir"] },
|
|
71
32
|
wbr: {},
|
|
72
|
-
|
|
33
|
+
"#text": {}
|
|
73
34
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// Impossible: strong > strong.
|
|
78
|
-
const excludedElements = ['#text', 'br'];
|
|
79
|
-
Object.keys(textContentSchema).filter(element => !excludedElements.includes(element)).forEach(tag => {
|
|
80
|
-
const {
|
|
81
|
-
[tag]: removedTag,
|
|
82
|
-
...restSchema
|
|
83
|
-
} = textContentSchema;
|
|
35
|
+
const excludedElements = ["#text", "br"];
|
|
36
|
+
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
|
|
37
|
+
const { [tag]: removedTag, ...restSchema } = textContentSchema;
|
|
84
38
|
textContentSchema[tag].children = restSchema;
|
|
85
39
|
});
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Embedded content elements.
|
|
89
|
-
*
|
|
90
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0
|
|
91
|
-
*
|
|
92
|
-
* @type {ContentSchema}
|
|
93
|
-
*/
|
|
94
40
|
const embeddedContentSchema = {
|
|
95
41
|
audio: {
|
|
96
|
-
attributes: [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
42
|
+
attributes: [
|
|
43
|
+
"src",
|
|
44
|
+
"preload",
|
|
45
|
+
"autoplay",
|
|
46
|
+
"mediagroup",
|
|
47
|
+
"loop",
|
|
48
|
+
"muted"
|
|
49
|
+
]
|
|
103
50
|
},
|
|
51
|
+
canvas: { attributes: ["width", "height"] },
|
|
52
|
+
embed: { attributes: ["src", "type", "width", "height"] },
|
|
104
53
|
img: {
|
|
105
|
-
attributes: [
|
|
54
|
+
attributes: [
|
|
55
|
+
"alt",
|
|
56
|
+
"src",
|
|
57
|
+
"srcset",
|
|
58
|
+
"usemap",
|
|
59
|
+
"ismap",
|
|
60
|
+
"width",
|
|
61
|
+
"height"
|
|
62
|
+
]
|
|
106
63
|
},
|
|
107
64
|
object: {
|
|
108
|
-
attributes: [
|
|
65
|
+
attributes: [
|
|
66
|
+
"data",
|
|
67
|
+
"type",
|
|
68
|
+
"name",
|
|
69
|
+
"usemap",
|
|
70
|
+
"form",
|
|
71
|
+
"width",
|
|
72
|
+
"height"
|
|
73
|
+
]
|
|
109
74
|
},
|
|
110
75
|
video: {
|
|
111
|
-
attributes: [
|
|
76
|
+
attributes: [
|
|
77
|
+
"src",
|
|
78
|
+
"poster",
|
|
79
|
+
"preload",
|
|
80
|
+
"playsinline",
|
|
81
|
+
"autoplay",
|
|
82
|
+
"mediagroup",
|
|
83
|
+
"loop",
|
|
84
|
+
"muted",
|
|
85
|
+
"controls",
|
|
86
|
+
"width",
|
|
87
|
+
"height"
|
|
88
|
+
]
|
|
112
89
|
}
|
|
113
90
|
};
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Phrasing content elements.
|
|
117
|
-
*
|
|
118
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
|
|
119
|
-
*/
|
|
120
91
|
const phrasingContentSchema = {
|
|
121
92
|
...textContentSchema,
|
|
122
93
|
...embeddedContentSchema
|
|
123
94
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* Get schema of possible paths for phrasing content.
|
|
127
|
-
*
|
|
128
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
|
|
129
|
-
*
|
|
130
|
-
* @param {string} [context] Set to "paste" to exclude invisible elements and
|
|
131
|
-
* sensitive data.
|
|
132
|
-
*
|
|
133
|
-
* @return {Partial<ContentSchema>} Schema.
|
|
134
|
-
*/
|
|
135
|
-
export function getPhrasingContentSchema(context) {
|
|
136
|
-
if (context !== 'paste') {
|
|
95
|
+
function getPhrasingContentSchema(context) {
|
|
96
|
+
if (context !== "paste") {
|
|
137
97
|
return phrasingContentSchema;
|
|
138
98
|
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @type {Partial<ContentSchema>}
|
|
142
|
-
*/
|
|
143
99
|
const {
|
|
144
100
|
u,
|
|
145
101
|
// Used to mark misspelling. Shouldn't be pasted.
|
|
@@ -160,36 +116,22 @@ export function getPhrasingContentSchema(context) {
|
|
|
160
116
|
...phrasingContentSchema,
|
|
161
117
|
// We shouldn't paste potentially sensitive information which is not
|
|
162
118
|
// visible to the user when pasted, so strip the attributes.
|
|
163
|
-
ins: {
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
del: {
|
|
167
|
-
children: phrasingContentSchema.del.children
|
|
168
|
-
}
|
|
119
|
+
ins: { children: phrasingContentSchema.ins.children },
|
|
120
|
+
del: { children: phrasingContentSchema.del.children }
|
|
169
121
|
};
|
|
170
122
|
return remainingContentSchema;
|
|
171
123
|
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Find out whether or not the given node is phrasing content.
|
|
175
|
-
*
|
|
176
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
|
|
177
|
-
*
|
|
178
|
-
* @param {Node} node The node to test.
|
|
179
|
-
*
|
|
180
|
-
* @return {boolean} True if phrasing content, false if not.
|
|
181
|
-
*/
|
|
182
|
-
export function isPhrasingContent(node) {
|
|
124
|
+
function isPhrasingContent(node) {
|
|
183
125
|
const tag = node.nodeName.toLowerCase();
|
|
184
|
-
return getPhrasingContentSchema().hasOwnProperty(tag) || tag ===
|
|
126
|
+
return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
|
|
185
127
|
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @param {Node} node
|
|
189
|
-
* @return {boolean} Node is text content
|
|
190
|
-
*/
|
|
191
|
-
export function isTextContent(node) {
|
|
128
|
+
function isTextContent(node) {
|
|
192
129
|
const tag = node.nodeName.toLowerCase();
|
|
193
|
-
return textContentSchema.hasOwnProperty(tag) || tag ===
|
|
130
|
+
return textContentSchema.hasOwnProperty(tag) || tag === "span";
|
|
194
131
|
}
|
|
195
|
-
|
|
132
|
+
export {
|
|
133
|
+
getPhrasingContentSchema,
|
|
134
|
+
isPhrasingContent,
|
|
135
|
+
isTextContent
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=phrasing-content.js.map
|