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