@wordpress/dom 3.12.0 → 3.15.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -2
  3. package/build/dom/clean-node-list.js +1 -7
  4. package/build/dom/clean-node-list.js.map +1 -1
  5. package/build/dom/get-rectangle-from-range.js +11 -3
  6. package/build/dom/get-rectangle-from-range.js.map +1 -1
  7. package/build/dom/is-form-element.js +4 -0
  8. package/build/dom/is-form-element.js.map +1 -1
  9. package/build/dom/place-caret-at-edge.js +6 -0
  10. package/build/dom/place-caret-at-edge.js.map +1 -1
  11. package/build/phrasing-content.js +31 -18
  12. package/build/phrasing-content.js.map +1 -1
  13. package/build/tabbable.js +6 -9
  14. package/build/tabbable.js.map +1 -1
  15. package/build-module/dom/clean-node-list.js +1 -6
  16. package/build-module/dom/clean-node-list.js.map +1 -1
  17. package/build-module/dom/get-rectangle-from-range.js +11 -3
  18. package/build-module/dom/get-rectangle-from-range.js.map +1 -1
  19. package/build-module/dom/is-form-element.js +4 -0
  20. package/build-module/dom/is-form-element.js.map +1 -1
  21. package/build-module/dom/place-caret-at-edge.js +6 -0
  22. package/build-module/dom/place-caret-at-edge.js.map +1 -1
  23. package/build-module/phrasing-content.js +30 -16
  24. package/build-module/phrasing-content.js.map +1 -1
  25. package/build-module/tabbable.js +6 -8
  26. package/build-module/tabbable.js.map +1 -1
  27. package/build-types/dom/clean-node-list.d.ts.map +1 -1
  28. package/build-types/dom/get-rectangle-from-range.d.ts +4 -3
  29. package/build-types/dom/get-rectangle-from-range.d.ts.map +1 -1
  30. package/build-types/dom/is-form-element.d.ts.map +1 -1
  31. package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
  32. package/build-types/phrasing-content.d.ts.map +1 -1
  33. package/build-types/tabbable.d.ts +2 -0
  34. package/build-types/tabbable.d.ts.map +1 -1
  35. package/package.json +3 -4
  36. package/src/dom/clean-node-list.js +1 -6
  37. package/src/dom/get-rectangle-from-range.js +12 -3
  38. package/src/dom/is-form-element.js +4 -0
  39. package/src/dom/place-caret-at-edge.js +6 -0
  40. package/src/phrasing-content.js +28 -26
  41. package/src/tabbable.js +6 -8
  42. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["assertIsDefined","getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,4BAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAiBA,KAAK,GAAG,CAAzB;AAAA,KAAd,CAAtB,CATwB,CAWxB;;AACA,QAAKF,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAON,KAAK,CAACU,qBAAN,EAAP;AACA;;AAED,QAAKH,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAOC,aAAa,CAAE,CAAF,CAApB;AACA;;AAED,QA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hB,EAA4BC,KAA5B;AACAzB,IAAAA,KAAK,CAAC8B,MAAN,CAAcN,UAAd,EAA0BC,KAA1B;AACA;;AAED,MAAIM,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAX,CA/DsD,CAiEtD;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAE0B,IAAP,EAAc;AACbjC,IAAAA,eAAe,CAAEwB,aAAF,EAAiB,eAAjB,CAAf;AACA,UAAMU,OAAO,GAAGV,aAAa,CAACW,cAAd,CAA8B,QAA9B,CAAhB,CAFa,CAGb;;AACAjC,IAAAA,KAAK,GAAGA,KAAK,CAACkC,UAAN,EAAR;AACAlC,IAAAA,KAAK,CAACmC,UAAN,CAAkBH,OAAlB;AACAD,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACAP,IAAAA,eAAe,CAAEkC,OAAO,CAACR,UAAV,EAAsB,oBAAtB,CAAf;AACAQ,IAAAA,OAAO,CAACR,UAAR,CAAmBY,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOD,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tlet rect = range.getClientRects()[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["assertIsDefined","getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,4BAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAiBA,KAAK,GAAG,CAAzB;AAAA,KAAd,CAAtB,CATwB,CAWxB;;AACA,QAAKF,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAON,KAAK,CAACU,qBAAN,EAAP;AACA;;AAED,QAAKH,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAOC,aAAa,CAAE,CAAF,CAApB;AACA;;AAED,QAAI;AACHI,MAAAA,GAAG,EAAEC,WADF;AAEHC,MAAAA,MAAM,EAAEC,cAFL;AAGHC,MAAAA,IAAI,EAAEC,YAHH;AAIHC,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AAGF,KAAK,CAACK,cAAN,EAAd,CA/DsD,CAiEtD;AACA;;AACA,MAAKH,KAAK,CAACI,MAAN,GAAe,CAApB,EAAwB;AACvB,WAAO,IAAP;AACA;;AAED,MAAIyB,IAAI,GAAG7B,KAAK,CAAE,CAAF,CAAhB,CAvEsD,CAyEtD;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAE6B,IAAP,EAAc;AACbjC,IAAAA,eAAe,CAAEwB,aAAF,EAAiB,eAAjB,CAAf;AACA,UAAMU,OAAO,GAAGV,aAAa,CAACW,cAAd,CAA8B,QAA9B,CAAhB,CAFa,CAGb;;AACAjC,IAAAA,KAAK,GAAGA,KAAK,CAACkC,UAAN,EAAR;AACAlC,IAAAA,KAAK,CAACmC,UAAN,CAAkBH,OAAlB;AACAD,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACAP,IAAAA,eAAe,CAAEkC,OAAO,CAACR,UAAV,EAAsB,oBAAtB,CAAf;AACAQ,IAAAA,OAAO,CAACR,UAAR,CAAmBY,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOD,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range. Returns `null` if no suitable rectangle\n * can be found.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect?} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tconst rects = range.getClientRects();\n\n\t// If we have multiple rectangles for a collapsed range, there's no way to\n\t// know which it is, so don't return anything.\n\tif ( rects.length > 1 ) {\n\t\treturn null;\n\t}\n\n\tlet rect = rects[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
@@ -12,6 +12,10 @@ import isInputOrTextArea from './is-input-or-text-area';
12
12
  */
13
13
 
14
14
  export default function isFormElement(element) {
15
+ if (!element) {
16
+ return false;
17
+ }
18
+
15
19
  const {
16
20
  tagName
17
21
  } = element;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/is-form-element.js"],"names":["isInputOrTextArea","isFormElement","element","tagName","checkForInputTextarea"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAP,MAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AAChD,QAAM;AAAEC,IAAAA;AAAF,MAAcD,OAApB;AACA,QAAME,qBAAqB,GAAGJ,iBAAiB,CAAEE,OAAF,CAA/C;AACA,SACCE,qBAAqB,IAAID,OAAO,KAAK,QAArC,IAAiDA,OAAO,KAAK,QAD9D;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n *\n * Detects if element is a form element.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} True if form element and false otherwise.\n */\nexport default function isFormElement( element ) {\n\tconst { tagName } = element;\n\tconst checkForInputTextarea = isInputOrTextArea( element );\n\treturn (\n\t\tcheckForInputTextarea || tagName === 'BUTTON' || tagName === 'SELECT'\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/is-form-element.js"],"names":["isInputOrTextArea","isFormElement","element","tagName","checkForInputTextarea"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAP,MAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AAChD,MAAK,CAAEA,OAAP,EAAiB;AAChB,WAAO,KAAP;AACA;;AAED,QAAM;AAAEC,IAAAA;AAAF,MAAcD,OAApB;AACA,QAAME,qBAAqB,GAAGJ,iBAAiB,CAAEE,OAAF,CAA/C;AACA,SACCE,qBAAqB,IAAID,OAAO,KAAK,QAArC,IAAiDA,OAAO,KAAK,QAD9D;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n *\n * Detects if element is a form element.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} True if form element and false otherwise.\n */\nexport default function isFormElement( element ) {\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tconst { tagName } = element;\n\tconst checkForInputTextarea = isInputOrTextArea( element );\n\treturn (\n\t\tcheckForInputTextarea || tagName === 'BUTTON' || tagName === 'SELECT'\n\t);\n}\n"]}
@@ -23,9 +23,15 @@ function getRange(container, isReverse, x) {
23
23
  const isReverseDir = isRTL(container) ? !isReverse : isReverse;
24
24
  const containerRect = container.getBoundingClientRect(); // When placing at the end (isReverse), find the closest range to the bottom
25
25
  // right corner. When placing at the start, to the top left corner.
26
+ // Ensure x is defined and within the container's boundaries. When it's
27
+ // exactly at the boundary, it's not considered within the boundaries.
26
28
 
27
29
  if (x === undefined) {
28
30
  x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
31
+ } else if (x <= containerRect.left) {
32
+ x = containerRect.left + 1;
33
+ } else if (x >= containerRect.right) {
34
+ x = containerRect.right - 1;
29
35
  }
30
36
 
31
37
  const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/place-caret-at-edge.js"],"names":["hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","isRTL","getRange","container","isReverse","x","ownerDocument","isReverseDir","containerRect","getBoundingClientRect","undefined","right","left","y","bottom","top","placeCaretAtEdge","focus","selectionStart","value","length","selectionEnd","isContentEditable","range","startContainer","contains","scrollIntoView","defaultView","selection","getSelection","removeAllRanges","addRange"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,yBAAP,MAAsC,iCAAtC;AACA,SAASC,eAAT,QAAgC,4BAAhC;AACA,OAAOC,iBAAP,MAA8B,yBAA9B;AACA,OAAOC,KAAP,MAAkB,UAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAmBC,SAAnB,EAA8BC,SAA9B,EAAyCC,CAAzC,EAA6C;AAC5C,QAAM;AAAEC,IAAAA;AAAF,MAAoBH,SAA1B,CAD4C,CAE5C;;AACA,QAAMI,YAAY,GAAGN,KAAK,CAAEE,SAAF,CAAL,GAAqB,CAAEC,SAAvB,GAAmCA,SAAxD;AACA,QAAMI,aAAa,GAAGL,SAAS,CAACM,qBAAV,EAAtB,CAJ4C,CAK5C;AACA;;AACA,MAAKJ,CAAC,KAAKK,SAAX,EAAuB;AACtBL,IAAAA,CAAC,GAAGD,SAAS,GAAGI,aAAa,CAACG,KAAd,GAAsB,CAAzB,GAA6BH,aAAa,CAACI,IAAd,GAAqB,CAA/D;AACA;;AACD,QAAMC,CAAC,GAAGN,YAAY,GAAGC,aAAa,CAACM,MAAd,GAAuB,CAA1B,GAA8BN,aAAa,CAACO,GAAd,GAAoB,CAAxE;AACA,SAAOjB,yBAAyB,CAAEQ,aAAF,EAAiBD,CAAjB,EAAoBQ,CAApB,EAAuBV,SAAvB,CAAhC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASa,gBAAT,CAA2Bb,SAA3B,EAAsCC,SAAtC,EAAiDC,CAAjD,EAAqD;AACnE,MAAK,CAAEF,SAAP,EAAmB;AAClB;AACA;;AAEDA,EAAAA,SAAS,CAACc,KAAV;;AAE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,CAAE6B,SAAF,EAAa,WAAb,CAAf;AACAA,EAAAA,SAAS,CAACE,eAAV;AACAF,EAAAA,SAAS,CAACG,QAAV,CAAoBR,KAApB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport 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';\n\n/**\n * Gets the range to place.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n * @param {number|undefined} x X coordinate to vertically position.\n *\n * @return {Range|null} The range to place.\n */\nfunction getRange( container, isReverse, x ) {\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\tif ( x === undefined ) {\n\t\tx = isReverse ? containerRect.right - 1 : containerRect.left + 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 {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n * @param {number|undefined} x X coordinate to vertically position.\n */\nexport default function placeCaretAtEdge( container, isReverse, x ) {\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\tif ( ! container.isContentEditable ) {\n\t\treturn;\n\t}\n\n\tlet range = getRange( container, isReverse, x );\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( isReverse );\n\t\trange = range = getRange( container, isReverse, x );\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;\n\t\t}\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"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/place-caret-at-edge.js"],"names":["hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","isRTL","getRange","container","isReverse","x","ownerDocument","isReverseDir","containerRect","getBoundingClientRect","undefined","right","left","y","bottom","top","placeCaretAtEdge","focus","selectionStart","value","length","selectionEnd","isContentEditable","range","startContainer","contains","scrollIntoView","defaultView","selection","getSelection","removeAllRanges","addRange"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,yBAAP,MAAsC,iCAAtC;AACA,SAASC,eAAT,QAAgC,4BAAhC;AACA,OAAOC,iBAAP,MAA8B,yBAA9B;AACA,OAAOC,KAAP,MAAkB,UAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAmBC,SAAnB,EAA8BC,SAA9B,EAAyCC,CAAzC,EAA6C;AAC5C,QAAM;AAAEC,IAAAA;AAAF,MAAoBH,SAA1B,CAD4C,CAE5C;;AACA,QAAMI,YAAY,GAAGN,KAAK,CAAEE,SAAF,CAAL,GAAqB,CAAEC,SAAvB,GAAmCA,SAAxD;AACA,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AACe,cAAV,GAA2B,CAA3B;AACAf,MAAAA,SAAS,CAACkB,YAAV,GAAyB,CAAzB;AACA;;AAED;AACA;;AAED,MAAK,CAAElB,SAAS,CAACmB,iBAAjB,EAAqC;AACpC;AACA;;AAED,MAAIC,KAAK,GAAGrB,QAAQ,CAAEC,SAAF,EAAaC,SAAb,EAAwBC,CAAxB,CAApB,CA5BmE,CA8BnE;AACA;;AACA,MACC,CAAEkB,KAAF,IACA,CAAEA,KAAK,CAACC,cADR,IAEA,CAAErB,SAAS,CAACsB,QAAV,CAAoBF,KAAK,CAACC,cAA1B,CAHH,EAIE;AACDrB,IAAAA,SAAS,CAACuB,cAAV,CAA0BtB,SAA1B;AACAmB,IAAAA,KAAK,GAAGA,KAAK,GAAGrB,QAAQ,CAAEC,SAAF,EAAaC,SAAb,EAAwBC,CAAxB,CAAxB;;AAEA,QACC,CAAEkB,KAAF,IACA,CAAEA,KAAK,CAACC,cADR,IAEA,CAAErB,SAAS,CAACsB,QAAV,CAAoBF,KAAK,CAACC,cAA1B,CAHH,EAIE;AACD;AACA;AACD;;AAED,QAAM;AAAElB,IAAAA;AAAF,MAAoBH,SAA1B;AACA,QAAM;AAAEwB,IAAAA;AAAF,MAAkBrB,aAAxB;AACAP,EAAAA,eAAe,CAAE4B,WAAF,EAAe,aAAf,CAAf;AACA,QAAMC,SAAS,GAAGD,WAAW,CAACE,YAAZ,EAAlB;AACA9B,EAAAA,eAAe,CAAE6B,SAAF,EAAa,WAAb,CAAf;AACAA,EAAAA,SAAS,CAACE,eAAV;AACAF,EAAAA,SAAS,CAACG,QAAV,CAAoBR,KAApB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport 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';\n\n/**\n * Gets the range to place.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n * @param {number|undefined} x X coordinate to vertically position.\n *\n * @return {Range|null} The range to place.\n */\nfunction getRange( container, isReverse, x ) {\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 {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n * @param {number|undefined} x X coordinate to vertically position.\n */\nexport default function placeCaretAtEdge( container, isReverse, x ) {\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\tif ( ! container.isContentEditable ) {\n\t\treturn;\n\t}\n\n\tlet range = getRange( container, isReverse, x );\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( isReverse );\n\t\trange = range = getRange( container, isReverse, x );\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;\n\t\t}\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"]}
@@ -1,7 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { omit, without } from 'lodash';
5
1
  /**
6
2
  * All phrasing content elements.
7
3
  *
@@ -25,7 +21,6 @@ import { omit, without } from 'lodash';
25
21
  *
26
22
  * @type {ContentSchema}
27
23
  */
28
-
29
24
  const textContentSchema = {
30
25
  strong: {},
31
26
  em: {},
@@ -79,8 +74,13 @@ const textContentSchema = {
79
74
  // Possible: strong > em > strong.
80
75
  // Impossible: strong > strong.
81
76
 
82
- without(Object.keys(textContentSchema), '#text', 'br').forEach(tag => {
83
- textContentSchema[tag].children = omit(textContentSchema, tag);
77
+ const excludedElements = ['#text', 'br'];
78
+ Object.keys(textContentSchema).filter(element => !excludedElements.includes(element)).forEach(tag => {
79
+ const {
80
+ [tag]: removedTag,
81
+ ...restSchema
82
+ } = textContentSchema;
83
+ textContentSchema[tag].children = restSchema;
84
84
  });
85
85
  /**
86
86
  * Embedded content elements.
@@ -134,8 +134,28 @@ export function getPhrasingContentSchema(context) {
134
134
  if (context !== 'paste') {
135
135
  return phrasingContentSchema;
136
136
  }
137
+ /**
138
+ * @type {Partial<ContentSchema>}
139
+ */
140
+
137
141
 
138
- return omit({ ...phrasingContentSchema,
142
+ const {
143
+ u,
144
+ // Used to mark misspelling. Shouldn't be pasted.
145
+ abbr,
146
+ // Invisible.
147
+ data,
148
+ // Invisible.
149
+ time,
150
+ // Invisible.
151
+ wbr,
152
+ // Invisible.
153
+ bdi,
154
+ // Invisible.
155
+ bdo,
156
+ // Invisible.
157
+ ...remainingContentSchema
158
+ } = { ...phrasingContentSchema,
139
159
  // We shouldn't paste potentially sensitive information which is not
140
160
  // visible to the user when pasted, so strip the attributes.
141
161
  ins: {
@@ -144,14 +164,8 @@ export function getPhrasingContentSchema(context) {
144
164
  del: {
145
165
  children: phrasingContentSchema.del.children
146
166
  }
147
- }, ['u', // Used to mark misspelling. Shouldn't be pasted.
148
- 'abbr', // Invisible.
149
- 'data', // Invisible.
150
- 'time', // Invisible.
151
- 'wbr', // Invisible.
152
- 'bdi', // Invisible.
153
- 'bdo' // Invisible.
154
- ]);
167
+ };
168
+ return remainingContentSchema;
155
169
  }
156
170
  /**
157
171
  * Find out whether or not the given node is phrasing content.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/phrasing-content.js"],"names":["omit","without","textContentSchema","strong","em","s","del","ins","a","attributes","code","abbr","sub","sup","br","small","q","dfn","data","time","var","samp","kbd","i","b","u","mark","ruby","rt","rp","bdi","bdo","wbr","Object","keys","forEach","tag","children","embeddedContentSchema","audio","canvas","embed","img","object","video","phrasingContentSchema","getPhrasingContentSchema","context","isPhrasingContent","node","nodeName","toLowerCase","hasOwnProperty","isTextContent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,OAAf,QAA8B,QAA9B;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG;AACzBC,EAAAA,MAAM,EAAE,EADiB;AAEzBC,EAAAA,EAAE,EAAE,EAFqB;AAGzBC,EAAAA,CAAC,EAAE,EAHsB;AAIzBC,EAAAA,GAAG,EAAE,EAJoB;AAKzBC,EAAAA,GAAG,EAAE,EALoB;AAMzBC,EAAAA,CAAC,EAAE;AAAEC,IAAAA,UAAU,EAAE,CAAE,MAAF,EAAU,QAA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,GAAG3C,iBAD0B;AAE7B,KAAGoC;AAF0B,CAA9B;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASQ,wBAAT,CAAmCC,OAAnC,EAA6C;AACnD,MAAKA,OAAO,KAAK,OAAjB,EAA2B;AAC1B,WAAOF,qBAAP;AACA;;AAED,SAAO7C,IAAI,CACV,EACC,GAAG6C,qBADJ;AAEC;AACA;AACAtC,IAAAA,GAAG,EAAE;AAAE8B,MAAAA,QAAQ,EAAEQ,qBAAqB,CAACtC,GAAtB,CAA0B8B;AAAtC,KAJN;AAKC/B,IAAAA,GAAG,EAAE;AAAE+B,MAAAA,QAAQ,EAAEQ,qBAAqB,CAACvC,GAAtB,CAA0B+B;AAAtC;AALN,GADU,EAQV,CACC,GADD,EACM;AACL,QAFD,EAES;AACR,QAHD,EAGS;AACR,QAJD,EAIS;AACR,OALD,EAKQ;AACP,OAND,EAMQ;AACP,OAPD,CAOQ;AAPR,GARU,CAAX;AAkBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAAMb,GAAG,GAAGa,IAAI,CAACC,QAAL,CAAcC,WAAd,EAAZ;AACA,SAAOL,wBAAwB,GAAGM,cAA3B,CAA2ChB,GAA3C,KAAoDA,GAAG,KAAK,MAAnE;AACA;AAED;AACA;AACA;AACA;;AACA,OAAO,SAASiB,aAAT,CAAwBJ,IAAxB,EAA+B;AACrC,QAAMb,GAAG,GAAGa,IAAI,CAACC,QAAL,CAAcC,WAAd,EAAZ;AACA,SAAOjD,iBAAiB,CAACkD,cAAlB,CAAkChB,GAAlC,KAA2CA,GAAG,KAAK,MAA1D;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { omit, without } from 'lodash';\n\n/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n// Recursion is needed.\n// Possible: strong > em > strong.\n// Impossible: strong > strong.\nwithout( Object.keys( textContentSchema ), '#text', 'br' ).forEach( ( tag ) => {\n\ttextContentSchema[ tag ].children = omit( textContentSchema, tag );\n} );\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n *\n * @type {ContentSchema}\n */\nconst embeddedContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n};\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {string} [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return {Partial<ContentSchema>} Schema.\n */\nexport function getPhrasingContentSchema( context ) {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\treturn omit(\n\t\t{\n\t\t\t...phrasingContentSchema,\n\t\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t\t// visible to the user when pasted, so strip the attributes.\n\t\t\tins: { children: phrasingContentSchema.ins.children },\n\t\t\tdel: { children: phrasingContentSchema.del.children },\n\t\t},\n\t\t[\n\t\t\t'u', // Used to mark misspelling. Shouldn't be pasted.\n\t\t\t'abbr', // Invisible.\n\t\t\t'data', // Invisible.\n\t\t\t'time', // Invisible.\n\t\t\t'wbr', // Invisible.\n\t\t\t'bdi', // Invisible.\n\t\t\t'bdo', // Invisible.\n\t\t]\n\t);\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {Node} node The node to test.\n *\n * @return {boolean} True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param {Node} node\n * @return {boolean} Node is text content\n */\nexport function isTextContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/phrasing-content.js"],"names":["textContentSchema","strong","em","s","del","ins","a","attributes","code","abbr","sub","sup","br","small","q","dfn","data","time","var","samp","kbd","i","b","u","mark","ruby","rt","rp","bdi","bdo","wbr","excludedElements","Object","keys","filter","element","includes","forEach","tag","removedTag","restSchema","children","embeddedContentSchema","audio","canvas","embed","img","object","video","phrasingContentSchema","getPhrasingContentSchema","context","remainingContentSchema","isPhrasingContent","node","nodeName","toLowerCase","hasOwnProperty","isTextContent"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG;AACzBC,EAAAA,MAAM,EAAE,EADiB;AAEzBC,EAAAA,EAAE,EAAE,EAFqB;AAGzBC,EAAAA,CAAC,EAAE,EAHsB;AAIzBC,EAAAA,GAAG,EAAE,EAJoB;AAKzBC,EAAAA,GAAG,EAAE,EALoB;AAMzBC,EAAAA,CAAC,EAAE;AAAEC,IAAAA,UAAU,EAAE,CAAE,MAAF,EAAU,QAAV,EAAoB,KAApB,EAA2B,IAA3B;AAAd,GANsB;AAOzBC,EAAAA,IAAI,EAAE,EAPmB;AAQzBC,EAAAA,IAAI,EAAE;AAAEF,IAAAA,UAAU,EAAE,CAAE,OAAF;AAAd,GARmB;AASzBG,EAAAA,GAAG,EAAE,EAToB;AAUzBC,EAAAA,GA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;AACA;AACA;;AACA,OAAO,SAASQ,wBAAT,CAAmCC,OAAnC,EAA6C;AACnD,MAAKA,OAAO,KAAK,OAAjB,EAA2B;AAC1B,WAAOF,qBAAP;AACA;AAED;AACD;AACA;;;AACC,QAAM;AACL1B,IAAAA,CADK;AACF;AACHd,IAAAA,IAFK;AAEC;AACNO,IAAAA,IAHK;AAGC;AACNC,IAAAA,IAJK;AAIC;AACNa,IAAAA,GALK;AAKA;AACLF,IAAAA,GANK;AAMA;AACLC,IAAAA,GAPK;AAOA;AACL,OAAGuB;AARE,MASF,EACH,GAAGH,qBADA;AAEH;AACA;AACA5C,IAAAA,GAAG,EAAE;AAAEoC,MAAAA,QAAQ,EAAEQ,qBAAqB,CAAC5C,GAAtB,CAA0BoC;AAAtC,KAJF;AAKHrC,IAAAA,GAAG,EAAE;AAAEqC,MAAAA,QAAQ,EAAEQ,qBAAqB,CAAC7C,GAAtB,CAA0BqC;AAAtC;AALF,GATJ;AAiBA,SAAOW,sBAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAAMhB,GAAG,GAAGgB,IAAI,CAACC,QAAL,CAAcC,WAAd,EAAZ;AACA,SAAON,wBAAwB,GAAGO,cAA3B,CAA2CnB,GAA3C,KAAoDA,GAAG,KAAK,MAAnE;AACA;AAED;AACA;AACA;AACA;;AACA,OAAO,SAASoB,aAAT,CAAwBJ,IAAxB,EAA+B;AACrC,QAAMhB,GAAG,GAAGgB,IAAI,CAACC,QAAL,CAAcC,WAAd,EAAZ;AACA,SAAOxD,iBAAiB,CAACyD,cAAlB,CAAkCnB,GAAlC,KAA2CA,GAAG,KAAK,MAA1D;AACA","sourcesContent":["/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n// Recursion is needed.\n// Possible: strong > em > strong.\n// Impossible: strong > strong.\nconst excludedElements = [ '#text', 'br' ];\nObject.keys( textContentSchema )\n\t.filter( ( element ) => ! excludedElements.includes( element ) )\n\t.forEach( ( tag ) => {\n\t\tconst { [ tag ]: removedTag, ...restSchema } = textContentSchema;\n\t\ttextContentSchema[ tag ].children = restSchema;\n\t} );\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n *\n * @type {ContentSchema}\n */\nconst embeddedContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n};\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {string} [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return {Partial<ContentSchema>} Schema.\n */\nexport function getPhrasingContentSchema( context ) {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\t/**\n\t * @type {Partial<ContentSchema>}\n\t */\n\tconst {\n\t\tu, // Used to mark misspelling. Shouldn't be pasted.\n\t\tabbr, // Invisible.\n\t\tdata, // Invisible.\n\t\ttime, // Invisible.\n\t\twbr, // Invisible.\n\t\tbdi, // Invisible.\n\t\tbdo, // Invisible.\n\t\t...remainingContentSchema\n\t} = {\n\t\t...phrasingContentSchema,\n\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t// visible to the user when pasted, so strip the attributes.\n\t\tins: { children: phrasingContentSchema.ins.children },\n\t\tdel: { children: phrasingContentSchema.del.children },\n\t};\n\n\treturn remainingContentSchema;\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {Node} node The node to test.\n *\n * @return {boolean} True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param {Node} node\n * @return {boolean} Node is text content\n */\nexport function isTextContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"]}
@@ -1,11 +1,6 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { without, first, last } from 'lodash';
5
1
  /**
6
2
  * Internal dependencies
7
3
  */
8
-
9
4
  import { find as findFocusable } from './focusable';
10
5
  /**
11
6
  * Returns the tab index of the given element. In contrast with the tabIndex
@@ -79,7 +74,7 @@ function createStatefulCollapseRadioGroup() {
79
74
 
80
75
  if (hasChosen) {
81
76
  const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
82
- result = without(result, hadChosenElement);
77
+ result = result.filter(e => e !== hadChosenElement);
83
78
  }
84
79
 
85
80
  CHOSEN_RADIO_BY_NAME[name] = element;
@@ -180,13 +175,16 @@ export function findPrevious(element) {
180
175
 
181
176
 
182
177
  focusables.length = index;
183
- return last(filterTabbable(focusables));
178
+ const tabbable = filterTabbable(focusables);
179
+ return tabbable[tabbable.length - 1];
184
180
  }
185
181
  /**
186
182
  * Given a focusable element, find the next tabbable element.
187
183
  *
188
184
  * @param {Element} element The focusable element after which to look. Defaults
189
185
  * to the active element.
186
+ *
187
+ * @return {Element|undefined} Next tabbable element.
190
188
  */
191
189
 
192
190
  export function findNext(element) {
@@ -194,6 +192,6 @@ export function findNext(element) {
194
192
  const index = focusables.indexOf(element); // Remove all focusables before and including `element`.
195
193
 
196
194
  const remaining = focusables.slice(index + 1);
197
- return first(filterTabbable(remaining));
195
+ return filterTabbable(remaining)[0];
198
196
  }
199
197
  //# sourceMappingURL=tabbable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/tabbable.js"],"names":["without","first","last","find","findFocusable","getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","filter","map","sort","reduce","context","findPrevious","ownerDocument","body","indexOf","undefined","length","findNext","remaining","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,KAAlB,EAAyBC,IAAzB,QAAqC,QAArC;AAEA;AACA;AACA;;AACA,SAASC,IAAI,IAAIC,aAAjB,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAsBC,OAAtB,EAAgC;AAC/B,QAAMC,QAAQ,GAAGD,OAAO,CAACE,YAAR,CAAsB,UAAtB,CAAjB;AACA,SAAOD,QAAQ,KAAK,IAAb,GAAoB,CAApB,GAAwBE,QAAQ,CAAEF,QAAF,EAAY,EAAZ,CAAvC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASG,eAAT,CAA0BJ,OAA1B,EAAoC;AAC1C,SAAOD,WAAW,CAAEC,OAAF,CAAX,KAA2B,CAAC,CAAnC;AACA;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASK,gCAAT,GAA4C;AAC3C;AACA,QAAMC,oBAAoB,GAAG,EAA7B;AAEA,SAAO,SAASC,kBAAT;AACN;AAAuCC,EAAAA,MADjC;AAEN;AAAqCR,EAAAA,OAF/B,EAGL;AACD,UAAM;AAAES,MAAAA,QAAF;AAAYC,MAAAA,IAAZ;AAAk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CAAd,CAFmC,CAInC;;AACA,QAAMyC,SAAS,GAAGb,UAAU,CAACc,KAAX,CAAkBvB,KAAK,GAAG,CAA1B,CAAlB;AAEA,SAAOxB,KAAK,CAAEgC,cAAc,CAAEc,SAAF,CAAhB,CAAZ;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { without, first, last } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param {Element} element Element from which to retrieve.\n *\n * @return {number} Tab index of element (default 0).\n */\nfunction getTabIndex( element ) {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param {Element} element Element to test.\n *\n * @return {boolean} Whether element is tabbable.\n */\nexport function isTabbableIndex( element ) {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/** @typedef {Element & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup() {\n\t/** @type {Record<string, MaybeHTMLInputElement>} */\n\tconst CHOSEN_RADIO_BY_NAME = {};\n\n\treturn function collapseRadioGroup(\n\t\t/** @type {MaybeHTMLInputElement[]} */ result,\n\t\t/** @type {MaybeHTMLInputElement} */ element\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = without( result, hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param {Element} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: Element, index: number }} Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable( element, index ) {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param {{ element: Element }} object Mapped object with element.\n *\n * @return {Element} Mapped object element.\n */\nfunction mapObjectTabbableToElement( object ) {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param {{ element: Element, index: number }} a First object to compare.\n * @param {{ element: Element, index: number }} b Second object to compare.\n *\n * @return {number} Comparator result.\n */\nfunction compareObjectTabbables( a, b ) {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Givin focusable elements, filters out tabbable element.\n *\n * @param {Element[]} focusables Focusable elements to filter.\n *\n * @return {Element[]} Tabbable elements.\n */\nfunction filterTabbable( focusables ) {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param {Element} context\n * @return {Element[]} Tabbable elements within the context.\n */\nexport function find( context ) {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param {Element} element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return {Element|undefined} Preceding tabbable element.\n */\nexport function findPrevious( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\tif ( index === -1 ) {\n\t\treturn undefined;\n\t}\n\n\t// Remove all focusables after and including `element`.\n\tfocusables.length = index;\n\n\treturn last( filterTabbable( focusables ) );\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param {Element} element The focusable element after which to look. Defaults\n * to the active element.\n */\nexport function findNext( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables before and including `element`.\n\tconst remaining = focusables.slice( index + 1 );\n\n\treturn first( filterTabbable( remaining ) );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/tabbable.js"],"names":["find","findFocusable","getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","filter","e","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","map","sort","reduce","context","findPrevious","ownerDocument","body","indexOf","undefined","length","tabbable","findNext","remaining","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,aAAjB,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AAc,CAAE/B,aAAa,CAAEoC,OAAF,CAAf,CAArB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBnC,OAAvB,EAAiC;AACvC,QAAM8B,UAAU,GAAGhC,aAAa,CAAEE,OAAO,CAACoC,aAAR,CAAsBC,IAAxB,CAAhC;AACA,QAAMhB,KAAK,GAAGS,UAAU,CAACQ,OAAX,CAAoBtC,OAApB,CAAd;;AAEA,MAAKqB,KAAK,KAAK,CAAC,CAAhB,EAAoB;AACnB,WAAOkB,SAAP;AACA,GANsC,CAQvC;;;AACAT,EAAAA,UAAU,CAACU,MAAX,GAAoBnB,KAApB;AAEA,QAAMoB,QAAQ,GAAGZ,cAAc,CAAEC,UAAF,CAA/B;AACA,SAAOW,QAAQ,CAAEA,QAAQ,CAACD,MAAT,GAAkB,CAApB,CAAf;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,QAAT,CAAmB1C,OAAnB,EAA6B;AACnC,QAAM8B,UAAU,GAAGhC,aAAa,CAAEE,OAAO,CAACoC,aAAR,CAAsBC,IAAxB,CAAhC;AACA,QAAMhB,KAAK,GAAGS,UAAU,CAACQ,OAAX,CAAoBtC,OAApB,CAAd,CAFmC,CAInC;;AACA,QAAM2C,SAAS,GAAGb,UAAU,CAACc,KAAX,CAAkBvB,KAAK,GAAG,CAA1B,CAAlB;AAEA,SAAOQ,cAAc,CAAEc,SAAF,CAAd,CAA6B,CAA7B,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param {Element} element Element from which to retrieve.\n *\n * @return {number} Tab index of element (default 0).\n */\nfunction getTabIndex( element ) {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param {Element} element Element to test.\n *\n * @return {boolean} Whether element is tabbable.\n */\nexport function isTabbableIndex( element ) {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/** @typedef {Element & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup() {\n\t/** @type {Record<string, MaybeHTMLInputElement>} */\n\tconst CHOSEN_RADIO_BY_NAME = {};\n\n\treturn function collapseRadioGroup(\n\t\t/** @type {MaybeHTMLInputElement[]} */ result,\n\t\t/** @type {MaybeHTMLInputElement} */ element\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = result.filter( ( e ) => e !== hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param {Element} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: Element, index: number }} Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable( element, index ) {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param {{ element: Element }} object Mapped object with element.\n *\n * @return {Element} Mapped object element.\n */\nfunction mapObjectTabbableToElement( object ) {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param {{ element: Element, index: number }} a First object to compare.\n * @param {{ element: Element, index: number }} b Second object to compare.\n *\n * @return {number} Comparator result.\n */\nfunction compareObjectTabbables( a, b ) {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Givin focusable elements, filters out tabbable element.\n *\n * @param {Element[]} focusables Focusable elements to filter.\n *\n * @return {Element[]} Tabbable elements.\n */\nfunction filterTabbable( focusables ) {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param {Element} context\n * @return {Element[]} Tabbable elements within the context.\n */\nexport function find( context ) {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param {Element} element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return {Element|undefined} Preceding tabbable element.\n */\nexport function findPrevious( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\tif ( index === -1 ) {\n\t\treturn undefined;\n\t}\n\n\t// Remove all focusables after and including `element`.\n\tfocusables.length = index;\n\n\tconst tabbable = filterTabbable( focusables );\n\treturn tabbable[ tabbable.length - 1 ];\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param {Element} element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return {Element|undefined} Next tabbable element.\n */\nexport function findNext( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables before and including `element`.\n\tconst remaining = focusables.slice( index + 1 );\n\n\treturn filterTabbable( remaining )[ 0 ];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clean-node-list.d.ts","sourceRoot":"","sources":["../../src/dom/clean-node-list.js"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AAEH,sDAAsD;AAGtD;;;;;;;;GAQG;AACH,gDALW,QAAQ,OACR,QAAQ,UACR,MAAM,UACN,OAAO,QAwJjB;;;;;;;;;;;;;;;;;;;;;;;gBAtKa,OAAO;;;;sBACA,IAAI,KAAK,OAAO"}
1
+ {"version":3,"file":"clean-node-list.d.ts","sourceRoot":"","sources":["../../src/dom/clean-node-list.js"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AAEH,sDAAsD;AAGtD;;;;;;;;GAQG;AACH,gDALW,QAAQ,OACR,QAAQ,UACR,MAAM,UACN,OAAO,QAwJjB;;;;;;;;;;;;;;;;;;;;;;;gBAtKa,OAAO;;;;sBACA,IAAI,KAAK,OAAO"}
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Get the rectangle of a given Range.
2
+ * Get the rectangle of a given Range. Returns `null` if no suitable rectangle
3
+ * can be found.
3
4
  *
4
5
  * @param {Range} range The range.
5
6
  *
6
- * @return {DOMRect} The rectangle.
7
+ * @return {DOMRect?} The rectangle.
7
8
  */
8
- export default function getRectangleFromRange(range: Range): DOMRect;
9
+ export default function getRectangleFromRange(range: Range): DOMRect | null;
9
10
  //# sourceMappingURL=get-rectangle-from-range.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-rectangle-from-range.d.ts","sourceRoot":"","sources":["../../src/dom/get-rectangle-from-range.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,qDAJW,KAAK,GAEJ,OAAO,CAoFlB"}
1
+ {"version":3,"file":"get-rectangle-from-range.d.ts","sourceRoot":"","sources":["../../src/dom/get-rectangle-from-range.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,qDAJW,KAAK,GAEJ,OAAO,QA4FlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"is-form-element.d.ts","sourceRoot":"","sources":["../../src/dom/is-form-element.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,+CAJW,OAAO,GAEN,OAAO,CAQlB"}
1
+ {"version":3,"file":"is-form-element.d.ts","sourceRoot":"","sources":["../../src/dom/is-form-element.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,+CAJW,OAAO,GAEN,OAAO,CAYlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"place-caret-at-edge.d.ts","sourceRoot":"","sources":["../../src/dom/place-caret-at-edge.js"],"names":[],"mappings":"AA+BA;;;;;;GAMG;AACH,oDAJW,WAAW,aACX,OAAO,KACP,MAAM,GAAC,SAAS,QA0D1B"}
1
+ {"version":3,"file":"place-caret-at-edge.d.ts","sourceRoot":"","sources":["../../src/dom/place-caret-at-edge.js"],"names":[],"mappings":"AAqCA;;;;;;GAMG;AACH,oDAJW,WAAW,aACX,OAAO,KACP,MAAM,GAAC,SAAS,QA0D1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"phrasing-content.d.ts","sourceRoot":"","sources":["../src/phrasing-content.js"],"names":[],"mappings":"AA0IA;;;;;;;;;GASG;AACH,wEAFY,QAAQ,aAAa,CAAC,CAyBjC;AAED;;;;;;;;GAQG;AACH,wCAJW,IAAI,GAEH,OAAO,CAKlB;AAED;;;GAGG;AACH,oCAHW,IAAI,GACH,OAAO,CAKlB;4BAtLY,OAAO,MAAM,EAAC,yBAAyB,CAAC"}
1
+ {"version":3,"file":"phrasing-content.d.ts","sourceRoot":"","sources":["../src/phrasing-content.js"],"names":[],"mappings":"AAyIA;;;;;;;;;GASG;AACH,wEAFY,QAAQ,aAAa,CAAC,CA4BjC;AAED;;;;;;;;GAQG;AACH,wCAJW,IAAI,GAEH,OAAO,CAKlB;AAED;;;GAGG;AACH,oCAHW,IAAI,GACH,OAAO,CAKlB;4BA7LY,OAAO,MAAM,EAAC,yBAAyB,CAAC"}
@@ -25,6 +25,8 @@ export function findPrevious(element: Element): Element | undefined;
25
25
  *
26
26
  * @param {Element} element The focusable element after which to look. Defaults
27
27
  * to the active element.
28
+ *
29
+ * @return {Element|undefined} Next tabbable element.
28
30
  */
29
31
  export function findNext(element: Element): Element | undefined;
30
32
  export type MaybeHTMLInputElement = Element & {
@@ -1 +1 @@
1
- {"version":3,"file":"tabbable.d.ts","sourceRoot":"","sources":["../src/tabbable.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,yCAJW,OAAO,GAEN,OAAO,CAIlB;AAiHD;;;GAGG;AACH,8BAHW,OAAO,GACN,OAAO,EAAE,CAIpB;AAED;;;;;;;GAOG;AACH,sCALW,OAAO,GAGN,OAAO,GAAC,SAAS,CAc5B;AAED;;;;;GAKG;AACH,kCAHW,OAAO,uBAWjB;oCA3Ja,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE"}
1
+ {"version":3,"file":"tabbable.d.ts","sourceRoot":"","sources":["../src/tabbable.js"],"names":[],"mappings":"AAsBA;;;;;;GAMG;AACH,yCAJW,OAAO,GAEN,OAAO,CAIlB;AAiHD;;;GAGG;AACH,8BAHW,OAAO,GACN,OAAO,EAAE,CAIpB;AAED;;;;;;;GAOG;AACH,sCALW,OAAO,GAGN,OAAO,GAAC,SAAS,CAe5B;AAED;;;;;;;GAOG;AACH,kCALW,OAAO,GAGN,OAAO,GAAC,SAAS,CAU5B;oCA9Ja,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/dom",
3
- "version": "3.12.0",
3
+ "version": "3.15.0",
4
4
  "description": "DOM utilities module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,11 +29,10 @@
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.16.0",
32
- "@wordpress/deprecated": "^3.8.0",
33
- "lodash": "^4.17.21"
32
+ "@wordpress/deprecated": "^3.8.0"
34
33
  },
35
34
  "publishConfig": {
36
35
  "access": "public"
37
36
  },
38
- "gitHead": "a80eeb62ec7cb1418b9915c277e084a29d6665e3"
37
+ "gitHead": "08358f53b627a15148c3a3e433cdf58cf8714aa4"
39
38
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { includes } from 'lodash';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
@@ -70,7 +65,7 @@ export default function cleanNodeList( nodeList, doc, schema, inline ) {
70
65
  Array.from( node.attributes ).forEach( ( { name } ) => {
71
66
  if (
72
67
  name !== 'class' &&
73
- ! includes( attributes, name )
68
+ ! attributes.includes( name )
74
69
  ) {
75
70
  node.removeAttribute( name );
76
71
  }
@@ -4,11 +4,12 @@
4
4
  import { assertIsDefined } from '../utils/assert-is-defined';
5
5
 
6
6
  /**
7
- * Get the rectangle of a given Range.
7
+ * Get the rectangle of a given Range. Returns `null` if no suitable rectangle
8
+ * can be found.
8
9
  *
9
10
  * @param {Range} range The range.
10
11
  *
11
- * @return {DOMRect} The rectangle.
12
+ * @return {DOMRect?} The rectangle.
12
13
  */
13
14
  export default function getRectangleFromRange( range ) {
14
15
  // For uncollapsed ranges, get the rectangle that bounds the contents of the
@@ -73,7 +74,15 @@ export default function getRectangleFromRange( range ) {
73
74
  range.setEnd( parentNode, index );
74
75
  }
75
76
 
76
- let rect = range.getClientRects()[ 0 ];
77
+ const rects = range.getClientRects();
78
+
79
+ // If we have multiple rectangles for a collapsed range, there's no way to
80
+ // know which it is, so don't return anything.
81
+ if ( rects.length > 1 ) {
82
+ return null;
83
+ }
84
+
85
+ let rect = rects[ 0 ];
77
86
 
78
87
  // If the collapsed range starts (and therefore ends) at an element node,
79
88
  // `getClientRects` can be empty in some browsers. This can be resolved
@@ -12,6 +12,10 @@ import isInputOrTextArea from './is-input-or-text-area';
12
12
  * @return {boolean} True if form element and false otherwise.
13
13
  */
14
14
  export default function isFormElement( element ) {
15
+ if ( ! element ) {
16
+ return false;
17
+ }
18
+
15
19
  const { tagName } = element;
16
20
  const checkForInputTextarea = isInputOrTextArea( element );
17
21
  return (
@@ -22,8 +22,14 @@ function getRange( container, isReverse, x ) {
22
22
  const containerRect = container.getBoundingClientRect();
23
23
  // When placing at the end (isReverse), find the closest range to the bottom
24
24
  // right corner. When placing at the start, to the top left corner.
25
+ // Ensure x is defined and within the container's boundaries. When it's
26
+ // exactly at the boundary, it's not considered within the boundaries.
25
27
  if ( x === undefined ) {
26
28
  x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
29
+ } else if ( x <= containerRect.left ) {
30
+ x = containerRect.left + 1;
31
+ } else if ( x >= containerRect.right ) {
32
+ x = containerRect.right - 1;
27
33
  }
28
34
  const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
29
35
  return hiddenCaretRangeFromPoint( ownerDocument, x, y, container );
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { omit, without } from 'lodash';
5
-
6
1
  /**
7
2
  * All phrasing content elements.
8
3
  *
@@ -64,9 +59,13 @@ const textContentSchema = {
64
59
  // Recursion is needed.
65
60
  // Possible: strong > em > strong.
66
61
  // Impossible: strong > strong.
67
- without( Object.keys( textContentSchema ), '#text', 'br' ).forEach( ( tag ) => {
68
- textContentSchema[ tag ].children = omit( textContentSchema, tag );
69
- } );
62
+ const excludedElements = [ '#text', 'br' ];
63
+ Object.keys( textContentSchema )
64
+ .filter( ( element ) => ! excludedElements.includes( element ) )
65
+ .forEach( ( tag ) => {
66
+ const { [ tag ]: removedTag, ...restSchema } = textContentSchema;
67
+ textContentSchema[ tag ].children = restSchema;
68
+ } );
70
69
 
71
70
  /**
72
71
  * Embedded content elements.
@@ -151,24 +150,27 @@ export function getPhrasingContentSchema( context ) {
151
150
  return phrasingContentSchema;
152
151
  }
153
152
 
154
- return omit(
155
- {
156
- ...phrasingContentSchema,
157
- // We shouldn't paste potentially sensitive information which is not
158
- // visible to the user when pasted, so strip the attributes.
159
- ins: { children: phrasingContentSchema.ins.children },
160
- del: { children: phrasingContentSchema.del.children },
161
- },
162
- [
163
- 'u', // Used to mark misspelling. Shouldn't be pasted.
164
- 'abbr', // Invisible.
165
- 'data', // Invisible.
166
- 'time', // Invisible.
167
- 'wbr', // Invisible.
168
- 'bdi', // Invisible.
169
- 'bdo', // Invisible.
170
- ]
171
- );
153
+ /**
154
+ * @type {Partial<ContentSchema>}
155
+ */
156
+ const {
157
+ u, // Used to mark misspelling. Shouldn't be pasted.
158
+ abbr, // Invisible.
159
+ data, // Invisible.
160
+ time, // Invisible.
161
+ wbr, // Invisible.
162
+ bdi, // Invisible.
163
+ bdo, // Invisible.
164
+ ...remainingContentSchema
165
+ } = {
166
+ ...phrasingContentSchema,
167
+ // We shouldn't paste potentially sensitive information which is not
168
+ // visible to the user when pasted, so strip the attributes.
169
+ ins: { children: phrasingContentSchema.ins.children },
170
+ del: { children: phrasingContentSchema.del.children },
171
+ };
172
+
173
+ return remainingContentSchema;
172
174
  }
173
175
 
174
176
  /**
package/src/tabbable.js CHANGED
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { without, first, last } from 'lodash';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
@@ -74,7 +69,7 @@ function createStatefulCollapseRadioGroup() {
74
69
  // the element which had previously been considered the chosen one.
75
70
  if ( hasChosen ) {
76
71
  const hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];
77
- result = without( result, hadChosenElement );
72
+ result = result.filter( ( e ) => e !== hadChosenElement );
78
73
  }
79
74
 
80
75
  CHOSEN_RADIO_BY_NAME[ name ] = element;
@@ -174,7 +169,8 @@ export function findPrevious( element ) {
174
169
  // Remove all focusables after and including `element`.
175
170
  focusables.length = index;
176
171
 
177
- return last( filterTabbable( focusables ) );
172
+ const tabbable = filterTabbable( focusables );
173
+ return tabbable[ tabbable.length - 1 ];
178
174
  }
179
175
 
180
176
  /**
@@ -182,6 +178,8 @@ export function findPrevious( element ) {
182
178
  *
183
179
  * @param {Element} element The focusable element after which to look. Defaults
184
180
  * to the active element.
181
+ *
182
+ * @return {Element|undefined} Next tabbable element.
185
183
  */
186
184
  export function findNext( element ) {
187
185
  const focusables = findFocusable( element.ownerDocument.body );
@@ -190,5 +188,5 @@ export function findNext( element ) {
190
188
  // Remove all focusables before and including `element`.
191
189
  const remaining = focusables.slice( index + 1 );
192
190
 
193
- return first( filterTabbable( remaining ) );
191
+ return filterTabbable( remaining )[ 0 ];
194
192
  }