[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> token-list.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["tokenList"] =
   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 = 447);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 16:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["regeneratorRuntime"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 2:
  98  /***/ (function(module, exports) {
  99  
 100  (function() { module.exports = window["lodash"]; }());
 101  
 102  /***/ }),
 103  
 104  /***/ 25:
 105  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 106  
 107  "use strict";
 108  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 109  function _classCallCheck(instance, Constructor) {
 110    if (!(instance instanceof Constructor)) {
 111      throw new TypeError("Cannot call a class as a function");
 112    }
 113  }
 114  
 115  /***/ }),
 116  
 117  /***/ 26:
 118  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 119  
 120  "use strict";
 121  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
 122  function _defineProperties(target, props) {
 123    for (var i = 0; i < props.length; i++) {
 124      var descriptor = props[i];
 125      descriptor.enumerable = descriptor.enumerable || false;
 126      descriptor.configurable = true;
 127      if ("value" in descriptor) descriptor.writable = true;
 128      Object.defineProperty(target, descriptor.key, descriptor);
 129    }
 130  }
 131  
 132  function _createClass(Constructor, protoProps, staticProps) {
 133    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 134    if (staticProps) _defineProperties(Constructor, staticProps);
 135    return Constructor;
 136  }
 137  
 138  /***/ }),
 139  
 140  /***/ 447:
 141  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 142  
 143  "use strict";
 144  __webpack_require__.r(__webpack_exports__);
 145  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TokenList; });
 146  /* harmony import */ var _babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
 147  /* harmony import */ var _babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(26);
 148  /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
 149  /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__);
 150  /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
 151  /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_3__);
 152  
 153  
 154  
 155  
 156  /**
 157   * External dependencies
 158   */
 159  
 160  /**
 161   * A set of tokens.
 162   *
 163   * @see https://dom.spec.whatwg.org/#domtokenlist
 164   */
 165  
 166  var TokenList = /*#__PURE__*/function () {
 167    /**
 168     * Constructs a new instance of TokenList.
 169     *
 170     * @param {string} initialValue Initial value to assign.
 171     */
 172    function TokenList() {
 173      var initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
 174  
 175      Object(_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(this, TokenList);
 176  
 177      this.value = initialValue; // Disable reason: These are type hints on the class.
 178  
 179      /* eslint-disable no-unused-expressions */
 180  
 181      /** @type {string} */
 182  
 183      this._currentValue;
 184      /** @type {string[]} */
 185  
 186      this._valueAsArray;
 187      /* eslint-enable no-unused-expressions */
 188    }
 189    /**
 190     * @param {Parameters<Array<string>['entries']>} args
 191     */
 192  
 193  
 194    Object(_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(TokenList, [{
 195      key: "entries",
 196      value: function entries() {
 197        var _this$_valueAsArray;
 198  
 199        return (_this$_valueAsArray = this._valueAsArray).entries.apply(_this$_valueAsArray, arguments);
 200      }
 201      /**
 202       * @param {Parameters<Array<string>['forEach']>} args
 203       */
 204  
 205    }, {
 206      key: "forEach",
 207      value: function forEach() {
 208        var _this$_valueAsArray2;
 209  
 210        return (_this$_valueAsArray2 = this._valueAsArray).forEach.apply(_this$_valueAsArray2, arguments);
 211      }
 212      /**
 213       * @param {Parameters<Array<string>['keys']>} args
 214       */
 215  
 216    }, {
 217      key: "keys",
 218      value: function keys() {
 219        var _this$_valueAsArray3;
 220  
 221        return (_this$_valueAsArray3 = this._valueAsArray).keys.apply(_this$_valueAsArray3, arguments);
 222      }
 223      /**
 224       * @param {Parameters<Array<string>['values']>} args
 225       */
 226  
 227    }, {
 228      key: "values",
 229      value: function values() {
 230        var _this$_valueAsArray4;
 231  
 232        return (_this$_valueAsArray4 = this._valueAsArray).values.apply(_this$_valueAsArray4, arguments);
 233      }
 234      /**
 235       * Returns the associated set as string.
 236       *
 237       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value
 238       *
 239       * @return {string} Token set as string.
 240       */
 241  
 242    }, {
 243      key: "value",
 244      get: function get() {
 245        return this._currentValue;
 246      }
 247      /**
 248       * Replaces the associated set with a new string value.
 249       *
 250       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value
 251       *
 252       * @param {string} value New token set as string.
 253       */
 254      ,
 255      set: function set(value) {
 256        value = String(value);
 257        this._valueAsArray = Object(lodash__WEBPACK_IMPORTED_MODULE_3__["uniq"])(Object(lodash__WEBPACK_IMPORTED_MODULE_3__["compact"])(value.split(/\s+/g)));
 258        this._currentValue = this._valueAsArray.join(' ');
 259      }
 260      /**
 261       * Returns the number of tokens.
 262       *
 263       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-length
 264       *
 265       * @return {number} Number of tokens.
 266       */
 267  
 268    }, {
 269      key: "length",
 270      get: function get() {
 271        return this._valueAsArray.length;
 272      }
 273      /**
 274       * Returns the stringified form of the TokenList.
 275       *
 276       * @see https://dom.spec.whatwg.org/#DOMTokenList-stringification-behavior
 277       * @see https://www.ecma-international.org/ecma-262/9.0/index.html#sec-tostring
 278       *
 279       * @return {string} Token set as string.
 280       */
 281  
 282    }, {
 283      key: "toString",
 284      value: function toString() {
 285        return this.value;
 286      }
 287      /**
 288       * Returns an iterator for the TokenList, iterating items of the set.
 289       *
 290       * @see https://dom.spec.whatwg.org/#domtokenlist
 291       *
 292       * @return {IterableIterator<string>} TokenList iterator.
 293       */
 294  
 295    }, {
 296      key: Symbol.iterator,
 297      value:
 298      /*#__PURE__*/
 299      _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function value() {
 300        return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function value$(_context) {
 301          while (1) {
 302            switch (_context.prev = _context.next) {
 303              case 0:
 304                return _context.delegateYield(this._valueAsArray, "t0", 1);
 305  
 306              case 1:
 307                return _context.abrupt("return", _context.t0);
 308  
 309              case 2:
 310              case "end":
 311                return _context.stop();
 312            }
 313          }
 314        }, value, this);
 315      })
 316      /**
 317       * Returns the token with index `index`.
 318       *
 319       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-item
 320       *
 321       * @param {number} index Index at which to return token.
 322       *
 323       * @return {string|undefined} Token at index.
 324       */
 325  
 326    }, {
 327      key: "item",
 328      value: function item(index) {
 329        return this._valueAsArray[index];
 330      }
 331      /**
 332       * Returns true if `token` is present, and false otherwise.
 333       *
 334       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-contains
 335       *
 336       * @param {string} item Token to test.
 337       *
 338       * @return {boolean} Whether token is present.
 339       */
 340  
 341    }, {
 342      key: "contains",
 343      value: function contains(item) {
 344        return this._valueAsArray.indexOf(item) !== -1;
 345      }
 346      /**
 347       * Adds all arguments passed, except those already present.
 348       *
 349       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-add
 350       *
 351       * @param {...string} items Items to add.
 352       */
 353  
 354    }, {
 355      key: "add",
 356      value: function add() {
 357        for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
 358          items[_key] = arguments[_key];
 359        }
 360  
 361        this.value += ' ' + items.join(' ');
 362      }
 363      /**
 364       * Removes arguments passed, if they are present.
 365       *
 366       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-remove
 367       *
 368       * @param {...string} items Items to remove.
 369       */
 370  
 371    }, {
 372      key: "remove",
 373      value: function remove() {
 374        for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
 375          items[_key2] = arguments[_key2];
 376        }
 377  
 378        this.value = lodash__WEBPACK_IMPORTED_MODULE_3__["without"].apply(void 0, [this._valueAsArray].concat(items)).join(' ');
 379      }
 380      /**
 381       * If `force` is not given, "toggles" `token`, removing it if it’s present
 382       * and adding it if it’s not present. If `force` is true, adds token (same
 383       * as add()). If force is false, removes token (same as remove()). Returns
 384       * true if `token` is now present, and false otherwise.
 385       *
 386       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
 387       *
 388       * @param {string}  token   Token to toggle.
 389       * @param {boolean} [force] Presence to force.
 390       *
 391       * @return {boolean} Whether token is present after toggle.
 392       */
 393  
 394    }, {
 395      key: "toggle",
 396      value: function toggle(token, force) {
 397        if (undefined === force) {
 398          force = !this.contains(token);
 399        }
 400  
 401        if (force) {
 402          this.add(token);
 403        } else {
 404          this.remove(token);
 405        }
 406  
 407        return force;
 408      }
 409      /**
 410       * Replaces `token` with `newToken`. Returns true if `token` was replaced
 411       * with `newToken`, and false otherwise.
 412       *
 413       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-replace
 414       *
 415       * @param {string} token    Token to replace with `newToken`.
 416       * @param {string} newToken Token to use in place of `token`.
 417       *
 418       * @return {boolean} Whether replacement occurred.
 419       */
 420  
 421    }, {
 422      key: "replace",
 423      value: function replace(token, newToken) {
 424        if (!this.contains(token)) {
 425          return false;
 426        }
 427  
 428        this.remove(token);
 429        this.add(newToken);
 430        return true;
 431      }
 432      /**
 433       * Returns true if `token` is in the associated attribute’s supported
 434       * tokens. Returns false otherwise.
 435       *
 436       * Always returns `true` in this implementation.
 437       *
 438       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-supports
 439       *
 440       * @return {boolean} Whether token is supported.
 441       */
 442  
 443    }, {
 444      key: "supports",
 445      value: function supports() {
 446        return true;
 447      }
 448    }]);
 449  
 450    return TokenList;
 451  }();
 452  
 453  
 454  
 455  
 456  /***/ })
 457  
 458  /******/ })["default"];


Generated: Sat May 15 01:00:05 2021 Cross-referenced by PHPXref 0.7.1