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