[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> dom.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["dom"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = 386);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 2:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = this["lodash"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 386:
  98  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99  
 100  "use strict";
 101  __webpack_require__.r(__webpack_exports__);
 102  var focusable_namespaceObject = {};
 103  __webpack_require__.r(focusable_namespaceObject);
 104  __webpack_require__.d(focusable_namespaceObject, "find", function() { return find; });
 105  var tabbable_namespaceObject = {};
 106  __webpack_require__.r(tabbable_namespaceObject);
 107  __webpack_require__.d(tabbable_namespaceObject, "isTabbableIndex", function() { return isTabbableIndex; });
 108  __webpack_require__.d(tabbable_namespaceObject, "find", function() { return tabbable_find; });
 109  
 110  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/focusable.js
 111  /**
 112   * References:
 113   *
 114   * Focusable:
 115   *  - https://www.w3.org/TR/html5/editing.html#focus-management
 116   *
 117   * Sequential focus navigation:
 118   *  - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute
 119   *
 120   * Disabled elements:
 121   *  - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements
 122   *
 123   * getClientRects algorithm (requiring layout box):
 124   *  - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface
 125   *
 126   * AREA elements associated with an IMG:
 127   *  - https://w3c.github.io/html/editing.html#data-model
 128   */
 129  var SELECTOR = ['[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', 'object', 'embed', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
 130  /**
 131   * Returns true if the specified element is visible (i.e. neither display: none
 132   * nor visibility: hidden).
 133   *
 134   * @param {Element} element DOM element to test.
 135   *
 136   * @return {boolean} Whether element is visible.
 137   */
 138  
 139  function isVisible(element) {
 140    return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
 141  }
 142  /**
 143   * Returns true if the specified area element is a valid focusable element, or
 144   * false otherwise. Area is only focusable if within a map where a named map
 145   * referenced by an image somewhere in the document.
 146   *
 147   * @param {Element} element DOM area element to test.
 148   *
 149   * @return {boolean} Whether area element is valid for focus.
 150   */
 151  
 152  
 153  function isValidFocusableArea(element) {
 154    var map = element.closest('map[name]');
 155  
 156    if (!map) {
 157      return false;
 158    }
 159  
 160    var img = document.querySelector('img[usemap="#' + map.name + '"]');
 161    return !!img && isVisible(img);
 162  }
 163  /**
 164   * Returns all focusable elements within a given context.
 165   *
 166   * @param {Element} context Element in which to search.
 167   *
 168   * @return {Element[]} Focusable elements.
 169   */
 170  
 171  
 172  function find(context) {
 173    var elements = context.querySelectorAll(SELECTOR);
 174    return Array.from(elements).filter(function (element) {
 175      if (!isVisible(element)) {
 176        return false;
 177      }
 178  
 179      var nodeName = element.nodeName;
 180  
 181      if ('AREA' === nodeName) {
 182        return isValidFocusableArea(element);
 183      }
 184  
 185      return true;
 186    });
 187  }
 188  
 189  // EXTERNAL MODULE: external {"this":"lodash"}
 190  var external_this_lodash_ = __webpack_require__(2);
 191  
 192  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/tabbable.js
 193  /**
 194   * External dependencies
 195   */
 196  
 197  /**
 198   * Internal dependencies
 199   */
 200  
 201  
 202  /**
 203   * Returns the tab index of the given element. In contrast with the tabIndex
 204   * property, this normalizes the default (0) to avoid browser inconsistencies,
 205   * operating under the assumption that this function is only ever called with a
 206   * focusable node.
 207   *
 208   * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261
 209   *
 210   * @param {Element} element Element from which to retrieve.
 211   *
 212   * @return {?number} Tab index of element (default 0).
 213   */
 214  
 215  function getTabIndex(element) {
 216    var tabIndex = element.getAttribute('tabindex');
 217    return tabIndex === null ? 0 : parseInt(tabIndex, 10);
 218  }
 219  /**
 220   * Returns true if the specified element is tabbable, or false otherwise.
 221   *
 222   * @param {Element} element Element to test.
 223   *
 224   * @return {boolean} Whether element is tabbable.
 225   */
 226  
 227  
 228  function isTabbableIndex(element) {
 229    return getTabIndex(element) !== -1;
 230  }
 231  /**
 232   * Returns a stateful reducer function which constructs a filtered array of
 233   * tabbable elements, where at most one radio input is selected for a given
 234   * name, giving priority to checked input, falling back to the first
 235   * encountered.
 236   *
 237   * @return {Function} Radio group collapse reducer.
 238   */
 239  
 240  function createStatefulCollapseRadioGroup() {
 241    var CHOSEN_RADIO_BY_NAME = {};
 242    return function collapseRadioGroup(result, element) {
 243      var nodeName = element.nodeName,
 244          type = element.type,
 245          checked = element.checked,
 246          name = element.name; // For all non-radio tabbables, construct to array by concatenating.
 247  
 248      if (nodeName !== 'INPUT' || type !== 'radio' || !name) {
 249        return result.concat(element);
 250      }
 251  
 252      var hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name); // Omit by skipping concatenation if the radio element is not chosen.
 253  
 254      var isChosen = checked || !hasChosen;
 255  
 256      if (!isChosen) {
 257        return result;
 258      } // At this point, if there had been a chosen element, the current
 259      // element is checked and should take priority. Retroactively remove
 260      // the element which had previously been considered the chosen one.
 261  
 262  
 263      if (hasChosen) {
 264        var hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
 265        result = Object(external_this_lodash_["without"])(result, hadChosenElement);
 266      }
 267  
 268      CHOSEN_RADIO_BY_NAME[name] = element;
 269      return result.concat(element);
 270    };
 271  }
 272  /**
 273   * An array map callback, returning an object with the element value and its
 274   * array index location as properties. This is used to emulate a proper stable
 275   * sort where equal tabIndex should be left in order of their occurrence in the
 276   * document.
 277   *
 278   * @param {Element} element Element.
 279   * @param {number}  index   Array index of element.
 280   *
 281   * @return {Object} Mapped object with element, index.
 282   */
 283  
 284  
 285  function mapElementToObjectTabbable(element, index) {
 286    return {
 287      element: element,
 288      index: index
 289    };
 290  }
 291  /**
 292   * An array map callback, returning an element of the given mapped object's
 293   * element value.
 294   *
 295   * @param {Object} object Mapped object with index.
 296   *
 297   * @return {Element} Mapped object element.
 298   */
 299  
 300  
 301  function mapObjectTabbableToElement(object) {
 302    return object.element;
 303  }
 304  /**
 305   * A sort comparator function used in comparing two objects of mapped elements.
 306   *
 307   * @see mapElementToObjectTabbable
 308   *
 309   * @param {Object} a First object to compare.
 310   * @param {Object} b Second object to compare.
 311   *
 312   * @return {number} Comparator result.
 313   */
 314  
 315  
 316  function compareObjectTabbables(a, b) {
 317    var aTabIndex = getTabIndex(a.element);
 318    var bTabIndex = getTabIndex(b.element);
 319  
 320    if (aTabIndex === bTabIndex) {
 321      return a.index - b.index;
 322    }
 323  
 324    return aTabIndex - bTabIndex;
 325  }
 326  
 327  function tabbable_find(context) {
 328    return find(context).filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
 329  }
 330  
 331  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom.js
 332  /**
 333   * External dependencies
 334   */
 335  
 336  /**
 337   * Browser dependencies
 338   */
 339  
 340  var _window = window,
 341      getComputedStyle = _window.getComputedStyle;
 342  var _window$Node = window.Node,
 343      TEXT_NODE = _window$Node.TEXT_NODE,
 344      ELEMENT_NODE = _window$Node.ELEMENT_NODE,
 345      DOCUMENT_POSITION_PRECEDING = _window$Node.DOCUMENT_POSITION_PRECEDING,
 346      DOCUMENT_POSITION_FOLLOWING = _window$Node.DOCUMENT_POSITION_FOLLOWING;
 347  /**
 348   * Returns true if the given selection object is in the forward direction, or
 349   * false otherwise.
 350   *
 351   * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
 352   *
 353   * @param {Selection} selection Selection object to check.
 354   *
 355   * @return {boolean} Whether the selection is forward.
 356   */
 357  
 358  function isSelectionForward(selection) {
 359    var anchorNode = selection.anchorNode,
 360        focusNode = selection.focusNode,
 361        anchorOffset = selection.anchorOffset,
 362        focusOffset = selection.focusOffset;
 363    var position = anchorNode.compareDocumentPosition(focusNode); // Disable reason: `Node#compareDocumentPosition` returns a bitmask value,
 364    // so bitwise operators are intended.
 365  
 366    /* eslint-disable no-bitwise */
 367    // Compare whether anchor node precedes focus node. If focus node (where
 368    // end of selection occurs) is after the anchor node, it is forward.
 369  
 370    if (position & DOCUMENT_POSITION_PRECEDING) {
 371      return false;
 372    }
 373  
 374    if (position & DOCUMENT_POSITION_FOLLOWING) {
 375      return true;
 376    }
 377    /* eslint-enable no-bitwise */
 378    // `compareDocumentPosition` returns 0 when passed the same node, in which
 379    // case compare offsets.
 380  
 381  
 382    if (position === 0) {
 383      return anchorOffset <= focusOffset;
 384    } // This should never be reached, but return true as default case.
 385  
 386  
 387    return true;
 388  }
 389  /**
 390   * Check whether the selection is at the edge of the container. Checks for
 391   * horizontal position by default. Set `onlyVertical` to true to check only
 392   * vertically.
 393   *
 394   * @param {Element} container    Focusable element.
 395   * @param {boolean} isReverse    Set to true to check left, false to check right.
 396   * @param {boolean} onlyVertical Set to true to check only vertical position.
 397   *
 398   * @return {boolean} True if at the edge, false if not.
 399   */
 400  
 401  
 402  function isEdge(container, isReverse, onlyVertical) {
 403    if (Object(external_this_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
 404      if (container.selectionStart !== container.selectionEnd) {
 405        return false;
 406      }
 407  
 408      if (isReverse) {
 409        return container.selectionStart === 0;
 410      }
 411  
 412      return container.value.length === container.selectionStart;
 413    }
 414  
 415    if (!container.isContentEditable) {
 416      return true;
 417    }
 418  
 419    var selection = window.getSelection();
 420  
 421    if (!selection.rangeCount) {
 422      return false;
 423    }
 424  
 425    var range = selection.getRangeAt(0).cloneRange();
 426    var isForward = isSelectionForward(selection);
 427    var isCollapsed = selection.isCollapsed; // Collapse in direction of selection.
 428  
 429    if (!isCollapsed) {
 430      range.collapse(!isForward);
 431    }
 432  
 433    var rangeRect = getRectangleFromRange(range);
 434  
 435    if (!rangeRect) {
 436      return false;
 437    }
 438  
 439    var computedStyle = window.getComputedStyle(container);
 440    var lineHeight = parseInt(computedStyle.lineHeight, 10) || 0; // Only consider the multiline selection at the edge if the direction is
 441    // towards the edge.
 442  
 443    if (!isCollapsed && rangeRect.height > lineHeight && isForward === isReverse) {
 444      return false;
 445    }
 446  
 447    var padding = parseInt(computedStyle["padding".concat(isReverse ? 'Top' : 'Bottom')], 10) || 0; // Calculate a buffer that is half the line height. In some browsers, the
 448    // selection rectangle may not fill the entire height of the line, so we add
 449    // 3/4 the line height to the selection rectangle to ensure that it is well
 450    // over its line boundary.
 451  
 452    var buffer = 3 * parseInt(lineHeight, 10) / 4;
 453    var containerRect = container.getBoundingClientRect();
 454    var verticalEdge = isReverse ? containerRect.top + padding > rangeRect.top - buffer : containerRect.bottom - padding < rangeRect.bottom + buffer;
 455  
 456    if (!verticalEdge) {
 457      return false;
 458    }
 459  
 460    if (onlyVertical) {
 461      return true;
 462    } // In the case of RTL scripts, the horizontal edge is at the opposite side.
 463  
 464  
 465    var direction = computedStyle.direction;
 466    var isReverseDir = direction === 'rtl' ? !isReverse : isReverse; // To calculate the horizontal position, we insert a test range and see if
 467    // this test range has the same horizontal position. This method proves to
 468    // be better than a DOM-based calculation, because it ignores empty text
 469    // nodes and a trailing line break element. In other words, we need to check
 470    // visual positioning, not DOM positioning.
 471  
 472    var x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
 473    var y = isReverse ? containerRect.top + buffer : containerRect.bottom - buffer;
 474    var testRange = hiddenCaretRangeFromPoint(document, x, y, container);
 475  
 476    if (!testRange) {
 477      return false;
 478    }
 479  
 480    var side = isReverseDir ? 'left' : 'right';
 481    var testRect = getRectangleFromRange(testRange); // Allow the position to be 1px off.
 482  
 483    return Math.abs(testRect[side] - rangeRect[side]) <= 1;
 484  }
 485  /**
 486   * Check whether the selection is horizontally at the edge of the container.
 487   *
 488   * @param {Element} container Focusable element.
 489   * @param {boolean} isReverse Set to true to check left, false for right.
 490   *
 491   * @return {boolean} True if at the horizontal edge, false if not.
 492   */
 493  
 494  
 495  function isHorizontalEdge(container, isReverse) {
 496    return isEdge(container, isReverse);
 497  }
 498  /**
 499   * Check whether the selection is vertically at the edge of the container.
 500   *
 501   * @param {Element} container Focusable element.
 502   * @param {boolean} isReverse Set to true to check top, false for bottom.
 503   *
 504   * @return {boolean} True if at the vertical edge, false if not.
 505   */
 506  
 507  function isVerticalEdge(container, isReverse) {
 508    return isEdge(container, isReverse, true);
 509  }
 510  /**
 511   * Get the rectangle of a given Range.
 512   *
 513   * @param {Range} range The range.
 514   *
 515   * @return {DOMRect} The rectangle.
 516   */
 517  
 518  function getRectangleFromRange(range) {
 519    // For uncollapsed ranges, get the rectangle that bounds the contents of the
 520    // range; this a rectangle enclosing the union of the bounding rectangles
 521    // for all the elements in the range.
 522    if (!range.collapsed) {
 523      return range.getBoundingClientRect();
 524    }
 525  
 526    var _range = range,
 527        startContainer = _range.startContainer; // Correct invalid "BR" ranges. The cannot contain any children.
 528  
 529    if (startContainer.nodeName === 'BR') {
 530      var parentNode = startContainer.parentNode;
 531      var index = Array.from(parentNode.childNodes).indexOf(startContainer);
 532      range = document.createRange();
 533      range.setStart(parentNode, index);
 534      range.setEnd(parentNode, index);
 535    }
 536  
 537    var rect = range.getClientRects()[0]; // If the collapsed range starts (and therefore ends) at an element node,
 538    // `getClientRects` can be empty in some browsers. This can be resolved
 539    // by adding a temporary text node with zero-width space to the range.
 540    //
 541    // See: https://stackoverflow.com/a/6847328/995445
 542  
 543    if (!rect) {
 544      var padNode = document.createTextNode("\u200B"); // Do not modify the live range.
 545  
 546      range = range.cloneRange();
 547      range.insertNode(padNode);
 548      rect = range.getClientRects()[0];
 549      padNode.parentNode.removeChild(padNode);
 550    }
 551  
 552    return rect;
 553  }
 554  /**
 555   * Get the rectangle for the selection in a container.
 556   *
 557   * @return {?DOMRect} The rectangle.
 558   */
 559  
 560  function computeCaretRect() {
 561    var selection = window.getSelection();
 562    var range = selection.rangeCount ? selection.getRangeAt(0) : null;
 563  
 564    if (!range) {
 565      return;
 566    }
 567  
 568    return getRectangleFromRange(range);
 569  }
 570  /**
 571   * Places the caret at start or end of a given element.
 572   *
 573   * @param {Element} container Focusable element.
 574   * @param {boolean} isReverse True for end, false for start.
 575   */
 576  
 577  function placeCaretAtHorizontalEdge(container, isReverse) {
 578    if (!container) {
 579      return;
 580    }
 581  
 582    if (Object(external_this_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
 583      container.focus();
 584  
 585      if (isReverse) {
 586        container.selectionStart = container.value.length;
 587        container.selectionEnd = container.value.length;
 588      } else {
 589        container.selectionStart = 0;
 590        container.selectionEnd = 0;
 591      }
 592  
 593      return;
 594    }
 595  
 596    container.focus();
 597  
 598    if (!container.isContentEditable) {
 599      return;
 600    } // Select on extent child of the container, not the container itself. This
 601    // avoids the selection always being `endOffset` of 1 when placed at end,
 602    // where `startContainer`, `endContainer` would always be container itself.
 603  
 604  
 605    var rangeTarget = container[isReverse ? 'lastChild' : 'firstChild']; // If no range target, it implies that the container is empty. Focusing is
 606    // sufficient for caret to be placed correctly.
 607  
 608    if (!rangeTarget) {
 609      return;
 610    }
 611  
 612    var selection = window.getSelection();
 613    var range = document.createRange();
 614    range.selectNodeContents(rangeTarget);
 615    range.collapse(!isReverse);
 616    selection.removeAllRanges();
 617    selection.addRange(range);
 618  }
 619  /**
 620   * Polyfill.
 621   * Get a collapsed range for a given point.
 622   *
 623   * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
 624   *
 625   * @param {Document} doc The document of the range.
 626   * @param {number}    x   Horizontal position within the current viewport.
 627   * @param {number}    y   Vertical position within the current viewport.
 628   *
 629   * @return {?Range} The best range for the given point.
 630   */
 631  
 632  function caretRangeFromPoint(doc, x, y) {
 633    if (doc.caretRangeFromPoint) {
 634      return doc.caretRangeFromPoint(x, y);
 635    }
 636  
 637    if (!doc.caretPositionFromPoint) {
 638      return null;
 639    }
 640  
 641    var point = doc.caretPositionFromPoint(x, y); // If x or y are negative, outside viewport, or there is no text entry node.
 642    // https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
 643  
 644    if (!point) {
 645      return null;
 646    }
 647  
 648    var range = doc.createRange();
 649    range.setStart(point.offsetNode, point.offset);
 650    range.collapse(true);
 651    return range;
 652  }
 653  /**
 654   * Get a collapsed range for a given point.
 655   * Gives the container a temporary high z-index (above any UI).
 656   * This is preferred over getting the UI nodes and set styles there.
 657   *
 658   * @param {Document} doc       The document of the range.
 659   * @param {number}    x         Horizontal position within the current viewport.
 660   * @param {number}    y         Vertical position within the current viewport.
 661   * @param {Element}  container Container in which the range is expected to be found.
 662   *
 663   * @return {?Range} The best range for the given point.
 664   */
 665  
 666  
 667  function hiddenCaretRangeFromPoint(doc, x, y, container) {
 668    var originalZIndex = container.style.zIndex;
 669    var originalPosition = container.style.position; // A z-index only works if the element position is not static.
 670  
 671    container.style.zIndex = '10000';
 672    container.style.position = 'relative';
 673    var range = caretRangeFromPoint(doc, x, y);
 674    container.style.zIndex = originalZIndex;
 675    container.style.position = originalPosition;
 676    return range;
 677  }
 678  /**
 679   * Places the caret at the top or bottom of a given element.
 680   *
 681   * @param {Element} container           Focusable element.
 682   * @param {boolean} isReverse           True for bottom, false for top.
 683   * @param {DOMRect} [rect]              The rectangle to position the caret with.
 684   * @param {boolean} [mayUseScroll=true] True to allow scrolling, false to disallow.
 685   */
 686  
 687  
 688  function placeCaretAtVerticalEdge(container, isReverse, rect) {
 689    var mayUseScroll = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
 690  
 691    if (!container) {
 692      return;
 693    }
 694  
 695    if (!rect || !container.isContentEditable) {
 696      placeCaretAtHorizontalEdge(container, isReverse);
 697      return;
 698    } // Offset by a buffer half the height of the caret rect. This is needed
 699    // because caretRangeFromPoint may default to the end of the selection if
 700    // offset is too close to the edge. It's unclear how to precisely calculate
 701    // this threshold; it may be the padded area of some combination of line
 702    // height, caret height, and font size. The buffer offset is effectively
 703    // equivalent to a point at half the height of a line of text.
 704  
 705  
 706    var buffer = rect.height / 2;
 707    var editableRect = container.getBoundingClientRect();
 708    var x = rect.left;
 709    var y = isReverse ? editableRect.bottom - buffer : editableRect.top + buffer;
 710    var range = hiddenCaretRangeFromPoint(document, x, y, container);
 711  
 712    if (!range || !container.contains(range.startContainer)) {
 713      if (mayUseScroll && (!range || !range.startContainer || !range.startContainer.contains(container))) {
 714        // Might be out of view.
 715        // Easier than attempting to calculate manually.
 716        container.scrollIntoView(isReverse);
 717        placeCaretAtVerticalEdge(container, isReverse, rect, false);
 718        return;
 719      }
 720  
 721      placeCaretAtHorizontalEdge(container, isReverse);
 722      return;
 723    }
 724  
 725    var selection = window.getSelection();
 726    selection.removeAllRanges();
 727    selection.addRange(range);
 728    container.focus(); // Editable was already focussed, it goes back to old range...
 729    // This fixes it.
 730  
 731    selection.removeAllRanges();
 732    selection.addRange(range);
 733  }
 734  /**
 735   * Check whether the given element is a text field, where text field is defined
 736   * by the ability to select within the input, or that it is contenteditable.
 737   *
 738   * See: https://html.spec.whatwg.org/#textFieldSelection
 739   *
 740   * @param {HTMLElement} element The HTML element.
 741   *
 742   * @return {boolean} True if the element is an text field, false if not.
 743   */
 744  
 745  function isTextField(element) {
 746    try {
 747      var nodeName = element.nodeName,
 748          selectionStart = element.selectionStart,
 749          contentEditable = element.contentEditable;
 750      return nodeName === 'INPUT' && selectionStart !== null || nodeName === 'TEXTAREA' || contentEditable === 'true';
 751    } catch (error) {
 752      // Safari throws an exception when trying to get `selectionStart`
 753      // on non-text <input> elements (which, understandably, don't
 754      // have the text selection API). We catch this via a try/catch
 755      // block, as opposed to a more explicit check of the element's
 756      // input types, because of Safari's non-standard behavior. This
 757      // also means we don't have to worry about the list of input
 758      // types that support `selectionStart` changing as the HTML spec
 759      // evolves over time.
 760      return false;
 761    }
 762  }
 763  /**
 764   * Check wether the current document has a selection.
 765   * This checks both for focus in an input field and general text selection.
 766   *
 767   * @return {boolean} True if there is selection, false if not.
 768   */
 769  
 770  function documentHasSelection() {
 771    if (isTextField(document.activeElement)) {
 772      return true;
 773    }
 774  
 775    var selection = window.getSelection();
 776    var range = selection.rangeCount ? selection.getRangeAt(0) : null;
 777    return range && !range.collapsed;
 778  }
 779  /**
 780   * Check whether the contents of the element have been entirely selected.
 781   * Returns true if there is no possibility of selection.
 782   *
 783   * @param {Element} element The element to check.
 784   *
 785   * @return {boolean} True if entirely selected, false if not.
 786   */
 787  
 788  function isEntirelySelected(element) {
 789    if (Object(external_this_lodash_["includes"])(['INPUT', 'TEXTAREA'], element.nodeName)) {
 790      return element.selectionStart === 0 && element.value.length === element.selectionEnd;
 791    }
 792  
 793    if (!element.isContentEditable) {
 794      return true;
 795    }
 796  
 797    var selection = window.getSelection();
 798    var range = selection.rangeCount ? selection.getRangeAt(0) : null;
 799  
 800    if (!range) {
 801      return true;
 802    }
 803  
 804    var startContainer = range.startContainer,
 805        endContainer = range.endContainer,
 806        startOffset = range.startOffset,
 807        endOffset = range.endOffset;
 808  
 809    if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
 810      return true;
 811    }
 812  
 813    var lastChild = element.lastChild;
 814    var lastChildContentLength = lastChild.nodeType === TEXT_NODE ? lastChild.data.length : lastChild.childNodes.length;
 815    return startContainer === element.firstChild && endContainer === element.lastChild && startOffset === 0 && endOffset === lastChildContentLength;
 816  }
 817  /**
 818   * Given a DOM node, finds the closest scrollable container node.
 819   *
 820   * @param {Element} node Node from which to start.
 821   *
 822   * @return {?Element} Scrollable container node, if found.
 823   */
 824  
 825  function getScrollContainer(node) {
 826    if (!node) {
 827      return;
 828    } // Scrollable if scrollable height exceeds displayed...
 829  
 830  
 831    if (node.scrollHeight > node.clientHeight) {
 832      // ...except when overflow is defined to be hidden or visible
 833      var _window$getComputedSt = window.getComputedStyle(node),
 834          overflowY = _window$getComputedSt.overflowY;
 835  
 836      if (/(auto|scroll)/.test(overflowY)) {
 837        return node;
 838      }
 839    } // Continue traversing
 840  
 841  
 842    return getScrollContainer(node.parentNode);
 843  }
 844  /**
 845   * Returns the closest positioned element, or null under any of the conditions
 846   * of the offsetParent specification. Unlike offsetParent, this function is not
 847   * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).
 848   *
 849   * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
 850   *
 851   * @param {Node} node Node from which to find offset parent.
 852   *
 853   * @return {?Node} Offset parent.
 854   */
 855  
 856  function getOffsetParent(node) {
 857    // Cannot retrieve computed style or offset parent only anything other than
 858    // an element node, so find the closest element node.
 859    var closestElement;
 860  
 861    while (closestElement = node.parentNode) {
 862      if (closestElement.nodeType === ELEMENT_NODE) {
 863        break;
 864      }
 865    }
 866  
 867    if (!closestElement) {
 868      return null;
 869    } // If the closest element is already positioned, return it, as offsetParent
 870    // does not otherwise consider the node itself.
 871  
 872  
 873    if (getComputedStyle(closestElement).position !== 'static') {
 874      return closestElement;
 875    }
 876  
 877    return closestElement.offsetParent;
 878  }
 879  /**
 880   * Given two DOM nodes, replaces the former with the latter in the DOM.
 881   *
 882   * @param {Element} processedNode Node to be removed.
 883   * @param {Element} newNode       Node to be inserted in its place.
 884   * @return {void}
 885   */
 886  
 887  function replace(processedNode, newNode) {
 888    insertAfter(newNode, processedNode.parentNode);
 889    remove(processedNode);
 890  }
 891  /**
 892   * Given a DOM node, removes it from the DOM.
 893   *
 894   * @param {Element} node Node to be removed.
 895   * @return {void}
 896   */
 897  
 898  function remove(node) {
 899    node.parentNode.removeChild(node);
 900  }
 901  /**
 902   * Given two DOM nodes, inserts the former in the DOM as the next sibling of
 903   * the latter.
 904   *
 905   * @param {Element} newNode       Node to be inserted.
 906   * @param {Element} referenceNode Node after which to perform the insertion.
 907   * @return {void}
 908   */
 909  
 910  function insertAfter(newNode, referenceNode) {
 911    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
 912  }
 913  /**
 914   * Unwrap the given node. This means any child nodes are moved to the parent.
 915   *
 916   * @param {Node} node The node to unwrap.
 917   *
 918   * @return {void}
 919   */
 920  
 921  function unwrap(node) {
 922    var parent = node.parentNode;
 923  
 924    while (node.firstChild) {
 925      parent.insertBefore(node.firstChild, node);
 926    }
 927  
 928    parent.removeChild(node);
 929  }
 930  /**
 931   * Replaces the given node with a new node with the given tag name.
 932   *
 933   * @param {Element}  node    The node to replace
 934   * @param {string}   tagName The new tag name.
 935   *
 936   * @return {Element} The new node.
 937   */
 938  
 939  function replaceTag(node, tagName) {
 940    var newNode = node.ownerDocument.createElement(tagName);
 941  
 942    while (node.firstChild) {
 943      newNode.appendChild(node.firstChild);
 944    }
 945  
 946    node.parentNode.replaceChild(newNode, node);
 947    return newNode;
 948  }
 949  /**
 950   * Wraps the given node with a new node with the given tag name.
 951   *
 952   * @param {Element} newNode       The node to insert.
 953   * @param {Element} referenceNode The node to wrap.
 954   */
 955  
 956  function wrap(newNode, referenceNode) {
 957    referenceNode.parentNode.insertBefore(newNode, referenceNode);
 958    newNode.appendChild(referenceNode);
 959  }
 960  
 961  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/index.js
 962  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "focus", function() { return build_module_focus; });
 963  /* concated harmony reexport isHorizontalEdge */__webpack_require__.d(__webpack_exports__, "isHorizontalEdge", function() { return isHorizontalEdge; });
 964  /* concated harmony reexport isVerticalEdge */__webpack_require__.d(__webpack_exports__, "isVerticalEdge", function() { return isVerticalEdge; });
 965  /* concated harmony reexport getRectangleFromRange */__webpack_require__.d(__webpack_exports__, "getRectangleFromRange", function() { return getRectangleFromRange; });
 966  /* concated harmony reexport computeCaretRect */__webpack_require__.d(__webpack_exports__, "computeCaretRect", function() { return computeCaretRect; });
 967  /* concated harmony reexport placeCaretAtHorizontalEdge */__webpack_require__.d(__webpack_exports__, "placeCaretAtHorizontalEdge", function() { return placeCaretAtHorizontalEdge; });
 968  /* concated harmony reexport placeCaretAtVerticalEdge */__webpack_require__.d(__webpack_exports__, "placeCaretAtVerticalEdge", function() { return placeCaretAtVerticalEdge; });
 969  /* concated harmony reexport isTextField */__webpack_require__.d(__webpack_exports__, "isTextField", function() { return isTextField; });
 970  /* concated harmony reexport documentHasSelection */__webpack_require__.d(__webpack_exports__, "documentHasSelection", function() { return documentHasSelection; });
 971  /* concated harmony reexport isEntirelySelected */__webpack_require__.d(__webpack_exports__, "isEntirelySelected", function() { return isEntirelySelected; });
 972  /* concated harmony reexport getScrollContainer */__webpack_require__.d(__webpack_exports__, "getScrollContainer", function() { return getScrollContainer; });
 973  /* concated harmony reexport getOffsetParent */__webpack_require__.d(__webpack_exports__, "getOffsetParent", function() { return getOffsetParent; });
 974  /* concated harmony reexport replace */__webpack_require__.d(__webpack_exports__, "replace", function() { return replace; });
 975  /* concated harmony reexport remove */__webpack_require__.d(__webpack_exports__, "remove", function() { return remove; });
 976  /* concated harmony reexport insertAfter */__webpack_require__.d(__webpack_exports__, "insertAfter", function() { return insertAfter; });
 977  /* concated harmony reexport unwrap */__webpack_require__.d(__webpack_exports__, "unwrap", function() { return unwrap; });
 978  /* concated harmony reexport replaceTag */__webpack_require__.d(__webpack_exports__, "replaceTag", function() { return replaceTag; });
 979  /* concated harmony reexport wrap */__webpack_require__.d(__webpack_exports__, "wrap", function() { return wrap; });
 980  /**
 981   * Internal dependencies
 982   */
 983  
 984  
 985  /**
 986   * Object grouping `focusable` and `tabbable` utils
 987   * under the keys with the same name.
 988   */
 989  
 990  var build_module_focus = {
 991    focusable: focusable_namespaceObject,
 992    tabbable: tabbable_namespaceObject
 993  };
 994  
 995  
 996  
 997  /***/ })
 998  
 999  /******/ });


Generated: Mon Jan 20 01:00:03 2020 Cross-referenced by PHPXref 0.7.1