[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /******/ (function() { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/define property getters */ 8 /******/ !function() { 9 /******/ // define getter functions for harmony exports 10 /******/ __webpack_require__.d = function(exports, definition) { 11 /******/ for(var key in definition) { 12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14 /******/ } 15 /******/ } 16 /******/ }; 17 /******/ }(); 18 /******/ 19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 20 /******/ !function() { 21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 22 /******/ }(); 23 /******/ 24 /************************************************************************/ 25 var __webpack_exports__ = {}; 26 27 // EXPORTS 28 __webpack_require__.d(__webpack_exports__, { 29 "default": function() { return /* binding */ TokenList; } 30 }); 31 32 ;// CONCATENATED MODULE: external "lodash" 33 var external_lodash_namespaceObject = window["lodash"]; 34 ;// CONCATENATED MODULE: ./node_modules/@wordpress/token-list/build-module/index.js 35 /** 36 * External dependencies 37 */ 38 39 /** 40 * A set of tokens. 41 * 42 * @see https://dom.spec.whatwg.org/#domtokenlist 43 */ 44 45 class TokenList { 46 /** 47 * Constructs a new instance of TokenList. 48 * 49 * @param {string} initialValue Initial value to assign. 50 */ 51 constructor() { 52 let initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 53 this.value = initialValue; // Disable reason: These are type hints on the class. 54 55 /* eslint-disable no-unused-expressions */ 56 57 /** @type {string} */ 58 59 this._currentValue; 60 /** @type {string[]} */ 61 62 this._valueAsArray; 63 /* eslint-enable no-unused-expressions */ 64 } 65 /** 66 * @param {Parameters<Array<string>['entries']>} args 67 */ 68 69 70 entries() { 71 return this._valueAsArray.entries(...arguments); 72 } 73 /** 74 * @param {Parameters<Array<string>['forEach']>} args 75 */ 76 77 78 forEach() { 79 return this._valueAsArray.forEach(...arguments); 80 } 81 /** 82 * @param {Parameters<Array<string>['keys']>} args 83 */ 84 85 86 keys() { 87 return this._valueAsArray.keys(...arguments); 88 } 89 /** 90 * @param {Parameters<Array<string>['values']>} args 91 */ 92 93 94 values() { 95 return this._valueAsArray.values(...arguments); 96 } 97 /** 98 * Returns the associated set as string. 99 * 100 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value 101 * 102 * @return {string} Token set as string. 103 */ 104 105 106 get value() { 107 return this._currentValue; 108 } 109 /** 110 * Replaces the associated set with a new string value. 111 * 112 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value 113 * 114 * @param {string} value New token set as string. 115 */ 116 117 118 set value(value) { 119 value = String(value); 120 this._valueAsArray = (0,external_lodash_namespaceObject.uniq)((0,external_lodash_namespaceObject.compact)(value.split(/\s+/g))); 121 this._currentValue = this._valueAsArray.join(' '); 122 } 123 /** 124 * Returns the number of tokens. 125 * 126 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-length 127 * 128 * @return {number} Number of tokens. 129 */ 130 131 132 get length() { 133 return this._valueAsArray.length; 134 } 135 /** 136 * Returns the stringified form of the TokenList. 137 * 138 * @see https://dom.spec.whatwg.org/#DOMTokenList-stringification-behavior 139 * @see https://www.ecma-international.org/ecma-262/9.0/index.html#sec-tostring 140 * 141 * @return {string} Token set as string. 142 */ 143 144 145 toString() { 146 return this.value; 147 } 148 /** 149 * Returns an iterator for the TokenList, iterating items of the set. 150 * 151 * @see https://dom.spec.whatwg.org/#domtokenlist 152 * 153 * @return {IterableIterator<string>} TokenList iterator. 154 */ 155 156 157 *[Symbol.iterator]() { 158 return yield* this._valueAsArray; 159 } 160 /** 161 * Returns the token with index `index`. 162 * 163 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-item 164 * 165 * @param {number} index Index at which to return token. 166 * 167 * @return {string|undefined} Token at index. 168 */ 169 170 171 item(index) { 172 return this._valueAsArray[index]; 173 } 174 /** 175 * Returns true if `token` is present, and false otherwise. 176 * 177 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-contains 178 * 179 * @param {string} item Token to test. 180 * 181 * @return {boolean} Whether token is present. 182 */ 183 184 185 contains(item) { 186 return this._valueAsArray.indexOf(item) !== -1; 187 } 188 /** 189 * Adds all arguments passed, except those already present. 190 * 191 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-add 192 * 193 * @param {...string} items Items to add. 194 */ 195 196 197 add() { 198 for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) { 199 items[_key] = arguments[_key]; 200 } 201 202 this.value += ' ' + items.join(' '); 203 } 204 /** 205 * Removes arguments passed, if they are present. 206 * 207 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-remove 208 * 209 * @param {...string} items Items to remove. 210 */ 211 212 213 remove() { 214 for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 215 items[_key2] = arguments[_key2]; 216 } 217 218 this.value = (0,external_lodash_namespaceObject.without)(this._valueAsArray, ...items).join(' '); 219 } 220 /** 221 * If `force` is not given, "toggles" `token`, removing it if it’s present 222 * and adding it if it’s not present. If `force` is true, adds token (same 223 * as add()). If force is false, removes token (same as remove()). Returns 224 * true if `token` is now present, and false otherwise. 225 * 226 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-toggle 227 * 228 * @param {string} token Token to toggle. 229 * @param {boolean} [force] Presence to force. 230 * 231 * @return {boolean} Whether token is present after toggle. 232 */ 233 234 235 toggle(token, force) { 236 if (undefined === force) { 237 force = !this.contains(token); 238 } 239 240 if (force) { 241 this.add(token); 242 } else { 243 this.remove(token); 244 } 245 246 return force; 247 } 248 /** 249 * Replaces `token` with `newToken`. Returns true if `token` was replaced 250 * with `newToken`, and false otherwise. 251 * 252 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-replace 253 * 254 * @param {string} token Token to replace with `newToken`. 255 * @param {string} newToken Token to use in place of `token`. 256 * 257 * @return {boolean} Whether replacement occurred. 258 */ 259 260 261 replace(token, newToken) { 262 if (!this.contains(token)) { 263 return false; 264 } 265 266 this.remove(token); 267 this.add(newToken); 268 return true; 269 } 270 /** 271 * Returns true if `token` is in the associated attribute’s supported 272 * tokens. Returns false otherwise. 273 * 274 * Always returns `true` in this implementation. 275 * 276 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-supports 277 * 278 * @return {boolean} Whether token is supported. 279 */ 280 281 282 supports() { 283 return true; 284 } 285 286 } 287 288 (window.wp = window.wp || {}).tokenList = __webpack_exports__["default"]; 289 /******/ })() 290 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |