wp/wp-includes/js/dist/dom.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 379);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 462);
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
    90 /***/ 17:
       
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
    92 
       
    93 "use strict";
       
    94 
       
    95 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
       
    96 function _arrayWithoutHoles(arr) {
       
    97   if (Array.isArray(arr)) {
       
    98     for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
       
    99       arr2[i] = arr[i];
       
   100     }
       
   101 
       
   102     return arr2;
       
   103   }
       
   104 }
       
   105 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
       
   106 var iterableToArray = __webpack_require__(34);
       
   107 
       
   108 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
       
   109 function _nonIterableSpread() {
       
   110   throw new TypeError("Invalid attempt to spread non-iterable instance");
       
   111 }
       
   112 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
       
   113 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
       
   114 
       
   115 
       
   116 
       
   117 function _toConsumableArray(arr) {
       
   118   return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread();
       
   119 }
       
   120 
       
   121 /***/ }),
       
   122 
       
   123 /***/ 2:
    90 /***/ 2:
   124 /***/ (function(module, exports) {
    91 /***/ (function(module, exports) {
   125 
    92 
   126 (function() { module.exports = this["lodash"]; }());
    93 (function() { module.exports = this["lodash"]; }());
   127 
    94 
   128 /***/ }),
    95 /***/ }),
   129 
    96 
   130 /***/ 34:
    97 /***/ 462:
   131 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   132 
    99 
   133 "use strict";
   100 "use strict";
   134 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
   101 // ESM COMPAT FLAG
   135 function _iterableToArray(iter) {
       
   136   if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
       
   137 }
       
   138 
       
   139 /***/ }),
       
   140 
       
   141 /***/ 379:
       
   142 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   143 
       
   144 "use strict";
       
   145 __webpack_require__.r(__webpack_exports__);
   102 __webpack_require__.r(__webpack_exports__);
       
   103 
       
   104 // EXPORTS
       
   105 __webpack_require__.d(__webpack_exports__, "focus", function() { return /* binding */ build_module_focus; });
       
   106 __webpack_require__.d(__webpack_exports__, "isHorizontalEdge", function() { return /* reexport */ isHorizontalEdge; });
       
   107 __webpack_require__.d(__webpack_exports__, "isVerticalEdge", function() { return /* reexport */ isVerticalEdge; });
       
   108 __webpack_require__.d(__webpack_exports__, "getRectangleFromRange", function() { return /* reexport */ getRectangleFromRange; });
       
   109 __webpack_require__.d(__webpack_exports__, "computeCaretRect", function() { return /* reexport */ computeCaretRect; });
       
   110 __webpack_require__.d(__webpack_exports__, "placeCaretAtHorizontalEdge", function() { return /* reexport */ placeCaretAtHorizontalEdge; });
       
   111 __webpack_require__.d(__webpack_exports__, "placeCaretAtVerticalEdge", function() { return /* reexport */ placeCaretAtVerticalEdge; });
       
   112 __webpack_require__.d(__webpack_exports__, "isTextField", function() { return /* reexport */ isTextField; });
       
   113 __webpack_require__.d(__webpack_exports__, "isNumberInput", function() { return /* reexport */ isNumberInput; });
       
   114 __webpack_require__.d(__webpack_exports__, "documentHasTextSelection", function() { return /* reexport */ documentHasTextSelection; });
       
   115 __webpack_require__.d(__webpack_exports__, "documentHasUncollapsedSelection", function() { return /* reexport */ documentHasUncollapsedSelection; });
       
   116 __webpack_require__.d(__webpack_exports__, "documentHasSelection", function() { return /* reexport */ documentHasSelection; });
       
   117 __webpack_require__.d(__webpack_exports__, "isEntirelySelected", function() { return /* reexport */ isEntirelySelected; });
       
   118 __webpack_require__.d(__webpack_exports__, "getScrollContainer", function() { return /* reexport */ getScrollContainer; });
       
   119 __webpack_require__.d(__webpack_exports__, "getOffsetParent", function() { return /* reexport */ getOffsetParent; });
       
   120 __webpack_require__.d(__webpack_exports__, "replace", function() { return /* reexport */ replace; });
       
   121 __webpack_require__.d(__webpack_exports__, "remove", function() { return /* reexport */ remove; });
       
   122 __webpack_require__.d(__webpack_exports__, "insertAfter", function() { return /* reexport */ insertAfter; });
       
   123 __webpack_require__.d(__webpack_exports__, "unwrap", function() { return /* reexport */ unwrap; });
       
   124 __webpack_require__.d(__webpack_exports__, "replaceTag", function() { return /* reexport */ replaceTag; });
       
   125 __webpack_require__.d(__webpack_exports__, "wrap", function() { return /* reexport */ wrap; });
       
   126 __webpack_require__.d(__webpack_exports__, "__unstableStripHTML", function() { return /* reexport */ __unstableStripHTML; });
       
   127 
       
   128 // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/focusable.js
   146 var focusable_namespaceObject = {};
   129 var focusable_namespaceObject = {};
   147 __webpack_require__.r(focusable_namespaceObject);
   130 __webpack_require__.r(focusable_namespaceObject);
   148 __webpack_require__.d(focusable_namespaceObject, "find", function() { return find; });
   131 __webpack_require__.d(focusable_namespaceObject, "find", function() { return find; });
       
   132 
       
   133 // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/tabbable.js
   149 var tabbable_namespaceObject = {};
   134 var tabbable_namespaceObject = {};
   150 __webpack_require__.r(tabbable_namespaceObject);
   135 __webpack_require__.r(tabbable_namespaceObject);
   151 __webpack_require__.d(tabbable_namespaceObject, "isTabbableIndex", function() { return isTabbableIndex; });
   136 __webpack_require__.d(tabbable_namespaceObject, "isTabbableIndex", function() { return isTabbableIndex; });
   152 __webpack_require__.d(tabbable_namespaceObject, "find", function() { return tabbable_find; });
   137 __webpack_require__.d(tabbable_namespaceObject, "find", function() { return tabbable_find; });
   153 
   138 __webpack_require__.d(tabbable_namespaceObject, "findPrevious", function() { return findPrevious; });
   154 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
   139 __webpack_require__.d(tabbable_namespaceObject, "findNext", function() { return findNext; });
   155 var toConsumableArray = __webpack_require__(17);
       
   156 
   140 
   157 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/focusable.js
   141 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/focusable.js
   158 
       
   159 
       
   160 /**
   142 /**
   161  * References:
   143  * References:
   162  *
   144  *
   163  * Focusable:
   145  * Focusable:
   164  *  - https://www.w3.org/TR/html5/editing.html#focus-management
   146  *  - https://www.w3.org/TR/html5/editing.html#focus-management
   185  * @return {boolean} Whether element is visible.
   167  * @return {boolean} Whether element is visible.
   186  */
   168  */
   187 
   169 
   188 function isVisible(element) {
   170 function isVisible(element) {
   189   return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
   171   return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
       
   172 }
       
   173 /**
       
   174  * Returns true if the specified element should be skipped from focusable elements.
       
   175  * For now it rather specific for `iframes` and  if tabindex attribute is set to -1.
       
   176  *
       
   177  * @param {Element} element DOM element to test.
       
   178  *
       
   179  * @return {boolean} Whether element should be skipped from focusable elements.
       
   180  */
       
   181 
       
   182 
       
   183 function skipFocus(element) {
       
   184   return element.nodeName.toLowerCase() === 'iframe' && element.getAttribute('tabindex') === '-1';
   190 }
   185 }
   191 /**
   186 /**
   192  * Returns true if the specified area element is a valid focusable element, or
   187  * Returns true if the specified area element is a valid focusable element, or
   193  * false otherwise. Area is only focusable if within a map where a named map
   188  * false otherwise. Area is only focusable if within a map where a named map
   194  * referenced by an image somewhere in the document.
   189  * referenced by an image somewhere in the document.
   218  */
   213  */
   219 
   214 
   220 
   215 
   221 function find(context) {
   216 function find(context) {
   222   var elements = context.querySelectorAll(SELECTOR);
   217   var elements = context.querySelectorAll(SELECTOR);
   223   return Object(toConsumableArray["a" /* default */])(elements).filter(function (element) {
   218   return Array.from(elements).filter(function (element) {
   224     if (!isVisible(element)) {
   219     if (!isVisible(element) || skipFocus(element)) {
   225       return false;
   220       return false;
   226     }
   221     }
   227 
   222 
   228     var nodeName = element.nodeName;
   223     var nodeName = element.nodeName;
   229 
   224 
   233 
   228 
   234     return true;
   229     return true;
   235   });
   230   });
   236 }
   231 }
   237 
   232 
   238 // EXTERNAL MODULE: external "lodash"
   233 // EXTERNAL MODULE: external {"this":"lodash"}
   239 var external_lodash_ = __webpack_require__(2);
   234 var external_this_lodash_ = __webpack_require__(2);
   240 
   235 
   241 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/tabbable.js
   236 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/tabbable.js
   242 /**
   237 /**
   243  * External dependencies
   238  * External dependencies
   244  */
   239  */
   309     // the element which had previously been considered the chosen one.
   304     // the element which had previously been considered the chosen one.
   310 
   305 
   311 
   306 
   312     if (hasChosen) {
   307     if (hasChosen) {
   313       var hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
   308       var hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
   314       result = Object(external_lodash_["without"])(result, hadChosenElement);
   309       result = Object(external_this_lodash_["without"])(result, hadChosenElement);
   315     }
   310     }
   316 
   311 
   317     CHOSEN_RADIO_BY_NAME[name] = element;
   312     CHOSEN_RADIO_BY_NAME[name] = element;
   318     return result.concat(element);
   313     return result.concat(element);
   319   };
   314   };
   370     return a.index - b.index;
   365     return a.index - b.index;
   371   }
   366   }
   372 
   367 
   373   return aTabIndex - bTabIndex;
   368   return aTabIndex - bTabIndex;
   374 }
   369 }
       
   370 /**
       
   371  * Givin focusable elements, filters out tabbable element.
       
   372  *
       
   373  * @param {Array} focusables Focusable elements to filter.
       
   374  *
       
   375  * @return {Array} Tabbable elements.
       
   376  */
       
   377 
       
   378 
       
   379 function filterTabbable(focusables) {
       
   380   return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
       
   381 }
   375 
   382 
   376 function tabbable_find(context) {
   383 function tabbable_find(context) {
   377   return find(context).filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
   384   return filterTabbable(find(context));
       
   385 }
       
   386 /**
       
   387  * Given a focusable element, find the preceding tabbable element.
       
   388  *
       
   389  * @param {Element} element The focusable element before which to look. Defaults
       
   390  *                          to the active element.
       
   391  */
       
   392 
       
   393 function findPrevious() {
       
   394   var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.activeElement;
       
   395   var focusables = find(document.body);
       
   396   var index = focusables.indexOf(element); // Remove all focusables after and including `element`.
       
   397 
       
   398   focusables.length = index;
       
   399   return Object(external_this_lodash_["last"])(filterTabbable(focusables));
       
   400 }
       
   401 /**
       
   402  * Given a focusable element, find the next tabbable element.
       
   403  *
       
   404  * @param {Element} element The focusable element after which to look. Defaults
       
   405  *                          to the active element.
       
   406  */
       
   407 
       
   408 function findNext() {
       
   409   var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.activeElement;
       
   410   var focusables = find(document.body);
       
   411   var index = focusables.indexOf(element); // Remove all focusables before and inside `element`.
       
   412 
       
   413   var remaining = focusables.slice(index + 1).filter(function (node) {
       
   414     return !element.contains(node);
       
   415   });
       
   416   return Object(external_this_lodash_["first"])(filterTabbable(remaining));
   378 }
   417 }
   379 
   418 
   380 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom.js
   419 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom.js
   381 /**
   420 /**
   382  * External dependencies
   421  * External dependencies
   385 /**
   424 /**
   386  * Browser dependencies
   425  * Browser dependencies
   387  */
   426  */
   388 
   427 
   389 var _window = window,
   428 var _window = window,
       
   429     DOMParser = _window.DOMParser,
   390     getComputedStyle = _window.getComputedStyle;
   430     getComputedStyle = _window.getComputedStyle;
   391 var _window$Node = window.Node,
   431 var _window$Node = window.Node,
   392     TEXT_NODE = _window$Node.TEXT_NODE,
   432     TEXT_NODE = _window$Node.TEXT_NODE,
   393     ELEMENT_NODE = _window$Node.ELEMENT_NODE,
   433     ELEMENT_NODE = _window$Node.ELEMENT_NODE,
   394     DOCUMENT_POSITION_PRECEDING = _window$Node.DOCUMENT_POSITION_PRECEDING,
   434     DOCUMENT_POSITION_PRECEDING = _window$Node.DOCUMENT_POSITION_PRECEDING,
   447  * @return {boolean} True if at the edge, false if not.
   487  * @return {boolean} True if at the edge, false if not.
   448  */
   488  */
   449 
   489 
   450 
   490 
   451 function isEdge(container, isReverse, onlyVertical) {
   491 function isEdge(container, isReverse, onlyVertical) {
   452   if (Object(external_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
   492   if (Object(external_this_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
   453     if (container.selectionStart !== container.selectionEnd) {
   493     if (container.selectionStart !== container.selectionEnd) {
   454       return false;
   494       return false;
   455     }
   495     }
   456 
   496 
   457     if (isReverse) {
   497     if (isReverse) {
   469 
   509 
   470   if (!selection.rangeCount) {
   510   if (!selection.rangeCount) {
   471     return false;
   511     return false;
   472   }
   512   }
   473 
   513 
   474   var range = selection.getRangeAt(0).cloneRange();
   514   var originalRange = selection.getRangeAt(0);
       
   515   var range = originalRange.cloneRange();
   475   var isForward = isSelectionForward(selection);
   516   var isForward = isSelectionForward(selection);
   476   var isCollapsed = selection.isCollapsed; // Collapse in direction of selection.
   517   var isCollapsed = selection.isCollapsed; // Collapse in direction of selection.
   477 
   518 
   478   if (!isCollapsed) {
   519   if (!isCollapsed) {
   479     range.collapse(!isForward);
   520     range.collapse(!isForward);
   498   // 3/4 the line height to the selection rectangle to ensure that it is well
   539   // 3/4 the line height to the selection rectangle to ensure that it is well
   499   // over its line boundary.
   540   // over its line boundary.
   500 
   541 
   501   var buffer = 3 * parseInt(lineHeight, 10) / 4;
   542   var buffer = 3 * parseInt(lineHeight, 10) / 4;
   502   var containerRect = container.getBoundingClientRect();
   543   var containerRect = container.getBoundingClientRect();
   503   var verticalEdge = isReverse ? containerRect.top + padding > rangeRect.top - buffer : containerRect.bottom - padding < rangeRect.bottom + buffer;
   544   var originalRangeRect = getRectangleFromRange(originalRange);
       
   545   var verticalEdge = isReverse ? containerRect.top + padding > originalRangeRect.top - buffer : containerRect.bottom - padding < originalRangeRect.bottom + buffer;
   504 
   546 
   505   if (!verticalEdge) {
   547   if (!verticalEdge) {
   506     return false;
   548     return false;
   507   }
   549   }
   508 
   550 
   525   if (!testRange) {
   567   if (!testRange) {
   526     return false;
   568     return false;
   527   }
   569   }
   528 
   570 
   529   var side = isReverseDir ? 'left' : 'right';
   571   var side = isReverseDir ? 'left' : 'right';
   530   var testRect = getRectangleFromRange(testRange);
   572   var testRect = getRectangleFromRange(testRange); // Allow the position to be 1px off.
   531   return Math.round(testRect[side]) === Math.round(rangeRect[side]);
   573 
       
   574   return Math.abs(testRect[side] - rangeRect[side]) <= 1;
   532 }
   575 }
   533 /**
   576 /**
   534  * Check whether the selection is horizontally at the edge of the container.
   577  * Check whether the selection is horizontally at the edge of the container.
   535  *
   578  *
   536  * @param {Element} container Focusable element.
   579  * @param {Element} container Focusable element.
   600   return rect;
   643   return rect;
   601 }
   644 }
   602 /**
   645 /**
   603  * Get the rectangle for the selection in a container.
   646  * Get the rectangle for the selection in a container.
   604  *
   647  *
   605  * @param {Element} container Editable container.
       
   606  *
       
   607  * @return {?DOMRect} The rectangle.
   648  * @return {?DOMRect} The rectangle.
   608  */
   649  */
   609 
   650 
   610 function computeCaretRect(container) {
   651 function computeCaretRect() {
   611   if (!container.isContentEditable) {
       
   612     return;
       
   613   }
       
   614 
       
   615   var selection = window.getSelection();
   652   var selection = window.getSelection();
   616   var range = selection.rangeCount ? selection.getRangeAt(0) : null;
   653   var range = selection.rangeCount ? selection.getRangeAt(0) : null;
   617 
   654 
   618   if (!range) {
   655   if (!range) {
   619     return;
   656     return;
   631 function placeCaretAtHorizontalEdge(container, isReverse) {
   668 function placeCaretAtHorizontalEdge(container, isReverse) {
   632   if (!container) {
   669   if (!container) {
   633     return;
   670     return;
   634   }
   671   }
   635 
   672 
   636   if (Object(external_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
   673   if (Object(external_this_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
   637     container.focus();
   674     container.focus();
   638 
   675 
   639     if (isReverse) {
   676     if (isReverse) {
   640       container.selectionStart = container.value.length;
   677       container.selectionStart = container.value.length;
   641       container.selectionEnd = container.value.length;
   678       container.selectionEnd = container.value.length;
   717  * @return {?Range} The best range for the given point.
   754  * @return {?Range} The best range for the given point.
   718  */
   755  */
   719 
   756 
   720 
   757 
   721 function hiddenCaretRangeFromPoint(doc, x, y, container) {
   758 function hiddenCaretRangeFromPoint(doc, x, y, container) {
       
   759   var originalZIndex = container.style.zIndex;
       
   760   var originalPosition = container.style.position; // A z-index only works if the element position is not static.
       
   761 
   722   container.style.zIndex = '10000';
   762   container.style.zIndex = '10000';
       
   763   container.style.position = 'relative';
   723   var range = caretRangeFromPoint(doc, x, y);
   764   var range = caretRangeFromPoint(doc, x, y);
   724   container.style.zIndex = null;
   765   container.style.zIndex = originalZIndex;
       
   766   container.style.position = originalPosition;
   725   return range;
   767   return range;
   726 }
   768 }
   727 /**
   769 /**
   728  * Places the caret at the top or bottom of a given element.
   770  * Places the caret at the top or bottom of a given element.
   729  *
   771  *
   767       return;
   809       return;
   768     }
   810     }
   769 
   811 
   770     placeCaretAtHorizontalEdge(container, isReverse);
   812     placeCaretAtHorizontalEdge(container, isReverse);
   771     return;
   813     return;
   772   } // Check if the closest text node is actually further away.
       
   773   // If so, attempt to get the range again with the y position adjusted to get the right offset.
       
   774 
       
   775 
       
   776   if (range.startContainer.nodeType === TEXT_NODE) {
       
   777     var parentNode = range.startContainer.parentNode;
       
   778     var parentRect = parentNode.getBoundingClientRect();
       
   779     var side = isReverse ? 'bottom' : 'top';
       
   780     var padding = parseInt(getComputedStyle(parentNode).getPropertyValue("padding-".concat(side)), 10) || 0;
       
   781     var actualY = isReverse ? parentRect.bottom - padding - buffer : parentRect.top + padding + buffer;
       
   782 
       
   783     if (y !== actualY) {
       
   784       range = hiddenCaretRangeFromPoint(document, x, actualY, container);
       
   785     }
       
   786   }
   814   }
   787 
   815 
   788   var selection = window.getSelection();
   816   var selection = window.getSelection();
   789   selection.removeAllRanges();
   817   selection.removeAllRanges();
   790   selection.addRange(range);
   818   selection.addRange(range);
   804  *
   832  *
   805  * @return {boolean} True if the element is an text field, false if not.
   833  * @return {boolean} True if the element is an text field, false if not.
   806  */
   834  */
   807 
   835 
   808 function isTextField(element) {
   836 function isTextField(element) {
       
   837   var nodeName = element.nodeName,
       
   838       contentEditable = element.contentEditable;
       
   839   var nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number'];
       
   840   return nodeName === 'INPUT' && !nonTextInputs.includes(element.type) || nodeName === 'TEXTAREA' || contentEditable === 'true';
       
   841 }
       
   842 /**
       
   843  * Check whether the given element is an input field of type number
       
   844  * and has a valueAsNumber
       
   845  *
       
   846  * @param {HTMLElement} element The HTML element.
       
   847  *
       
   848  * @return {boolean} True if the element is input and holds a number.
       
   849  */
       
   850 
       
   851 function isNumberInput(element) {
       
   852   var nodeName = element.nodeName,
       
   853       type = element.type,
       
   854       valueAsNumber = element.valueAsNumber;
       
   855   return nodeName === 'INPUT' && type === 'number' && !!valueAsNumber;
       
   856 }
       
   857 /**
       
   858  * Check whether the current document has selected text. This applies to ranges
       
   859  * of text in the document, and not selection inside <input> and <textarea>
       
   860  * elements.
       
   861  *
       
   862  * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
       
   863  *
       
   864  * @return {boolean} True if there is selection, false if not.
       
   865  */
       
   866 
       
   867 function documentHasTextSelection() {
       
   868   var selection = window.getSelection();
       
   869   var range = selection.rangeCount ? selection.getRangeAt(0) : null;
       
   870   return range && !range.collapsed;
       
   871 }
       
   872 /**
       
   873  * Check whether the given element, assumed an input field or textarea,
       
   874  * contains a (uncollapsed) selection of text.
       
   875  *
       
   876  * Note: this is perhaps an abuse of the term "selection", since these elements
       
   877  * manage selection differently and aren't covered by Selection#collapsed.
       
   878  *
       
   879  * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
       
   880  *
       
   881  * @param {HTMLElement} element The HTML element.
       
   882  *
       
   883  * @return {boolean} Whether the input/textareaa element has some "selection".
       
   884  */
       
   885 
       
   886 function inputFieldHasUncollapsedSelection(element) {
       
   887   if (!isTextField(element) && !isNumberInput(element)) {
       
   888     return false;
       
   889   }
       
   890 
   809   try {
   891   try {
   810     var nodeName = element.nodeName,
   892     var selectionStart = element.selectionStart,
   811         selectionStart = element.selectionStart,
   893         selectionEnd = element.selectionEnd;
   812         contentEditable = element.contentEditable;
   894     return selectionStart !== null && selectionStart !== selectionEnd;
   813     return nodeName === 'INPUT' && selectionStart !== null || nodeName === 'TEXTAREA' || contentEditable === 'true';
       
   814   } catch (error) {
   895   } catch (error) {
   815     // Safari throws an exception when trying to get `selectionStart`
   896     // Safari throws an exception when trying to get `selectionStart`
   816     // on non-text <input> elements (which, understandably, don't
   897     // on non-text <input> elements (which, understandably, don't
   817     // have the text selection API). We catch this via a try/catch
   898     // have the text selection API). We catch this via a try/catch
   818     // block, as opposed to a more explicit check of the element's
   899     // block, as opposed to a more explicit check of the element's
   822     // evolves over time.
   903     // evolves over time.
   823     return false;
   904     return false;
   824   }
   905   }
   825 }
   906 }
   826 /**
   907 /**
   827  * Check wether the current document has a selection.
   908  * Check whether the current document has any sort of selection. This includes
   828  * This checks both for focus in an input field and general text selection.
   909  * ranges of text across elements and any selection inside <input> and
       
   910  * <textarea> elements.
       
   911  *
       
   912  * @return {boolean} Whether there is any sort of "selection" in the document.
       
   913  */
       
   914 
       
   915 
       
   916 function documentHasUncollapsedSelection() {
       
   917   return documentHasTextSelection() || inputFieldHasUncollapsedSelection(document.activeElement);
       
   918 }
       
   919 /**
       
   920  * Check whether the current document has a selection. This checks for both
       
   921  * focus in an input field and general text selection.
   829  *
   922  *
   830  * @return {boolean} True if there is selection, false if not.
   923  * @return {boolean} True if there is selection, false if not.
   831  */
   924  */
   832 
   925 
   833 function documentHasSelection() {
   926 function documentHasSelection() {
   834   if (isTextField(document.activeElement)) {
   927   return isTextField(document.activeElement) || isNumberInput(document.activeElement) || documentHasTextSelection();
   835     return true;
       
   836   }
       
   837 
       
   838   var selection = window.getSelection();
       
   839   var range = selection.rangeCount ? selection.getRangeAt(0) : null;
       
   840   return range && !range.collapsed;
       
   841 }
   928 }
   842 /**
   929 /**
   843  * Check whether the contents of the element have been entirely selected.
   930  * Check whether the contents of the element have been entirely selected.
   844  * Returns true if there is no possibility of selection.
   931  * Returns true if there is no possibility of selection.
   845  *
   932  *
   847  *
   934  *
   848  * @return {boolean} True if entirely selected, false if not.
   935  * @return {boolean} True if entirely selected, false if not.
   849  */
   936  */
   850 
   937 
   851 function isEntirelySelected(element) {
   938 function isEntirelySelected(element) {
   852   if (Object(external_lodash_["includes"])(['INPUT', 'TEXTAREA'], element.nodeName)) {
   939   if (Object(external_this_lodash_["includes"])(['INPUT', 'TEXTAREA'], element.nodeName)) {
   853     return element.selectionStart === 0 && element.value.length === element.selectionEnd;
   940     return element.selectionStart === 0 && element.value.length === element.selectionEnd;
   854   }
   941   }
   855 
   942 
   856   if (!element.isContentEditable) {
   943   if (!element.isContentEditable) {
   857     return true;
   944     return true;
  1018 
  1105 
  1019 function wrap(newNode, referenceNode) {
  1106 function wrap(newNode, referenceNode) {
  1020   referenceNode.parentNode.insertBefore(newNode, referenceNode);
  1107   referenceNode.parentNode.insertBefore(newNode, referenceNode);
  1021   newNode.appendChild(referenceNode);
  1108   newNode.appendChild(referenceNode);
  1022 }
  1109 }
       
  1110 /**
       
  1111  * Removes any HTML tags from the provided string.
       
  1112  *
       
  1113  * @param {string} html The string containing html.
       
  1114  *
       
  1115  * @return {string} The text content with any html removed.
       
  1116  */
       
  1117 
       
  1118 function __unstableStripHTML(html) {
       
  1119   var document = new DOMParser().parseFromString(html, 'text/html');
       
  1120   return document.body.textContent || '';
       
  1121 }
  1023 
  1122 
  1024 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/index.js
  1123 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/index.js
  1025 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "focus", function() { return build_module_focus; });
       
  1026 /* concated harmony reexport isHorizontalEdge */__webpack_require__.d(__webpack_exports__, "isHorizontalEdge", function() { return isHorizontalEdge; });
       
  1027 /* concated harmony reexport isVerticalEdge */__webpack_require__.d(__webpack_exports__, "isVerticalEdge", function() { return isVerticalEdge; });
       
  1028 /* concated harmony reexport getRectangleFromRange */__webpack_require__.d(__webpack_exports__, "getRectangleFromRange", function() { return getRectangleFromRange; });
       
  1029 /* concated harmony reexport computeCaretRect */__webpack_require__.d(__webpack_exports__, "computeCaretRect", function() { return computeCaretRect; });
       
  1030 /* concated harmony reexport placeCaretAtHorizontalEdge */__webpack_require__.d(__webpack_exports__, "placeCaretAtHorizontalEdge", function() { return placeCaretAtHorizontalEdge; });
       
  1031 /* concated harmony reexport placeCaretAtVerticalEdge */__webpack_require__.d(__webpack_exports__, "placeCaretAtVerticalEdge", function() { return placeCaretAtVerticalEdge; });
       
  1032 /* concated harmony reexport isTextField */__webpack_require__.d(__webpack_exports__, "isTextField", function() { return isTextField; });
       
  1033 /* concated harmony reexport documentHasSelection */__webpack_require__.d(__webpack_exports__, "documentHasSelection", function() { return documentHasSelection; });
       
  1034 /* concated harmony reexport isEntirelySelected */__webpack_require__.d(__webpack_exports__, "isEntirelySelected", function() { return isEntirelySelected; });
       
  1035 /* concated harmony reexport getScrollContainer */__webpack_require__.d(__webpack_exports__, "getScrollContainer", function() { return getScrollContainer; });
       
  1036 /* concated harmony reexport getOffsetParent */__webpack_require__.d(__webpack_exports__, "getOffsetParent", function() { return getOffsetParent; });
       
  1037 /* concated harmony reexport replace */__webpack_require__.d(__webpack_exports__, "replace", function() { return replace; });
       
  1038 /* concated harmony reexport remove */__webpack_require__.d(__webpack_exports__, "remove", function() { return remove; });
       
  1039 /* concated harmony reexport insertAfter */__webpack_require__.d(__webpack_exports__, "insertAfter", function() { return insertAfter; });
       
  1040 /* concated harmony reexport unwrap */__webpack_require__.d(__webpack_exports__, "unwrap", function() { return unwrap; });
       
  1041 /* concated harmony reexport replaceTag */__webpack_require__.d(__webpack_exports__, "replaceTag", function() { return replaceTag; });
       
  1042 /* concated harmony reexport wrap */__webpack_require__.d(__webpack_exports__, "wrap", function() { return wrap; });
       
  1043 /**
  1124 /**
  1044  * Internal dependencies
  1125  * Internal dependencies
  1045  */
  1126  */
  1046 
  1127 
  1047 
  1128