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