[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/define property getters */ 8 /******/ (() => { 9 /******/ // define getter functions for harmony exports 10 /******/ __webpack_require__.d = (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 /******/ (() => { 21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 22 /******/ })(); 23 /******/ 24 /************************************************************************/ 25 var __webpack_exports__ = {}; 26 /* harmony export */ __webpack_require__.d(__webpack_exports__, { 27 /* harmony export */ "default": () => (/* binding */ TokenList) 28 /* harmony export */ }); 29 /* wp:polyfill */ 30 /** 31 * A set of tokens. 32 * 33 * @see https://dom.spec.whatwg.org/#domtokenlist 34 */ 35 class TokenList { 36 /** 37 * Constructs a new instance of TokenList. 38 * 39 * @param initialValue Initial value to assign. 40 */ 41 constructor(initialValue = '') { 42 this._currentValue = ''; 43 this._valueAsArray = []; 44 this.value = initialValue; 45 } 46 entries(...args) { 47 return this._valueAsArray.entries(...args); 48 } 49 forEach(...args) { 50 return this._valueAsArray.forEach(...args); 51 } 52 keys(...args) { 53 return this._valueAsArray.keys(...args); 54 } 55 values(...args) { 56 return this._valueAsArray.values(...args); 57 } 58 59 /** 60 * Returns the associated set as string. 61 * 62 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value 63 * 64 * @return Token set as string. 65 */ 66 get value() { 67 return this._currentValue; 68 } 69 70 /** 71 * Replaces the associated set with a new string value. 72 * 73 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value 74 * 75 * @param value New token set as string. 76 */ 77 set value(value) { 78 value = String(value); 79 this._valueAsArray = [...new Set(value.split(/\s+/g).filter(Boolean))]; 80 this._currentValue = this._valueAsArray.join(' '); 81 } 82 83 /** 84 * Returns the number of tokens. 85 * 86 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-length 87 * 88 * @return Number of tokens. 89 */ 90 get length() { 91 return this._valueAsArray.length; 92 } 93 94 /** 95 * Returns the stringified form of the TokenList. 96 * 97 * @see https://dom.spec.whatwg.org/#DOMTokenList-stringification-behavior 98 * @see https://www.ecma-international.org/ecma-262/9.0/index.html#sec-tostring 99 * 100 * @return Token set as string. 101 */ 102 toString() { 103 return this.value; 104 } 105 106 /** 107 * Returns an iterator for the TokenList, iterating items of the set. 108 * 109 * @see https://dom.spec.whatwg.org/#domtokenlist 110 * 111 * @return TokenList iterator. 112 */ 113 *[Symbol.iterator]() { 114 return yield* this._valueAsArray; 115 } 116 117 /** 118 * Returns the token with index `index`. 119 * 120 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-item 121 * 122 * @param index Index at which to return token. 123 * 124 * @return Token at index. 125 */ 126 item(index) { 127 return this._valueAsArray[index]; 128 } 129 130 /** 131 * Returns true if `token` is present, and false otherwise. 132 * 133 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-contains 134 * 135 * @param item Token to test. 136 * 137 * @return Whether token is present. 138 */ 139 contains(item) { 140 return this._valueAsArray.indexOf(item) !== -1; 141 } 142 143 /** 144 * Adds all arguments passed, except those already present. 145 * 146 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-add 147 * 148 * @param items Items to add. 149 */ 150 add(...items) { 151 this.value += ' ' + items.join(' '); 152 } 153 154 /** 155 * Removes arguments passed, if they are present. 156 * 157 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-remove 158 * 159 * @param items Items to remove. 160 */ 161 remove(...items) { 162 this.value = this._valueAsArray.filter(val => !items.includes(val)).join(' '); 163 } 164 165 /** 166 * If `force` is not given, "toggles" `token`, removing it if it’s present 167 * and adding it if it’s not present. If `force` is true, adds token (same 168 * as add()). If force is false, removes token (same as remove()). Returns 169 * true if `token` is now present, and false otherwise. 170 * 171 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-toggle 172 * 173 * @param token Token to toggle. 174 * @param [force] Presence to force. 175 * 176 * @return Whether token is present after toggle. 177 */ 178 toggle(token, force) { 179 if (undefined === force) { 180 force = !this.contains(token); 181 } 182 if (force) { 183 this.add(token); 184 } else { 185 this.remove(token); 186 } 187 return force; 188 } 189 190 /** 191 * Replaces `token` with `newToken`. Returns true if `token` was replaced 192 * with `newToken`, and false otherwise. 193 * 194 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-replace 195 * 196 * @param token Token to replace with `newToken`. 197 * @param newToken Token to use in place of `token`. 198 * 199 * @return Whether replacement occurred. 200 */ 201 replace(token, newToken) { 202 if (!this.contains(token)) { 203 return false; 204 } 205 this.remove(token); 206 this.add(newToken); 207 return true; 208 } 209 210 /* eslint-disable @typescript-eslint/no-unused-vars */ 211 /** 212 * Returns true if `token` is in the associated attribute’s supported 213 * tokens. Returns false otherwise. 214 * 215 * Always returns `true` in this implementation. 216 * 217 * @param _token 218 * @see https://dom.spec.whatwg.org/#dom-domtokenlist-supports 219 * 220 * @return Whether token is supported. 221 */ 222 supports(_token) { 223 return true; 224 } 225 /* eslint-enable @typescript-eslint/no-unused-vars */ 226 } 227 228 (window.wp = window.wp || {}).tokenList = __webpack_exports__["default"]; 229 /******/ })() 230 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Feb 22 08:20:01 2025 | Cross-referenced by PHPXref |