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


Generated: Sun Sep 15 01:00:03 2019 Cross-referenced by PHPXref 0.7.1