@wordpress/dom 5.0.0 → 5.1.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/README.md +1 -1
- package/build/data-transfer.cjs +20 -38
- package/build/data-transfer.cjs.map +1 -7
- package/build/dom/caret-range-from-point.cjs +31 -38
- package/build/dom/caret-range-from-point.cjs.map +1 -7
- package/build/dom/clean-node-list.cjs +87 -132
- package/build/dom/clean-node-list.cjs.map +1 -7
- package/build/dom/compute-caret-rect.cjs +35 -35
- package/build/dom/compute-caret-rect.cjs.map +1 -7
- package/build/dom/document-has-selection.cjs +35 -30
- package/build/dom/document-has-selection.cjs.map +1 -7
- package/build/dom/document-has-text-selection.cjs +24 -30
- package/build/dom/document-has-text-selection.cjs.map +1 -7
- package/build/dom/document-has-uncollapsed-selection.cjs +34 -29
- package/build/dom/document-has-uncollapsed-selection.cjs.map +1 -7
- package/build/dom/get-computed-style.cjs +14 -30
- package/build/dom/get-computed-style.cjs.map +1 -7
- package/build/dom/get-offset-parent.cjs +40 -39
- package/build/dom/get-offset-parent.cjs.map +1 -7
- package/build/dom/get-range-height.cjs +18 -31
- package/build/dom/get-range-height.cjs.map +1 -7
- package/build/dom/get-rectangle-from-range.cjs +82 -128
- package/build/dom/get-rectangle-from-range.cjs.map +1 -7
- package/build/dom/get-scroll-container.cjs +46 -50
- package/build/dom/get-scroll-container.cjs.map +1 -7
- package/build/dom/hidden-caret-range-from-point.cjs +48 -42
- package/build/dom/hidden-caret-range-from-point.cjs.map +1 -7
- package/build/dom/index.cjs +233 -110
- package/build/dom/input-field-has-uncollapsed-selection.cjs +48 -43
- package/build/dom/input-field-has-uncollapsed-selection.cjs.map +1 -7
- package/build/dom/insert-after.cjs +17 -27
- package/build/dom/insert-after.cjs.map +1 -7
- package/build/dom/is-edge.cjs +82 -97
- package/build/dom/is-edge.cjs.map +1 -7
- package/build/dom/is-element.cjs +12 -25
- package/build/dom/is-element.cjs.map +1 -7
- package/build/dom/is-empty.cjs +23 -37
- package/build/dom/is-empty.cjs.map +1 -7
- package/build/dom/is-entirely-selected.cjs +70 -67
- package/build/dom/is-entirely-selected.cjs.map +1 -7
- package/build/dom/is-form-element.cjs +33 -33
- package/build/dom/is-form-element.cjs.map +1 -7
- package/build/dom/is-horizontal-edge.cjs +31 -28
- package/build/dom/is-horizontal-edge.cjs.map +1 -7
- package/build/dom/is-html-input-element.cjs +12 -25
- package/build/dom/is-html-input-element.cjs.map +1 -7
- package/build/dom/is-input-or-text-area.cjs +12 -25
- package/build/dom/is-input-or-text-area.cjs.map +1 -7
- package/build/dom/is-number-input.cjs +36 -33
- package/build/dom/is-number-input.cjs.map +1 -7
- package/build/dom/is-rtl.cjs +30 -28
- package/build/dom/is-rtl.cjs.map +1 -7
- package/build/dom/is-selection-forward.cjs +26 -39
- package/build/dom/is-selection-forward.cjs.map +1 -7
- package/build/dom/is-text-field.cjs +45 -42
- package/build/dom/is-text-field.cjs.map +1 -7
- package/build/dom/is-vertical-edge.cjs +31 -28
- package/build/dom/is-vertical-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-edge.cjs +75 -78
- package/build/dom/place-caret-at-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-horizontal-edge.cjs +29 -28
- package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-vertical-edge.cjs +30 -28
- package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
- package/build/dom/remove-invalid-html.cjs +35 -31
- package/build/dom/remove-invalid-html.cjs.map +1 -7
- package/build/dom/remove.cjs +15 -27
- package/build/dom/remove.cjs.map +1 -7
- package/build/dom/replace-tag.cjs +21 -32
- package/build/dom/replace-tag.cjs.map +1 -7
- package/build/dom/replace.cjs +34 -32
- package/build/dom/replace.cjs.map +1 -7
- package/build/dom/safe-html.cjs +45 -46
- package/build/dom/safe-html.cjs.map +1 -7
- package/build/dom/scroll-if-no-range.cjs +24 -37
- package/build/dom/scroll-if-no-range.cjs.map +1 -7
- package/build/dom/strip-html.cjs +33 -31
- package/build/dom/strip-html.cjs.map +1 -7
- package/build/dom/types.cjs +4 -18
- package/build/dom/unwrap.cjs +17 -31
- package/build/dom/unwrap.cjs.map +1 -7
- package/build/dom/wrap.cjs +17 -28
- package/build/dom/wrap.cjs.map +1 -7
- package/build/focusable.cjs +99 -76
- package/build/focusable.cjs.map +1 -7
- package/build/index.cjs +57 -38
- package/build/index.cjs.map +1 -7
- package/build/phrasing-content.cjs +163 -159
- package/build/phrasing-content.cjs.map +1 -7
- package/build/tabbable.cjs +123 -78
- package/build/tabbable.cjs.map +1 -7
- package/build/types.cjs +4 -18
- package/build/utils/assert-is-defined.cjs +8 -33
- package/build/utils/assert-is-defined.cjs.map +1 -7
- package/build-module/data-transfer.mjs +16 -14
- package/build-module/data-transfer.mjs.map +1 -7
- package/build-module/dom/caret-range-from-point.mjs +27 -18
- package/build-module/dom/caret-range-from-point.mjs.map +1 -7
- package/build-module/dom/clean-node-list.mjs +60 -105
- package/build-module/dom/clean-node-list.mjs.map +1 -7
- package/build-module/dom/compute-caret-rect.mjs +16 -12
- package/build-module/dom/compute-caret-rect.mjs.map +1 -7
- package/build-module/dom/document-has-selection.mjs +13 -6
- package/build-module/dom/document-has-selection.mjs.map +1 -7
- package/build-module/dom/document-has-text-selection.mjs +20 -10
- package/build-module/dom/document-has-text-selection.mjs.map +1 -7
- package/build-module/dom/document-has-uncollapsed-selection.mjs +14 -6
- package/build-module/dom/document-has-uncollapsed-selection.mjs.map +1 -7
- package/build-module/dom/get-computed-style.mjs +10 -10
- package/build-module/dom/get-computed-style.mjs.map +1 -7
- package/build-module/dom/get-offset-parent.mjs +20 -16
- package/build-module/dom/get-offset-parent.mjs.map +1 -7
- package/build-module/dom/get-range-height.mjs +14 -11
- package/build-module/dom/get-range-height.mjs.map +1 -7
- package/build-module/dom/get-rectangle-from-range.mjs +78 -108
- package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
- package/build-module/dom/get-scroll-container.mjs +28 -28
- package/build-module/dom/get-scroll-container.mjs.map +1 -7
- package/build-module/dom/hidden-caret-range-from-point.mjs +28 -19
- package/build-module/dom/hidden-caret-range-from-point.mjs.map +1 -7
- package/build-module/dom/index.mjs +28 -58
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs +28 -20
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +1 -7
- package/build-module/dom/insert-after.mjs +13 -7
- package/build-module/dom/insert-after.mjs.map +1 -7
- package/build-module/dom/is-edge.mjs +53 -69
- package/build-module/dom/is-edge.mjs.map +1 -7
- package/build-module/dom/is-element.mjs +8 -5
- package/build-module/dom/is-element.mjs.map +1 -7
- package/build-module/dom/is-empty.mjs +19 -17
- package/build-module/dom/is-empty.mjs.map +1 -7
- package/build-module/dom/is-entirely-selected.mjs +51 -44
- package/build-module/dom/is-entirely-selected.mjs.map +1 -7
- package/build-module/dom/is-form-element.mjs +15 -11
- package/build-module/dom/is-form-element.mjs.map +1 -7
- package/build-module/dom/is-horizontal-edge.mjs +13 -6
- package/build-module/dom/is-horizontal-edge.mjs.map +1 -7
- package/build-module/dom/is-html-input-element.mjs +8 -5
- package/build-module/dom/is-html-input-element.mjs.map +1 -7
- package/build-module/dom/is-input-or-text-area.mjs +8 -5
- package/build-module/dom/is-input-or-text-area.mjs.map +1 -7
- package/build-module/dom/is-number-input.mjs +16 -10
- package/build-module/dom/is-number-input.mjs.map +1 -7
- package/build-module/dom/is-rtl.mjs +12 -6
- package/build-module/dom/is-rtl.mjs.map +1 -7
- package/build-module/dom/is-selection-forward.mjs +22 -19
- package/build-module/dom/is-selection-forward.mjs.map +1 -7
- package/build-module/dom/is-text-field.mjs +27 -20
- package/build-module/dom/is-text-field.mjs.map +1 -7
- package/build-module/dom/is-vertical-edge.mjs +13 -6
- package/build-module/dom/is-vertical-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-edge.mjs +51 -52
- package/build-module/dom/place-caret-at-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-horizontal-edge.mjs +11 -6
- package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-vertical-edge.mjs +12 -6
- package/build-module/dom/place-caret-at-vertical-edge.mjs.map +1 -7
- package/build-module/dom/remove-invalid-html.mjs +17 -9
- package/build-module/dom/remove-invalid-html.mjs.map +1 -7
- package/build-module/dom/remove.mjs +11 -7
- package/build-module/dom/remove.mjs.map +1 -7
- package/build-module/dom/replace-tag.mjs +17 -12
- package/build-module/dom/replace-tag.mjs.map +1 -7
- package/build-module/dom/replace.mjs +13 -8
- package/build-module/dom/replace.mjs.map +1 -7
- package/build-module/dom/safe-html.mjs +27 -24
- package/build-module/dom/safe-html.mjs.map +1 -7
- package/build-module/dom/scroll-if-no-range.mjs +20 -13
- package/build-module/dom/scroll-if-no-range.mjs.map +1 -7
- package/build-module/dom/strip-html.mjs +15 -9
- package/build-module/dom/strip-html.mjs.map +1 -7
- package/build-module/dom/types.mjs +0 -1
- package/build-module/dom/unwrap.mjs +13 -11
- package/build-module/dom/unwrap.mjs.map +1 -7
- package/build-module/dom/wrap.mjs +13 -8
- package/build-module/dom/wrap.mjs.map +1 -7
- package/build-module/focusable.mjs +95 -52
- package/build-module/focusable.mjs.map +1 -7
- package/build-module/index.mjs +11 -5
- package/build-module/index.mjs.map +1 -7
- package/build-module/phrasing-content.mjs +157 -133
- package/build-module/phrasing-content.mjs.map +1 -7
- package/build-module/tabbable.mjs +116 -51
- package/build-module/tabbable.mjs.map +1 -7
- package/build-module/types.mjs +0 -1
- package/build-module/utils/assert-is-defined.mjs +4 -9
- package/build-module/utils/assert-is-defined.mjs.map +1 -7
- package/build-types/dom/clean-node-list.d.ts +2 -2
- package/build-types/dom/clean-node-list.d.ts.map +1 -1
- package/build-types/dom/is-edge.d.ts.map +1 -1
- package/build-types/dom/remove-invalid-html.d.ts +4 -4
- package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/dom/clean-node-list.ts +2 -2
- package/src/dom/is-edge.ts +35 -43
- package/src/dom/remove-invalid-html.ts +4 -4
- package/src/dom/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
- package/src/test/{dom.jsdom.test.js → dom.jsdom.test.ts} +9 -6
- package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
- package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
- package/build/dom/index.cjs.map +0 -7
- package/build/dom/types.cjs.map +0 -7
- package/build/types.cjs.map +0 -7
- package/build-module/dom/index.mjs.map +0 -7
- package/build-module/dom/types.mjs.map +0 -7
- package/build-module/types.mjs.map +0 -7
- /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
- /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
- /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
- /package/src/test/{utils.js → utils.ts} +0 -0
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/is-number-input.ts"],
|
|
4
|
-
"sourcesContent": ["import deprecated from '@wordpress/deprecated';\nimport isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given element is an input field of type number.\n *\n * @param node The HTML node.\n *\n * @return True if the node is number input.\n */\nexport default function isNumberInput( node: Node ): node is HTMLInputElement {\n\tdeprecated( 'wp.dom.isNumberInput', {\n\t\tsince: '6.1',\n\t\tversion: '6.5',\n\t} );\n\treturn (\n\t\tisHTMLInputElement( node ) &&\n\t\tnode.type === 'number' &&\n\t\t! isNaN( node.valueAsNumber )\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAShB,SAAR,cAAgC,MAAuC;AAC7E,aAAY,wBAAwB;AAAA,IACnC,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACF,SACC,mBAAoB,IAAK,KACzB,KAAK,SAAS,YACd,CAAE,MAAO,KAAK,aAAc;AAE9B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"is-number-input.mjs","names":[],"sources":["../../src/dom/is-number-input.ts"],"sourcesContent":["import deprecated from '@wordpress/deprecated';\nimport isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given element is an input field of type number.\n *\n * @param node The HTML node.\n *\n * @return True if the node is number input.\n */\nexport default function isNumberInput( node: Node ): node is HTMLInputElement {\n\tdeprecated( 'wp.dom.isNumberInput', {\n\t\tsince: '6.1',\n\t\tversion: '6.5',\n\t} );\n\treturn (\n\t\tisHTMLInputElement( node ) &&\n\t\tnode.type === 'number' &&\n\t\t! isNaN( node.valueAsNumber )\n\t);\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAwB,cAAe,MAAuC;CAC7E,WAAY,wBAAwB;EACnC,OAAO;EACP,SAAS;CACV,CAAE;CACF,OACC,mBAAoB,IAAK,KACzB,KAAK,SAAS,YACd,CAAE,MAAO,KAAK,aAAc;AAE9B"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
// packages/dom/src/dom/is-rtl.ts
|
|
2
1
|
import getComputedStyle from "./get-computed-style.mjs";
|
|
2
|
+
// packages/dom/src/dom/is-rtl.ts
|
|
3
|
+
/**
|
|
4
|
+
* Whether the element's text direction is right-to-left.
|
|
5
|
+
*
|
|
6
|
+
* @param element The element to check.
|
|
7
|
+
*
|
|
8
|
+
* @return True if rtl, false if ltr.
|
|
9
|
+
*/
|
|
3
10
|
function isRTL(element) {
|
|
4
|
-
|
|
11
|
+
return getComputedStyle(element).direction === "rtl";
|
|
5
12
|
}
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=is-rtl.mjs.map
|
|
13
|
+
export { isRTL as default };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=is-rtl.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/is-rtl.ts"],
|
|
4
|
-
"sourcesContent": ["import getComputedStyle from './get-computed-style';\n\n/**\n * Whether the element's text direction is right-to-left.\n *\n * @param element The element to check.\n *\n * @return True if rtl, false if ltr.\n */\nexport default function isRTL( element: Element ): boolean {\n\treturn getComputedStyle( element ).direction === 'rtl';\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,sBAAsB;AASd,SAAR,MAAwB,SAA4B;AAC1D,SAAO,iBAAkB,OAAQ,EAAE,cAAc;AAClD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"is-rtl.mjs","names":[],"sources":["../../src/dom/is-rtl.ts"],"sourcesContent":["import getComputedStyle from './get-computed-style';\n\n/**\n * Whether the element's text direction is right-to-left.\n *\n * @param element The element to check.\n *\n * @return True if rtl, false if ltr.\n */\nexport default function isRTL( element: Element ): boolean {\n\treturn getComputedStyle( element ).direction === 'rtl';\n}\n"],"mappings":";;;;;;;;;AASA,SAAwB,MAAO,SAA4B;CAC1D,OAAO,iBAAkB,OAAQ,CAAC,CAAC,cAAc;AAClD"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
// packages/dom/src/dom/is-selection-forward.ts
|
|
2
1
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
2
|
+
// packages/dom/src/dom/is-selection-forward.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if the given selection object is in the forward direction, or
|
|
5
|
+
* false otherwise.
|
|
6
|
+
*
|
|
7
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
8
|
+
*
|
|
9
|
+
* @param selection Selection object to check.
|
|
10
|
+
*
|
|
11
|
+
* @return Whether the selection is forward.
|
|
12
|
+
*/
|
|
3
13
|
function isSelectionForward(selection) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
if (position === 0) {
|
|
15
|
-
return anchorOffset <= focusOffset;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
14
|
+
const { anchorNode, focusNode, anchorOffset, focusOffset } = selection;
|
|
15
|
+
assertIsDefined(anchorNode, "anchorNode");
|
|
16
|
+
assertIsDefined(focusNode, "focusNode");
|
|
17
|
+
const position = anchorNode.compareDocumentPosition(focusNode);
|
|
18
|
+
if (position & anchorNode.DOCUMENT_POSITION_PRECEDING) return false;
|
|
19
|
+
if (position & anchorNode.DOCUMENT_POSITION_FOLLOWING) return true;
|
|
20
|
+
if (position === 0) return anchorOffset <= focusOffset;
|
|
21
|
+
return true;
|
|
18
22
|
}
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=is-selection-forward.mjs.map
|
|
23
|
+
export { isSelectionForward as default };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=is-selection-forward.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/is-selection-forward.ts"],
|
|
4
|
-
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Returns true if the given selection object is in the forward direction, or\n * false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n *\n * @param selection Selection object to check.\n *\n * @return Whether the selection is forward.\n */\nexport default function isSelectionForward( selection: Selection ): boolean {\n\tconst { anchorNode, focusNode, anchorOffset, focusOffset } = selection;\n\n\tassertIsDefined( anchorNode, 'anchorNode' );\n\tassertIsDefined( focusNode, 'focusNode' );\n\tconst position = anchorNode.compareDocumentPosition( focusNode );\n\n\t// Disable reason: `Node#compareDocumentPosition` returns a bitmask value,\n\t// so bitwise operators are intended.\n\t/* eslint-disable no-bitwise */\n\t// Compare whether anchor node precedes focus node. If focus node (where\n\t// end of selection occurs) is after the anchor node, it is forward.\n\tif ( position & anchorNode.DOCUMENT_POSITION_PRECEDING ) {\n\t\treturn false;\n\t}\n\n\tif ( position & anchorNode.DOCUMENT_POSITION_FOLLOWING ) {\n\t\treturn true;\n\t}\n\t/* eslint-enable no-bitwise */\n\n\t// `compareDocumentPosition` returns 0 when passed the same node, in which\n\t// case compare offsets.\n\tif ( position === 0 ) {\n\t\treturn anchorOffset <= focusOffset;\n\t}\n\n\t// This should never be reached, but return true as default case.\n\treturn true;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;AAYjB,SAAR,mBAAqC,WAAgC;AAC3E,QAAM,EAAE,YAAY,WAAW,cAAc,YAAY,IAAI;AAE7D,kBAAiB,YAAY,YAAa;AAC1C,kBAAiB,WAAW,WAAY;AACxC,QAAM,WAAW,WAAW,wBAAyB,SAAU;AAO/D,MAAK,WAAW,WAAW,6BAA8B;AACxD,WAAO;AAAA,EACR;AAEA,MAAK,WAAW,WAAW,6BAA8B;AACxD,WAAO;AAAA,EACR;AAKA,MAAK,aAAa,GAAI;AACrB,WAAO,gBAAgB;AAAA,EACxB;AAGA,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"is-selection-forward.mjs","names":[],"sources":["../../src/dom/is-selection-forward.ts"],"sourcesContent":["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Returns true if the given selection object is in the forward direction, or\n * false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n *\n * @param selection Selection object to check.\n *\n * @return Whether the selection is forward.\n */\nexport default function isSelectionForward( selection: Selection ): boolean {\n\tconst { anchorNode, focusNode, anchorOffset, focusOffset } = selection;\n\n\tassertIsDefined( anchorNode, 'anchorNode' );\n\tassertIsDefined( focusNode, 'focusNode' );\n\tconst position = anchorNode.compareDocumentPosition( focusNode );\n\n\t// Disable reason: `Node#compareDocumentPosition` returns a bitmask value,\n\t// so bitwise operators are intended.\n\t/* eslint-disable no-bitwise */\n\t// Compare whether anchor node precedes focus node. If focus node (where\n\t// end of selection occurs) is after the anchor node, it is forward.\n\tif ( position & anchorNode.DOCUMENT_POSITION_PRECEDING ) {\n\t\treturn false;\n\t}\n\n\tif ( position & anchorNode.DOCUMENT_POSITION_FOLLOWING ) {\n\t\treturn true;\n\t}\n\t/* eslint-enable no-bitwise */\n\n\t// `compareDocumentPosition` returns 0 when passed the same node, in which\n\t// case compare offsets.\n\tif ( position === 0 ) {\n\t\treturn anchorOffset <= focusOffset;\n\t}\n\n\t// This should never be reached, but return true as default case.\n\treturn true;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAwB,mBAAoB,WAAgC;CAC3E,MAAM,EAAE,YAAY,WAAW,cAAc,gBAAgB;CAE7D,gBAAiB,YAAY,YAAa;CAC1C,gBAAiB,WAAW,WAAY;CACxC,MAAM,WAAW,WAAW,wBAAyB,SAAU;CAO/D,IAAK,WAAW,WAAW,6BAC1B,OAAO;CAGR,IAAK,WAAW,WAAW,6BAC1B,OAAO;CAMR,IAAK,aAAa,GACjB,OAAO,gBAAgB;CAIxB,OAAO;AACR"}
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
// packages/dom/src/dom/is-text-field.ts
|
|
2
1
|
import isHTMLInputElement from "./is-html-input-element.mjs";
|
|
2
|
+
// packages/dom/src/dom/is-text-field.ts
|
|
3
|
+
/**
|
|
4
|
+
* Check whether the given element is a text field, where text field is defined
|
|
5
|
+
* by the ability to select within the input, or that it is contenteditable.
|
|
6
|
+
*
|
|
7
|
+
* See: https://html.spec.whatwg.org/#textFieldSelection
|
|
8
|
+
*
|
|
9
|
+
* @param node The HTML element.
|
|
10
|
+
* @return True if the element is an text field, false if not.
|
|
11
|
+
*/
|
|
3
12
|
function isTextField(node) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === "TEXTAREA" || node.contentEditable === "true";
|
|
13
|
+
return isHTMLInputElement(node) && node.type && ![
|
|
14
|
+
"button",
|
|
15
|
+
"checkbox",
|
|
16
|
+
"hidden",
|
|
17
|
+
"file",
|
|
18
|
+
"radio",
|
|
19
|
+
"image",
|
|
20
|
+
"range",
|
|
21
|
+
"reset",
|
|
22
|
+
"submit",
|
|
23
|
+
"number",
|
|
24
|
+
"email",
|
|
25
|
+
"time"
|
|
26
|
+
].includes(node.type) || node.nodeName === "TEXTAREA" || node.contentEditable === "true";
|
|
19
27
|
}
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=is-text-field.mjs.map
|
|
28
|
+
export { isTextField as default };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=is-text-field.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/is-text-field.ts"],
|
|
4
|
-
"sourcesContent": ["import isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given element is a text field, where text field is defined\n * by the ability to select within the input, or that it is contenteditable.\n *\n * See: https://html.spec.whatwg.org/#textFieldSelection\n *\n * @param node The HTML element.\n * @return True if the element is an text field, false if not.\n */\nexport default function isTextField( node: Node ): node is HTMLElement {\n\tconst nonTextInputs = [\n\t\t'button',\n\t\t'checkbox',\n\t\t'hidden',\n\t\t'file',\n\t\t'radio',\n\t\t'image',\n\t\t'range',\n\t\t'reset',\n\t\t'submit',\n\t\t'number',\n\t\t'email',\n\t\t'time',\n\t];\n\treturn (\n\t\t( isHTMLInputElement( node ) &&\n\t\t\tnode.type &&\n\t\t\t! nonTextInputs.includes( node.type ) ) ||\n\t\tnode.nodeName === 'TEXTAREA' ||\n\t\t( node as HTMLElement ).contentEditable === 'true'\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,wBAAwB;AAWhB,SAAR,YAA8B,MAAkC;AACtE,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SACG,mBAAoB,IAAK,KAC1B,KAAK,QACL,CAAE,cAAc,SAAU,KAAK,IAAK,KACrC,KAAK,aAAa,cAChB,KAAsB,oBAAoB;AAE9C;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"is-text-field.mjs","names":[],"sources":["../../src/dom/is-text-field.ts"],"sourcesContent":["import isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given element is a text field, where text field is defined\n * by the ability to select within the input, or that it is contenteditable.\n *\n * See: https://html.spec.whatwg.org/#textFieldSelection\n *\n * @param node The HTML element.\n * @return True if the element is an text field, false if not.\n */\nexport default function isTextField( node: Node ): node is HTMLElement {\n\tconst nonTextInputs = [\n\t\t'button',\n\t\t'checkbox',\n\t\t'hidden',\n\t\t'file',\n\t\t'radio',\n\t\t'image',\n\t\t'range',\n\t\t'reset',\n\t\t'submit',\n\t\t'number',\n\t\t'email',\n\t\t'time',\n\t];\n\treturn (\n\t\t( isHTMLInputElement( node ) &&\n\t\t\tnode.type &&\n\t\t\t! nonTextInputs.includes( node.type ) ) ||\n\t\tnode.nodeName === 'TEXTAREA' ||\n\t\t( node as HTMLElement ).contentEditable === 'true'\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAwB,YAAa,MAAkC;CAetE,OACG,mBAAoB,IAAK,KAC1B,KAAK,QACL,CAAE;EAhBH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAKe,CAAC,CAAC,SAAU,KAAK,IAAK,KACrC,KAAK,aAAa,cAChB,KAAsB,oBAAoB;AAE9C"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
// packages/dom/src/dom/is-vertical-edge.ts
|
|
2
1
|
import isEdge from "./is-edge.mjs";
|
|
2
|
+
// packages/dom/src/dom/is-vertical-edge.ts
|
|
3
|
+
/**
|
|
4
|
+
* Check whether the selection is vertically at the edge of the container.
|
|
5
|
+
*
|
|
6
|
+
* @param {HTMLElement} container Focusable element.
|
|
7
|
+
* @param {boolean} isReverse Set to true to check top, false for bottom.
|
|
8
|
+
*
|
|
9
|
+
* @return {boolean} True if at the vertical edge, false if not.
|
|
10
|
+
*/
|
|
3
11
|
function isVerticalEdge(container, isReverse) {
|
|
4
|
-
|
|
12
|
+
return isEdge(container, isReverse, true);
|
|
5
13
|
}
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=is-vertical-edge.mjs.map
|
|
14
|
+
export { isVerticalEdge as default };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=is-vertical-edge.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/is-vertical-edge.ts"],
|
|
4
|
-
"sourcesContent": ["import isEdge from './is-edge';\n\n/**\n * Check whether the selection is vertically at the edge of the container.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check top, false for bottom.\n *\n * @return {boolean} True if at the vertical edge, false if not.\n */\nexport default function isVerticalEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean\n): boolean {\n\treturn isEdge( container, isReverse, true );\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,YAAY;AAUJ,SAAR,eACN,WACA,WACU;AACV,SAAO,OAAQ,WAAW,WAAW,IAAK;AAC3C;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"is-vertical-edge.mjs","names":[],"sources":["../../src/dom/is-vertical-edge.ts"],"sourcesContent":["import isEdge from './is-edge';\n\n/**\n * Check whether the selection is vertically at the edge of the container.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check top, false for bottom.\n *\n * @return {boolean} True if at the vertical edge, false if not.\n */\nexport default function isVerticalEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean\n): boolean {\n\treturn isEdge( container, isReverse, true );\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAwB,eACvB,WACA,WACU;CACV,OAAO,OAAQ,WAAW,WAAW,IAAK;AAC3C"}
|
|
@@ -1,61 +1,60 @@
|
|
|
1
|
-
// packages/dom/src/dom/place-caret-at-edge.ts
|
|
2
1
|
import hiddenCaretRangeFromPoint from "./hidden-caret-range-from-point.mjs";
|
|
3
2
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
4
3
|
import isInputOrTextArea from "./is-input-or-text-area.mjs";
|
|
5
4
|
import isRTL from "./is-rtl.mjs";
|
|
6
5
|
import { scrollIfNoRange } from "./scroll-if-no-range.mjs";
|
|
6
|
+
// packages/dom/src/dom/place-caret-at-edge.ts
|
|
7
|
+
/**
|
|
8
|
+
* Gets the range to place.
|
|
9
|
+
*
|
|
10
|
+
* @param container Focusable element.
|
|
11
|
+
* @param isReverse True for end, false for start.
|
|
12
|
+
* @param x X coordinate to vertically position.
|
|
13
|
+
*
|
|
14
|
+
* @return The range to place.
|
|
15
|
+
*/
|
|
7
16
|
function getRange(container, isReverse, x) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
x = containerRect.right - 1;
|
|
17
|
-
}
|
|
18
|
-
const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
|
|
19
|
-
return hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
|
|
17
|
+
const { ownerDocument } = container;
|
|
18
|
+
const isReverseDir = isRTL(container) ? !isReverse : isReverse;
|
|
19
|
+
const containerRect = container.getBoundingClientRect();
|
|
20
|
+
if (x === void 0) x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
|
|
21
|
+
else if (x <= containerRect.left) x = containerRect.left + 1;
|
|
22
|
+
else if (x >= containerRect.right) x = containerRect.right - 1;
|
|
23
|
+
const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
|
|
24
|
+
return hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Places the caret at start or end of a given element.
|
|
28
|
+
*
|
|
29
|
+
* @param container Focusable element.
|
|
30
|
+
* @param isReverse True for end, false for start.
|
|
31
|
+
* @param x X coordinate to vertically position.
|
|
32
|
+
*/
|
|
21
33
|
function placeCaretAtEdge(container, isReverse, x) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
() => getRange(container, isReverse, x)
|
|
46
|
-
);
|
|
47
|
-
if (!range) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const { ownerDocument } = container;
|
|
51
|
-
const { defaultView } = ownerDocument;
|
|
52
|
-
assertIsDefined(defaultView, "defaultView");
|
|
53
|
-
const selection = defaultView.getSelection();
|
|
54
|
-
assertIsDefined(selection, "selection");
|
|
55
|
-
selection.removeAllRanges();
|
|
56
|
-
selection.addRange(range);
|
|
34
|
+
if (!container) return;
|
|
35
|
+
container.focus();
|
|
36
|
+
if (isInputOrTextArea(container)) {
|
|
37
|
+
if (typeof container.selectionStart !== "number") return;
|
|
38
|
+
if (isReverse) {
|
|
39
|
+
container.selectionStart = container.value.length;
|
|
40
|
+
container.selectionEnd = container.value.length;
|
|
41
|
+
} else {
|
|
42
|
+
container.selectionStart = 0;
|
|
43
|
+
container.selectionEnd = 0;
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (container.contentEditable !== "true") return;
|
|
48
|
+
const range = scrollIfNoRange(container, isReverse, () => getRange(container, isReverse, x));
|
|
49
|
+
if (!range) return;
|
|
50
|
+
const { ownerDocument } = container;
|
|
51
|
+
const { defaultView } = ownerDocument;
|
|
52
|
+
assertIsDefined(defaultView, "defaultView");
|
|
53
|
+
const selection = defaultView.getSelection();
|
|
54
|
+
assertIsDefined(selection, "selection");
|
|
55
|
+
selection.removeAllRanges();
|
|
56
|
+
selection.addRange(range);
|
|
57
57
|
}
|
|
58
|
-
export {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=place-caret-at-edge.mjs.map
|
|
58
|
+
export { placeCaretAtEdge as default };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=place-caret-at-edge.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/place-caret-at-edge.ts"],
|
|
4
|
-
"sourcesContent": ["import hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport isRTL from './is-rtl';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Gets the range to place.\n *\n * @param container Focusable element.\n * @param isReverse True for end, false for start.\n * @param x X coordinate to vertically position.\n *\n * @return The range to place.\n */\nfunction getRange(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tx: number | undefined\n): Range | null {\n\tconst { ownerDocument } = container;\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\t// When placing at the end (isReverse), find the closest range to the bottom\n\t// right corner. When placing at the start, to the top left corner.\n\t// Ensure x is defined and within the container's boundaries. When it's\n\t// exactly at the boundary, it's not considered within the boundaries.\n\tif ( x === undefined ) {\n\t\tx = isReverse ? containerRect.right - 1 : containerRect.left + 1;\n\t} else if ( x <= containerRect.left ) {\n\t\tx = containerRect.left + 1;\n\t} else if ( x >= containerRect.right ) {\n\t\tx = containerRect.right - 1;\n\t}\n\tconst y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;\n\treturn hiddenCaretRangeFromPoint( ownerDocument, x, y, container );\n}\n\n/**\n * Places the caret at start or end of a given element.\n *\n * @param container Focusable element.\n * @param isReverse True for end, false for start.\n * @param x X coordinate to vertically position.\n */\nexport default function placeCaretAtEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tx: number | undefined\n) {\n\tif ( ! container ) {\n\t\treturn;\n\t}\n\n\tcontainer.focus();\n\n\tif ( isInputOrTextArea( container ) ) {\n\t\t// The element may not support selection setting.\n\t\tif ( typeof container.selectionStart !== 'number' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\tcontainer.selectionStart = container.value.length;\n\t\t\tcontainer.selectionEnd = container.value.length;\n\t\t} else {\n\t\t\tcontainer.selectionStart = 0;\n\t\t\tcontainer.selectionEnd = 0;\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// Only place a caret if the container is itself an editable element.\n\t// It may also be content editable by inheriting it from an editing\n\t// host ancestor (e.g. an editable canvas wrapper), but placing a caret\n\t// for e.g. a focusable block element is then not intended.\n\tif ( container.contentEditable !== 'true' ) {\n\t\treturn;\n\t}\n\n\tconst range = scrollIfNoRange( container, isReverse, () =>\n\t\tgetRange( container, isReverse, x )\n\t);\n\n\tif ( ! range ) {\n\t\treturn;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,+BAA+B;AACtC,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,OAAO,WAAW;AAClB,SAAS,uBAAuB;AAWhC,SAAS,SACR,WACA,WACA,GACe;AACf,QAAM,EAAE,cAAc,IAAI;AAE1B,QAAM,eAAe,MAAO,SAAU,IAAI,CAAE,YAAY;AACxD,QAAM,gBAAgB,UAAU,sBAAsB;AAKtD,MAAK,MAAM,QAAY;AACtB,QAAI,YAAY,cAAc,QAAQ,IAAI,cAAc,OAAO;AAAA,EAChE,WAAY,KAAK,cAAc,MAAO;AACrC,QAAI,cAAc,OAAO;AAAA,EAC1B,WAAY,KAAK,cAAc,OAAQ;AACtC,QAAI,cAAc,QAAQ;AAAA,EAC3B;AACA,QAAM,IAAI,eAAe,cAAc,SAAS,IAAI,cAAc,MAAM;AACxE,SAAO,0BAA2B,eAAe,GAAG,GAAG,SAAU;AAClE;AASe,SAAR,iBACN,WACA,WACA,GACC;AACD,MAAK,CAAE,WAAY;AAClB;AAAA,EACD;AAEA,YAAU,MAAM;AAEhB,MAAK,kBAAmB,SAAU,GAAI;AAErC,QAAK,OAAO,UAAU,mBAAmB,UAAW;AACnD;AAAA,IACD;AAEA,QAAK,WAAY;AAChB,gBAAU,iBAAiB,UAAU,MAAM;AAC3C,gBAAU,eAAe,UAAU,MAAM;AAAA,IAC1C,OAAO;AACN,gBAAU,iBAAiB;AAC3B,gBAAU,eAAe;AAAA,IAC1B;AAEA;AAAA,EACD;AAMA,MAAK,UAAU,oBAAoB,QAAS;AAC3C;AAAA,EACD;AAEA,QAAM,QAAQ;AAAA,IAAiB;AAAA,IAAW;AAAA,IAAW,MACpD,SAAU,WAAW,WAAW,CAAE;AAAA,EACnC;AAEA,MAAK,CAAE,OAAQ;AACd;AAAA,EACD;AAEA,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,IAAI;AACxB,kBAAiB,aAAa,aAAc;AAC5C,QAAM,YAAY,YAAY,aAAa;AAC3C,kBAAiB,WAAW,WAAY;AACxC,YAAU,gBAAgB;AAC1B,YAAU,SAAU,KAAM;AAC3B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"place-caret-at-edge.mjs","names":[],"sources":["../../src/dom/place-caret-at-edge.ts"],"sourcesContent":["import hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport isRTL from './is-rtl';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Gets the range to place.\n *\n * @param container Focusable element.\n * @param isReverse True for end, false for start.\n * @param x X coordinate to vertically position.\n *\n * @return The range to place.\n */\nfunction getRange(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tx: number | undefined\n): Range | null {\n\tconst { ownerDocument } = container;\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\t// When placing at the end (isReverse), find the closest range to the bottom\n\t// right corner. When placing at the start, to the top left corner.\n\t// Ensure x is defined and within the container's boundaries. When it's\n\t// exactly at the boundary, it's not considered within the boundaries.\n\tif ( x === undefined ) {\n\t\tx = isReverse ? containerRect.right - 1 : containerRect.left + 1;\n\t} else if ( x <= containerRect.left ) {\n\t\tx = containerRect.left + 1;\n\t} else if ( x >= containerRect.right ) {\n\t\tx = containerRect.right - 1;\n\t}\n\tconst y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;\n\treturn hiddenCaretRangeFromPoint( ownerDocument, x, y, container );\n}\n\n/**\n * Places the caret at start or end of a given element.\n *\n * @param container Focusable element.\n * @param isReverse True for end, false for start.\n * @param x X coordinate to vertically position.\n */\nexport default function placeCaretAtEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tx: number | undefined\n) {\n\tif ( ! container ) {\n\t\treturn;\n\t}\n\n\tcontainer.focus();\n\n\tif ( isInputOrTextArea( container ) ) {\n\t\t// The element may not support selection setting.\n\t\tif ( typeof container.selectionStart !== 'number' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\tcontainer.selectionStart = container.value.length;\n\t\t\tcontainer.selectionEnd = container.value.length;\n\t\t} else {\n\t\t\tcontainer.selectionStart = 0;\n\t\t\tcontainer.selectionEnd = 0;\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// Only place a caret if the container is itself an editable element.\n\t// It may also be content editable by inheriting it from an editing\n\t// host ancestor (e.g. an editable canvas wrapper), but placing a caret\n\t// for e.g. a focusable block element is then not intended.\n\tif ( container.contentEditable !== 'true' ) {\n\t\treturn;\n\t}\n\n\tconst range = scrollIfNoRange( container, isReverse, () =>\n\t\tgetRange( container, isReverse, x )\n\t);\n\n\tif ( ! range ) {\n\t\treturn;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,SACR,WACA,WACA,GACe;CACf,MAAM,EAAE,kBAAkB;CAE1B,MAAM,eAAe,MAAO,SAAU,IAAI,CAAE,YAAY;CACxD,MAAM,gBAAgB,UAAU,sBAAsB;CAKtD,IAAK,MAAM,KAAA,GACV,IAAI,YAAY,cAAc,QAAQ,IAAI,cAAc,OAAO;MACzD,IAAK,KAAK,cAAc,MAC9B,IAAI,cAAc,OAAO;MACnB,IAAK,KAAK,cAAc,OAC9B,IAAI,cAAc,QAAQ;CAE3B,MAAM,IAAI,eAAe,cAAc,SAAS,IAAI,cAAc,MAAM;CACxE,OAAO,0BAA2B,eAAe,GAAG,GAAG,SAAU;AAClE;;;;;;;;AASA,SAAwB,iBACvB,WACA,WACA,GACC;CACD,IAAK,CAAE,WACN;CAGD,UAAU,MAAM;CAEhB,IAAK,kBAAmB,SAAU,GAAI;EAErC,IAAK,OAAO,UAAU,mBAAmB,UACxC;EAGD,IAAK,WAAY;GAChB,UAAU,iBAAiB,UAAU,MAAM;GAC3C,UAAU,eAAe,UAAU,MAAM;EAC1C,OAAO;GACN,UAAU,iBAAiB;GAC3B,UAAU,eAAe;EAC1B;EAEA;CACD;CAMA,IAAK,UAAU,oBAAoB,QAClC;CAGD,MAAM,QAAQ,gBAAiB,WAAW,iBACzC,SAAU,WAAW,WAAW,CAAE,CACnC;CAEA,IAAK,CAAE,OACN;CAGD,MAAM,EAAE,kBAAkB;CAC1B,MAAM,EAAE,gBAAgB;CACxB,gBAAiB,aAAa,aAAc;CAC5C,MAAM,YAAY,YAAY,aAAa;CAC3C,gBAAiB,WAAW,WAAY;CACxC,UAAU,gBAAgB;CAC1B,UAAU,SAAU,KAAM;AAC3B"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
// packages/dom/src/dom/place-caret-at-horizontal-edge.ts
|
|
2
1
|
import placeCaretAtEdge from "./place-caret-at-edge.mjs";
|
|
2
|
+
// packages/dom/src/dom/place-caret-at-horizontal-edge.ts
|
|
3
|
+
/**
|
|
4
|
+
* Places the caret at start or end of a given element.
|
|
5
|
+
*
|
|
6
|
+
* @param {HTMLElement} container Focusable element.
|
|
7
|
+
* @param {boolean} isReverse True for end, false for start.
|
|
8
|
+
*/
|
|
3
9
|
function placeCaretAtHorizontalEdge(container, isReverse) {
|
|
4
|
-
|
|
10
|
+
return placeCaretAtEdge(container, isReverse, void 0);
|
|
5
11
|
}
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=place-caret-at-horizontal-edge.mjs.map
|
|
12
|
+
export { placeCaretAtHorizontalEdge as default };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=place-caret-at-horizontal-edge.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/place-caret-at-horizontal-edge.ts"],
|
|
4
|
-
"sourcesContent": ["import placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at start or end of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n */\nexport default function placeCaretAtHorizontalEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean\n) {\n\treturn placeCaretAtEdge( container, isReverse, undefined );\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,sBAAsB;AAQd,SAAR,2BACN,WACA,WACC;AACD,SAAO,iBAAkB,WAAW,WAAW,MAAU;AAC1D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"place-caret-at-horizontal-edge.mjs","names":[],"sources":["../../src/dom/place-caret-at-horizontal-edge.ts"],"sourcesContent":["import placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at start or end of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n */\nexport default function placeCaretAtHorizontalEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean\n) {\n\treturn placeCaretAtEdge( container, isReverse, undefined );\n}\n"],"mappings":";;;;;;;;AAQA,SAAwB,2BACvB,WACA,WACC;CACD,OAAO,iBAAkB,WAAW,WAAW,KAAA,CAAU;AAC1D"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
// packages/dom/src/dom/place-caret-at-vertical-edge.ts
|
|
2
1
|
import placeCaretAtEdge from "./place-caret-at-edge.mjs";
|
|
2
|
+
// packages/dom/src/dom/place-caret-at-vertical-edge.ts
|
|
3
|
+
/**
|
|
4
|
+
* Places the caret at the top or bottom of a given element.
|
|
5
|
+
*
|
|
6
|
+
* @param {HTMLElement} container Focusable element.
|
|
7
|
+
* @param {boolean} isReverse True for bottom, false for top.
|
|
8
|
+
* @param {DOMRect} [rect] The rectangle to position the caret with.
|
|
9
|
+
*/
|
|
3
10
|
function placeCaretAtVerticalEdge(container, isReverse, rect) {
|
|
4
|
-
|
|
11
|
+
return placeCaretAtEdge(container, isReverse, rect?.left);
|
|
5
12
|
}
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=place-caret-at-vertical-edge.mjs.map
|
|
13
|
+
export { placeCaretAtVerticalEdge as default };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=place-caret-at-vertical-edge.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/place-caret-at-vertical-edge.ts"],
|
|
4
|
-
"sourcesContent": ["import placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at the top or bottom of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for bottom, false for top.\n * @param {DOMRect} [rect] The rectangle to position the caret with.\n */\nexport default function placeCaretAtVerticalEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\trect?: DOMRect\n) {\n\treturn placeCaretAtEdge( container, isReverse, rect?.left );\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,sBAAsB;AASd,SAAR,yBACN,WACA,WACA,MACC;AACD,SAAO,iBAAkB,WAAW,WAAW,MAAM,IAAK;AAC3D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"place-caret-at-vertical-edge.mjs","names":[],"sources":["../../src/dom/place-caret-at-vertical-edge.ts"],"sourcesContent":["import placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at the top or bottom of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for bottom, false for top.\n * @param {DOMRect} [rect] The rectangle to position the caret with.\n */\nexport default function placeCaretAtVerticalEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\trect?: DOMRect\n) {\n\treturn placeCaretAtEdge( container, isReverse, rect?.left );\n}\n"],"mappings":";;;;;;;;;AASA,SAAwB,yBACvB,WACA,WACA,MACC;CACD,OAAO,iBAAkB,WAAW,WAAW,MAAM,IAAK;AAC3D"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
// packages/dom/src/dom/remove-invalid-html.ts
|
|
2
1
|
import cleanNodeList from "./clean-node-list.mjs";
|
|
2
|
+
// packages/dom/src/dom/remove-invalid-html.ts
|
|
3
|
+
/**
|
|
4
|
+
* Given a schema, unwraps or removes nodes, attributes and classes on HTML.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} HTML The HTML to clean up.
|
|
7
|
+
* @param {Schema} schema Schema for the HTML.
|
|
8
|
+
* @param {boolean} [inline] Whether to clean for inline mode.
|
|
9
|
+
*
|
|
10
|
+
* @return {string} The cleaned up HTML.
|
|
11
|
+
*/
|
|
3
12
|
function removeInvalidHTML(HTML, schema, inline) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
const doc = document.implementation.createHTMLDocument("");
|
|
14
|
+
doc.body.innerHTML = HTML;
|
|
15
|
+
cleanNodeList(doc.body.childNodes, doc, schema, inline);
|
|
16
|
+
return doc.body.innerHTML;
|
|
8
17
|
}
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=remove-invalid-html.mjs.map
|
|
18
|
+
export { removeInvalidHTML as default };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=remove-invalid-html.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/remove-invalid-html.ts"],
|
|
4
|
-
"sourcesContent": ["import cleanNodeList from './clean-node-list';\nimport type { Schema } from './types';\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on HTML.\n *\n * @param {string} HTML The HTML to clean up.\n * @param {Schema} schema Schema for the HTML.\n * @param {boolean} inline Whether to clean for inline mode.\n *\n * @return {string} The cleaned up HTML.\n */\nexport default function removeInvalidHTML(\n\tHTML: string,\n\tschema: Schema,\n\tinline: boolean\n): string {\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\n\tdoc.body.innerHTML = HTML;\n\n\tcleanNodeList( doc.body.childNodes, doc, schema, inline );\n\n\treturn doc.body.innerHTML;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,mBAAmB;AAYX,SAAR,kBACN,MACA,QACA,QACS;AACT,QAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;AAE3D,MAAI,KAAK,YAAY;AAErB,gBAAe,IAAI,KAAK,YAAY,KAAK,QAAQ,MAAO;AAExD,SAAO,IAAI,KAAK;AACjB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"remove-invalid-html.mjs","names":[],"sources":["../../src/dom/remove-invalid-html.ts"],"sourcesContent":["import cleanNodeList from './clean-node-list';\nimport type { Schema } from './types';\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on HTML.\n *\n * @param {string} HTML The HTML to clean up.\n * @param {Schema} schema Schema for the HTML.\n * @param {boolean} [inline] Whether to clean for inline mode.\n *\n * @return {string} The cleaned up HTML.\n */\nexport default function removeInvalidHTML(\n\tHTML: string,\n\tschema: Schema,\n\tinline?: boolean\n): string {\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\n\tdoc.body.innerHTML = HTML;\n\n\tcleanNodeList( doc.body.childNodes, doc, schema, inline );\n\n\treturn doc.body.innerHTML;\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAwB,kBACvB,MACA,QACA,QACS;CACT,MAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;CAE3D,IAAI,KAAK,YAAY;CAErB,cAAe,IAAI,KAAK,YAAY,KAAK,QAAQ,MAAO;CAExD,OAAO,IAAI,KAAK;AACjB"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
// packages/dom/src/dom/remove.ts
|
|
2
1
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
2
|
+
// packages/dom/src/dom/remove.ts
|
|
3
|
+
/**
|
|
4
|
+
* Given a DOM node, removes it from the DOM.
|
|
5
|
+
*
|
|
6
|
+
* @param node Node to be removed.
|
|
7
|
+
*/
|
|
3
8
|
function remove(node) {
|
|
4
|
-
|
|
5
|
-
|
|
9
|
+
assertIsDefined(node.parentNode, "node.parentNode");
|
|
10
|
+
node.parentNode.removeChild(node);
|
|
6
11
|
}
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=remove.mjs.map
|
|
12
|
+
export { remove as default };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=remove.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/remove.ts"],
|
|
4
|
-
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Given a DOM node, removes it from the DOM.\n *\n * @param node Node to be removed.\n */\nexport default function remove( node: Node ): void {\n\tassertIsDefined( node.parentNode, 'node.parentNode' );\n\tnode.parentNode.removeChild( node );\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;AAOjB,SAAR,OAAyB,MAAmB;AAClD,kBAAiB,KAAK,YAAY,iBAAkB;AACpD,OAAK,WAAW,YAAa,IAAK;AACnC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"remove.mjs","names":[],"sources":["../../src/dom/remove.ts"],"sourcesContent":["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Given a DOM node, removes it from the DOM.\n *\n * @param node Node to be removed.\n */\nexport default function remove( node: Node ): void {\n\tassertIsDefined( node.parentNode, 'node.parentNode' );\n\tnode.parentNode.removeChild( node );\n}\n"],"mappings":";;;;;;;AAOA,SAAwB,OAAQ,MAAmB;CAClD,gBAAiB,KAAK,YAAY,iBAAkB;CACpD,KAAK,WAAW,YAAa,IAAK;AACnC"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
// packages/dom/src/dom/replace-tag.ts
|
|
2
1
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
2
|
+
// packages/dom/src/dom/replace-tag.ts
|
|
3
|
+
/**
|
|
4
|
+
* Replaces the given node with a new node with the given tag name.
|
|
5
|
+
*
|
|
6
|
+
* @param node The node to replace
|
|
7
|
+
* @param tagName The new tag name.
|
|
8
|
+
*
|
|
9
|
+
* @return The new node.
|
|
10
|
+
*/
|
|
3
11
|
function replaceTag(node, tagName) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
node.parentNode.replaceChild(newNode, node);
|
|
10
|
-
return newNode;
|
|
12
|
+
const newNode = node.ownerDocument.createElement(tagName);
|
|
13
|
+
while (node.firstChild) newNode.appendChild(node.firstChild);
|
|
14
|
+
assertIsDefined(node.parentNode, "node.parentNode");
|
|
15
|
+
node.parentNode.replaceChild(newNode, node);
|
|
16
|
+
return newNode;
|
|
11
17
|
}
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=replace-tag.mjs.map
|
|
18
|
+
export { replaceTag as default };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=replace-tag.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/replace-tag.ts"],
|
|
4
|
-
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Replaces the given node with a new node with the given tag name.\n *\n * @param node The node to replace\n * @param tagName The new tag name.\n *\n * @return The new node.\n */\nexport default function replaceTag( node: Element, tagName: string ): Element {\n\tconst newNode = node.ownerDocument.createElement( tagName );\n\n\twhile ( node.firstChild ) {\n\t\tnewNode.appendChild( node.firstChild );\n\t}\n\n\tassertIsDefined( node.parentNode, 'node.parentNode' );\n\tnode.parentNode.replaceChild( newNode, node );\n\n\treturn newNode;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;AAUjB,SAAR,WAA6B,MAAe,SAA2B;AAC7E,QAAM,UAAU,KAAK,cAAc,cAAe,OAAQ;AAE1D,SAAQ,KAAK,YAAa;AACzB,YAAQ,YAAa,KAAK,UAAW;AAAA,EACtC;AAEA,kBAAiB,KAAK,YAAY,iBAAkB;AACpD,OAAK,WAAW,aAAc,SAAS,IAAK;AAE5C,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"replace-tag.mjs","names":[],"sources":["../../src/dom/replace-tag.ts"],"sourcesContent":["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Replaces the given node with a new node with the given tag name.\n *\n * @param node The node to replace\n * @param tagName The new tag name.\n *\n * @return The new node.\n */\nexport default function replaceTag( node: Element, tagName: string ): Element {\n\tconst newNode = node.ownerDocument.createElement( tagName );\n\n\twhile ( node.firstChild ) {\n\t\tnewNode.appendChild( node.firstChild );\n\t}\n\n\tassertIsDefined( node.parentNode, 'node.parentNode' );\n\tnode.parentNode.replaceChild( newNode, node );\n\n\treturn newNode;\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAwB,WAAY,MAAe,SAA2B;CAC7E,MAAM,UAAU,KAAK,cAAc,cAAe,OAAQ;CAE1D,OAAQ,KAAK,YACZ,QAAQ,YAAa,KAAK,UAAW;CAGtC,gBAAiB,KAAK,YAAY,iBAAkB;CACpD,KAAK,WAAW,aAAc,SAAS,IAAK;CAE5C,OAAO;AACR"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
// packages/dom/src/dom/replace.ts
|
|
2
1
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
3
2
|
import insertAfter from "./insert-after.mjs";
|
|
4
3
|
import remove from "./remove.mjs";
|
|
4
|
+
// packages/dom/src/dom/replace.ts
|
|
5
|
+
/**
|
|
6
|
+
* Given two DOM nodes, replaces the former with the latter in the DOM.
|
|
7
|
+
*
|
|
8
|
+
* @param processedNode Node to be removed.
|
|
9
|
+
* @param newNode Node to be inserted in its place.
|
|
10
|
+
*/
|
|
5
11
|
function replace(processedNode, newNode) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
assertIsDefined(processedNode.parentNode, "processedNode.parentNode");
|
|
13
|
+
insertAfter(newNode, processedNode.parentNode);
|
|
14
|
+
remove(processedNode);
|
|
9
15
|
}
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=replace.mjs.map
|
|
16
|
+
export { replace as default };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=replace.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/replace.ts"],
|
|
4
|
-
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\nimport insertAfter from './insert-after';\nimport remove from './remove';\n\n/**\n * Given two DOM nodes, replaces the former with the latter in the DOM.\n *\n * @param processedNode Node to be removed.\n * @param newNode Node to be inserted in its place.\n */\nexport default function replace(\n\tprocessedNode: Element,\n\tnewNode: Element\n): void {\n\tassertIsDefined( processedNode.parentNode, 'processedNode.parentNode' );\n\tinsertAfter( newNode, processedNode.parentNode );\n\tremove( processedNode );\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;AAChC,OAAO,iBAAiB;AACxB,OAAO,YAAY;AAQJ,SAAR,QACN,eACA,SACO;AACP,kBAAiB,cAAc,YAAY,0BAA2B;AACtE,cAAa,SAAS,cAAc,UAAW;AAC/C,SAAQ,aAAc;AACvB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"replace.mjs","names":[],"sources":["../../src/dom/replace.ts"],"sourcesContent":["import { assertIsDefined } from '../utils/assert-is-defined';\nimport insertAfter from './insert-after';\nimport remove from './remove';\n\n/**\n * Given two DOM nodes, replaces the former with the latter in the DOM.\n *\n * @param processedNode Node to be removed.\n * @param newNode Node to be inserted in its place.\n */\nexport default function replace(\n\tprocessedNode: Element,\n\tnewNode: Element\n): void {\n\tassertIsDefined( processedNode.parentNode, 'processedNode.parentNode' );\n\tinsertAfter( newNode, processedNode.parentNode );\n\tremove( processedNode );\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAwB,QACvB,eACA,SACO;CACP,gBAAiB,cAAc,YAAY,0BAA2B;CACtE,YAAa,SAAS,cAAc,UAAW;CAC/C,OAAQ,aAAc;AACvB"}
|