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


Generated: Fri Sep 25 01:00:03 2020 Cross-referenced by PHPXref 0.7.1