/ cloudformation-templates / node_modules / jsdom / lib / jsdom / living / generated / HTMLScriptElement.js
HTMLScriptElement.js
1 "use strict"; 2 3 const conversions = require("webidl-conversions"); 4 const utils = require("./utils.js"); 5 6 const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; 7 const parseURLToResultingURLRecord_helpers_document_base_url = 8 require("../helpers/document-base-url.js").parseURLToResultingURLRecord; 9 const serializeURLwhatwg_url = require("whatwg-url").serializeURL; 10 const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; 11 const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; 12 const implSymbol = utils.implSymbol; 13 const ctorRegistrySymbol = utils.ctorRegistrySymbol; 14 const HTMLElement = require("./HTMLElement.js"); 15 16 const interfaceName = "HTMLScriptElement"; 17 18 exports.is = value => { 19 return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; 20 }; 21 exports.isImpl = value => { 22 return utils.isObject(value) && value instanceof Impl.implementation; 23 }; 24 exports.convert = (value, { context = "The provided value" } = {}) => { 25 if (exports.is(value)) { 26 return utils.implForWrapper(value); 27 } 28 throw new TypeError(`${context} is not of type 'HTMLScriptElement'.`); 29 }; 30 31 function makeWrapper(globalObject) { 32 if (globalObject[ctorRegistrySymbol] === undefined) { 33 throw new Error("Internal error: invalid global object"); 34 } 35 36 const ctor = globalObject[ctorRegistrySymbol]["HTMLScriptElement"]; 37 if (ctor === undefined) { 38 throw new Error("Internal error: constructor HTMLScriptElement is not installed on the passed global object"); 39 } 40 41 return Object.create(ctor.prototype); 42 } 43 44 exports.create = (globalObject, constructorArgs, privateData) => { 45 const wrapper = makeWrapper(globalObject); 46 return exports.setup(wrapper, globalObject, constructorArgs, privateData); 47 }; 48 49 exports.createImpl = (globalObject, constructorArgs, privateData) => { 50 const wrapper = exports.create(globalObject, constructorArgs, privateData); 51 return utils.implForWrapper(wrapper); 52 }; 53 54 exports._internalSetup = (wrapper, globalObject) => { 55 HTMLElement._internalSetup(wrapper, globalObject); 56 }; 57 58 exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { 59 privateData.wrapper = wrapper; 60 61 exports._internalSetup(wrapper, globalObject); 62 Object.defineProperty(wrapper, implSymbol, { 63 value: new Impl.implementation(globalObject, constructorArgs, privateData), 64 configurable: true 65 }); 66 67 wrapper[implSymbol][utils.wrapperSymbol] = wrapper; 68 if (Impl.init) { 69 Impl.init(wrapper[implSymbol]); 70 } 71 return wrapper; 72 }; 73 74 exports.new = globalObject => { 75 const wrapper = makeWrapper(globalObject); 76 77 exports._internalSetup(wrapper, globalObject); 78 Object.defineProperty(wrapper, implSymbol, { 79 value: Object.create(Impl.implementation.prototype), 80 configurable: true 81 }); 82 83 wrapper[implSymbol][utils.wrapperSymbol] = wrapper; 84 if (Impl.init) { 85 Impl.init(wrapper[implSymbol]); 86 } 87 return wrapper[implSymbol]; 88 }; 89 90 const exposed = new Set(["Window"]); 91 92 exports.install = (globalObject, globalNames) => { 93 if (!globalNames.some(globalName => exposed.has(globalName))) { 94 return; 95 } 96 97 if (globalObject.HTMLElement === undefined) { 98 throw new Error("Internal error: attempting to evaluate HTMLScriptElement before HTMLElement"); 99 } 100 class HTMLScriptElement extends globalObject.HTMLElement { 101 constructor() { 102 return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); 103 } 104 105 get src() { 106 const esValue = this !== null && this !== undefined ? this : globalObject; 107 108 if (!exports.is(esValue)) { 109 throw new TypeError("'get src' called on an object that is not a valid instance of HTMLScriptElement."); 110 } 111 112 ceReactionsPreSteps_helpers_custom_elements(globalObject); 113 try { 114 const value = esValue[implSymbol].getAttributeNS(null, "src"); 115 if (value === null) { 116 return ""; 117 } 118 const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( 119 value, 120 esValue[implSymbol]._ownerDocument 121 ); 122 if (urlRecord !== null) { 123 return serializeURLwhatwg_url(urlRecord); 124 } 125 return conversions.USVString(value); 126 } finally { 127 ceReactionsPostSteps_helpers_custom_elements(globalObject); 128 } 129 } 130 131 set src(V) { 132 const esValue = this !== null && this !== undefined ? this : globalObject; 133 134 if (!exports.is(esValue)) { 135 throw new TypeError("'set src' called on an object that is not a valid instance of HTMLScriptElement."); 136 } 137 138 V = conversions["USVString"](V, { 139 context: "Failed to set the 'src' property on 'HTMLScriptElement': The provided value" 140 }); 141 142 ceReactionsPreSteps_helpers_custom_elements(globalObject); 143 try { 144 esValue[implSymbol].setAttributeNS(null, "src", V); 145 } finally { 146 ceReactionsPostSteps_helpers_custom_elements(globalObject); 147 } 148 } 149 150 get type() { 151 const esValue = this !== null && this !== undefined ? this : globalObject; 152 153 if (!exports.is(esValue)) { 154 throw new TypeError("'get type' called on an object that is not a valid instance of HTMLScriptElement."); 155 } 156 157 ceReactionsPreSteps_helpers_custom_elements(globalObject); 158 try { 159 const value = esValue[implSymbol].getAttributeNS(null, "type"); 160 return value === null ? "" : value; 161 } finally { 162 ceReactionsPostSteps_helpers_custom_elements(globalObject); 163 } 164 } 165 166 set type(V) { 167 const esValue = this !== null && this !== undefined ? this : globalObject; 168 169 if (!exports.is(esValue)) { 170 throw new TypeError("'set type' called on an object that is not a valid instance of HTMLScriptElement."); 171 } 172 173 V = conversions["DOMString"](V, { 174 context: "Failed to set the 'type' property on 'HTMLScriptElement': The provided value" 175 }); 176 177 ceReactionsPreSteps_helpers_custom_elements(globalObject); 178 try { 179 esValue[implSymbol].setAttributeNS(null, "type", V); 180 } finally { 181 ceReactionsPostSteps_helpers_custom_elements(globalObject); 182 } 183 } 184 185 get defer() { 186 const esValue = this !== null && this !== undefined ? this : globalObject; 187 188 if (!exports.is(esValue)) { 189 throw new TypeError("'get defer' called on an object that is not a valid instance of HTMLScriptElement."); 190 } 191 192 ceReactionsPreSteps_helpers_custom_elements(globalObject); 193 try { 194 return esValue[implSymbol].hasAttributeNS(null, "defer"); 195 } finally { 196 ceReactionsPostSteps_helpers_custom_elements(globalObject); 197 } 198 } 199 200 set defer(V) { 201 const esValue = this !== null && this !== undefined ? this : globalObject; 202 203 if (!exports.is(esValue)) { 204 throw new TypeError("'set defer' called on an object that is not a valid instance of HTMLScriptElement."); 205 } 206 207 V = conversions["boolean"](V, { 208 context: "Failed to set the 'defer' property on 'HTMLScriptElement': The provided value" 209 }); 210 211 ceReactionsPreSteps_helpers_custom_elements(globalObject); 212 try { 213 if (V) { 214 esValue[implSymbol].setAttributeNS(null, "defer", ""); 215 } else { 216 esValue[implSymbol].removeAttributeNS(null, "defer"); 217 } 218 } finally { 219 ceReactionsPostSteps_helpers_custom_elements(globalObject); 220 } 221 } 222 223 get crossOrigin() { 224 const esValue = this !== null && this !== undefined ? this : globalObject; 225 226 if (!exports.is(esValue)) { 227 throw new TypeError("'get crossOrigin' called on an object that is not a valid instance of HTMLScriptElement."); 228 } 229 230 ceReactionsPreSteps_helpers_custom_elements(globalObject); 231 try { 232 const value = esValue[implSymbol].getAttributeNS(null, "crossorigin"); 233 return value === null ? "" : value; 234 } finally { 235 ceReactionsPostSteps_helpers_custom_elements(globalObject); 236 } 237 } 238 239 set crossOrigin(V) { 240 const esValue = this !== null && this !== undefined ? this : globalObject; 241 242 if (!exports.is(esValue)) { 243 throw new TypeError("'set crossOrigin' called on an object that is not a valid instance of HTMLScriptElement."); 244 } 245 246 if (V === null || V === undefined) { 247 V = null; 248 } else { 249 V = conversions["DOMString"](V, { 250 context: "Failed to set the 'crossOrigin' property on 'HTMLScriptElement': The provided value" 251 }); 252 } 253 254 ceReactionsPreSteps_helpers_custom_elements(globalObject); 255 try { 256 esValue[implSymbol].setAttributeNS(null, "crossorigin", V); 257 } finally { 258 ceReactionsPostSteps_helpers_custom_elements(globalObject); 259 } 260 } 261 262 get text() { 263 const esValue = this !== null && this !== undefined ? this : globalObject; 264 265 if (!exports.is(esValue)) { 266 throw new TypeError("'get text' called on an object that is not a valid instance of HTMLScriptElement."); 267 } 268 269 ceReactionsPreSteps_helpers_custom_elements(globalObject); 270 try { 271 return esValue[implSymbol]["text"]; 272 } finally { 273 ceReactionsPostSteps_helpers_custom_elements(globalObject); 274 } 275 } 276 277 set text(V) { 278 const esValue = this !== null && this !== undefined ? this : globalObject; 279 280 if (!exports.is(esValue)) { 281 throw new TypeError("'set text' called on an object that is not a valid instance of HTMLScriptElement."); 282 } 283 284 V = conversions["DOMString"](V, { 285 context: "Failed to set the 'text' property on 'HTMLScriptElement': The provided value" 286 }); 287 288 ceReactionsPreSteps_helpers_custom_elements(globalObject); 289 try { 290 esValue[implSymbol]["text"] = V; 291 } finally { 292 ceReactionsPostSteps_helpers_custom_elements(globalObject); 293 } 294 } 295 296 get charset() { 297 const esValue = this !== null && this !== undefined ? this : globalObject; 298 299 if (!exports.is(esValue)) { 300 throw new TypeError("'get charset' called on an object that is not a valid instance of HTMLScriptElement."); 301 } 302 303 ceReactionsPreSteps_helpers_custom_elements(globalObject); 304 try { 305 const value = esValue[implSymbol].getAttributeNS(null, "charset"); 306 return value === null ? "" : value; 307 } finally { 308 ceReactionsPostSteps_helpers_custom_elements(globalObject); 309 } 310 } 311 312 set charset(V) { 313 const esValue = this !== null && this !== undefined ? this : globalObject; 314 315 if (!exports.is(esValue)) { 316 throw new TypeError("'set charset' called on an object that is not a valid instance of HTMLScriptElement."); 317 } 318 319 V = conversions["DOMString"](V, { 320 context: "Failed to set the 'charset' property on 'HTMLScriptElement': The provided value" 321 }); 322 323 ceReactionsPreSteps_helpers_custom_elements(globalObject); 324 try { 325 esValue[implSymbol].setAttributeNS(null, "charset", V); 326 } finally { 327 ceReactionsPostSteps_helpers_custom_elements(globalObject); 328 } 329 } 330 331 get event() { 332 const esValue = this !== null && this !== undefined ? this : globalObject; 333 334 if (!exports.is(esValue)) { 335 throw new TypeError("'get event' called on an object that is not a valid instance of HTMLScriptElement."); 336 } 337 338 ceReactionsPreSteps_helpers_custom_elements(globalObject); 339 try { 340 const value = esValue[implSymbol].getAttributeNS(null, "event"); 341 return value === null ? "" : value; 342 } finally { 343 ceReactionsPostSteps_helpers_custom_elements(globalObject); 344 } 345 } 346 347 set event(V) { 348 const esValue = this !== null && this !== undefined ? this : globalObject; 349 350 if (!exports.is(esValue)) { 351 throw new TypeError("'set event' called on an object that is not a valid instance of HTMLScriptElement."); 352 } 353 354 V = conversions["DOMString"](V, { 355 context: "Failed to set the 'event' property on 'HTMLScriptElement': The provided value" 356 }); 357 358 ceReactionsPreSteps_helpers_custom_elements(globalObject); 359 try { 360 esValue[implSymbol].setAttributeNS(null, "event", V); 361 } finally { 362 ceReactionsPostSteps_helpers_custom_elements(globalObject); 363 } 364 } 365 366 get htmlFor() { 367 const esValue = this !== null && this !== undefined ? this : globalObject; 368 369 if (!exports.is(esValue)) { 370 throw new TypeError("'get htmlFor' called on an object that is not a valid instance of HTMLScriptElement."); 371 } 372 373 ceReactionsPreSteps_helpers_custom_elements(globalObject); 374 try { 375 const value = esValue[implSymbol].getAttributeNS(null, "for"); 376 return value === null ? "" : value; 377 } finally { 378 ceReactionsPostSteps_helpers_custom_elements(globalObject); 379 } 380 } 381 382 set htmlFor(V) { 383 const esValue = this !== null && this !== undefined ? this : globalObject; 384 385 if (!exports.is(esValue)) { 386 throw new TypeError("'set htmlFor' called on an object that is not a valid instance of HTMLScriptElement."); 387 } 388 389 V = conversions["DOMString"](V, { 390 context: "Failed to set the 'htmlFor' property on 'HTMLScriptElement': The provided value" 391 }); 392 393 ceReactionsPreSteps_helpers_custom_elements(globalObject); 394 try { 395 esValue[implSymbol].setAttributeNS(null, "for", V); 396 } finally { 397 ceReactionsPostSteps_helpers_custom_elements(globalObject); 398 } 399 } 400 } 401 Object.defineProperties(HTMLScriptElement.prototype, { 402 src: { enumerable: true }, 403 type: { enumerable: true }, 404 defer: { enumerable: true }, 405 crossOrigin: { enumerable: true }, 406 text: { enumerable: true }, 407 charset: { enumerable: true }, 408 event: { enumerable: true }, 409 htmlFor: { enumerable: true }, 410 [Symbol.toStringTag]: { value: "HTMLScriptElement", configurable: true } 411 }); 412 if (globalObject[ctorRegistrySymbol] === undefined) { 413 globalObject[ctorRegistrySymbol] = Object.create(null); 414 } 415 globalObject[ctorRegistrySymbol][interfaceName] = HTMLScriptElement; 416 417 Object.defineProperty(globalObject, interfaceName, { 418 configurable: true, 419 writable: true, 420 value: HTMLScriptElement 421 }); 422 }; 423 424 const Impl = require("../nodes/HTMLScriptElement-impl.js");