[ 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 = 416);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 13:
  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  /***/ 14:
 114  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 115  
 116  "use strict";
 117  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 118  function _classCallCheck(instance, Constructor) {
 119    if (!(instance instanceof Constructor)) {
 120      throw new TypeError("Cannot call a class as a function");
 121    }
 122  }
 123  
 124  /***/ }),
 125  
 126  /***/ 2:
 127  /***/ (function(module, exports) {
 128  
 129  (function() { module.exports = this["lodash"]; }());
 130  
 131  /***/ }),
 132  
 133  /***/ 23:
 134  /***/ (function(module, exports) {
 135  
 136  (function() { module.exports = this["regeneratorRuntime"]; }());
 137  
 138  /***/ }),
 139  
 140  /***/ 416:
 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__(23);
 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__(14);
 149  /* harmony import */ var _babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
 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 =
 167  /*#__PURE__*/
 168  function () {
 169    /**
 170     * Constructs a new instance of TokenList.
 171     *
 172     * @param {string} initialValue Initial value to assign.
 173     */
 174    function TokenList() {
 175      var _this = this;
 176  
 177      var initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
 178  
 179      Object(_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(this, TokenList);
 180  
 181      this.value = initialValue;
 182      ['entries', 'forEach', 'keys', 'values'].forEach(function (fn) {
 183        _this[fn] = function () {
 184          var _this$_valueAsArray;
 185  
 186          return (_this$_valueAsArray = _this._valueAsArray)[fn].apply(_this$_valueAsArray, arguments);
 187        };
 188      });
 189    }
 190    /**
 191     * Returns the associated set as string.
 192     *
 193     * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value
 194     *
 195     * @return {string} Token set as string.
 196     */
 197  
 198  
 199    Object(_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"])(TokenList, [{
 200      key: "toString",
 201  
 202      /**
 203       * Returns the stringified form of the TokenList.
 204       *
 205       * @see https://dom.spec.whatwg.org/#DOMTokenList-stringification-behavior
 206       * @see https://www.ecma-international.org/ecma-262/9.0/index.html#sec-tostring
 207       *
 208       * @return {string} Token set as string.
 209       */
 210      value: function toString() {
 211        return this.value;
 212      }
 213      /**
 214       * Returns an iterator for the TokenList, iterating items of the set.
 215       *
 216       * @see https://dom.spec.whatwg.org/#domtokenlist
 217       *
 218       * @return {IterableIterator<string>} TokenList iterator.
 219       */
 220  
 221    }, {
 222      key: Symbol.iterator,
 223      value:
 224      /*#__PURE__*/
 225      _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function value() {
 226        return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function value$(_context) {
 227          while (1) {
 228            switch (_context.prev = _context.next) {
 229              case 0:
 230                return _context.delegateYield(this._valueAsArray, "t0", 1);
 231  
 232              case 1:
 233                return _context.abrupt("return", _context.t0);
 234  
 235              case 2:
 236              case "end":
 237                return _context.stop();
 238            }
 239          }
 240        }, value, this);
 241      })
 242      /**
 243       * Returns the token with index `index`.
 244       *
 245       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-item
 246       *
 247       * @param {number} index Index at which to return token.
 248       *
 249       * @return {string|undefined} Token at index.
 250       */
 251  
 252    }, {
 253      key: "item",
 254      value: function item(index) {
 255        return this._valueAsArray[index];
 256      }
 257      /**
 258       * Returns true if `token` is present, and false otherwise.
 259       *
 260       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-contains
 261       *
 262       * @param {string} item Token to test.
 263       *
 264       * @return {boolean} Whether token is present.
 265       */
 266  
 267    }, {
 268      key: "contains",
 269      value: function contains(item) {
 270        return this._valueAsArray.indexOf(item) !== -1;
 271      }
 272      /**
 273       * Adds all arguments passed, except those already present.
 274       *
 275       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-add
 276       *
 277       * @param {...string} items Items to add.
 278       */
 279  
 280    }, {
 281      key: "add",
 282      value: function add() {
 283        for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
 284          items[_key] = arguments[_key];
 285        }
 286  
 287        this.value += ' ' + items.join(' ');
 288      }
 289      /**
 290       * Removes arguments passed, if they are present.
 291       *
 292       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-remove
 293       *
 294       * @param {...string} items Items to remove.
 295       */
 296  
 297    }, {
 298      key: "remove",
 299      value: function remove() {
 300        for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
 301          items[_key2] = arguments[_key2];
 302        }
 303  
 304        this.value = lodash__WEBPACK_IMPORTED_MODULE_3__["without"].apply(void 0, [this._valueAsArray].concat(items)).join(' ');
 305      }
 306      /**
 307       * If `force` is not given, "toggles" `token`, removing it if it’s present
 308       * and adding it if it’s not present. If `force` is true, adds token (same
 309       * as add()). If force is false, removes token (same as remove()). Returns
 310       * true if `token` is now present, and false otherwise.
 311       *
 312       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
 313       *
 314       * @param {string}  token   Token to toggle.
 315       * @param {boolean} [force] Presence to force.
 316       *
 317       * @return {boolean} Whether token is present after toggle.
 318       */
 319  
 320    }, {
 321      key: "toggle",
 322      value: function toggle(token, force) {
 323        if (undefined === force) {
 324          force = !this.contains(token);
 325        }
 326  
 327        if (force) {
 328          this.add(token);
 329        } else {
 330          this.remove(token);
 331        }
 332  
 333        return force;
 334      }
 335      /**
 336       * Replaces `token` with `newToken`. Returns true if `token` was replaced
 337       * with `newToken`, and false otherwise.
 338       *
 339       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-replace
 340       *
 341       * @param {string} token    Token to replace with `newToken`.
 342       * @param {string} newToken Token to use in place of `token`.
 343       *
 344       * @return {boolean} Whether replacement occurred.
 345       */
 346  
 347    }, {
 348      key: "replace",
 349      value: function replace(token, newToken) {
 350        if (!this.contains(token)) {
 351          return false;
 352        }
 353  
 354        this.remove(token);
 355        this.add(newToken);
 356        return true;
 357      }
 358      /**
 359       * Returns true if `token` is in the associated attribute’s supported
 360       * tokens. Returns false otherwise.
 361       *
 362       * Always returns `true` in this implementation.
 363       *
 364       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-supports
 365       *
 366       * @return {boolean} Whether token is supported.
 367       */
 368  
 369    }, {
 370      key: "supports",
 371      value: function supports() {
 372        return true;
 373      }
 374    }, {
 375      key: "value",
 376      get: function get() {
 377        return this._currentValue;
 378      }
 379      /**
 380       * Replaces the associated set with a new string value.
 381       *
 382       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value
 383       *
 384       * @param {string} value New token set as string.
 385       */
 386      ,
 387      set: function set(value) {
 388        value = String(value);
 389        this._valueAsArray = Object(lodash__WEBPACK_IMPORTED_MODULE_3__["uniq"])(Object(lodash__WEBPACK_IMPORTED_MODULE_3__["compact"])(value.split(/\s+/g)));
 390        this._currentValue = this._valueAsArray.join(' ');
 391      }
 392      /**
 393       * Returns the number of tokens.
 394       *
 395       * @see https://dom.spec.whatwg.org/#dom-domtokenlist-length
 396       *
 397       * @return {number} Number of tokens.
 398       */
 399  
 400    }, {
 401      key: "length",
 402      get: function get() {
 403        return this._valueAsArray.length;
 404      }
 405    }]);
 406  
 407    return TokenList;
 408  }();
 409  
 410  
 411  
 412  
 413  /***/ })
 414  
 415  /******/ })["default"];


Generated: Thu Apr 2 01:00:03 2020 Cross-referenced by PHPXref 0.7.1