This commit is contained in:
Your Name
2026-08-11 17:41:36 +08:00
parent cfe4c82c90
commit 03fe4ddf9d
18771 changed files with 3617239 additions and 0 deletions
@@ -0,0 +1,17 @@
"use strict";
const AbortSignal = require("../generated/AbortSignal");
class AbortControllerImpl {
constructor(globalObject) {
this.signal = AbortSignal.createImpl(globalObject, []);
}
abort() {
this.signal._signalAbort();
}
}
module.exports = {
implementation: AbortControllerImpl
};
@@ -0,0 +1,55 @@
"use strict";
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
const { fireAnEvent } = require("../helpers/events");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const AbortSignal = require("../generated/AbortSignal");
class AbortSignalImpl extends EventTargetImpl {
constructor(globalObject, args, privateData) {
super(globalObject, args, privateData);
// make event firing possible
this._ownerDocument = globalObject.document;
this.aborted = false;
this.abortAlgorithms = new Set();
}
static abort(globalObject) {
const abortSignal = AbortSignal.createImpl(globalObject, []);
abortSignal.aborted = true;
return abortSignal;
}
_signalAbort() {
if (this.aborted) {
return;
}
this.aborted = true;
for (const algorithm of this.abortAlgorithms) {
algorithm();
}
this.abortAlgorithms.clear();
fireAnEvent("abort", this);
}
_addAlgorithm(algorithm) {
if (this.aborted) {
return;
}
this.abortAlgorithms.add(algorithm);
}
_removeAlgorithm(algorithm) {
this.abortAlgorithms.delete(algorithm);
}
}
setupForSimpleEventAccessors(AbortSignalImpl.prototype, ["abort"]);
module.exports = {
implementation: AbortSignalImpl
};
+312
View File
@@ -0,0 +1,312 @@
"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const { HTML_NS } = require("./helpers/namespaces");
const { asciiLowercase } = require("./helpers/strings");
const { queueAttributeMutationRecord } = require("./helpers/mutation-observers");
const { enqueueCECallbackReaction } = require("./helpers/custom-elements");
// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a
// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations.
/* eslint-disable no-restricted-properties */
exports.hasAttribute = function (element, A) {
return element._attributeList.includes(A);
};
exports.hasAttributeByName = function (element, name) {
return element._attributesByNameMap.has(name);
};
exports.hasAttributeByNameNS = function (element, namespace, localName) {
return element._attributeList.some(attribute => {
return attribute._localName === localName && attribute._namespace === namespace;
});
};
// https://dom.spec.whatwg.org/#concept-element-attributes-change
exports.changeAttribute = (element, attribute, value) => {
const { _localName, _namespace, _value } = attribute;
queueAttributeMutationRecord(element, _localName, _namespace, _value);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
_value,
value,
_namespace
]);
}
attribute._value = value;
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(attribute._qualifiedName, value, _value);
};
// https://dom.spec.whatwg.org/#concept-element-attributes-append
exports.appendAttribute = function (element, attribute) {
const { _localName, _namespace, _value } = attribute;
queueAttributeMutationRecord(element, _localName, _namespace, null);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
null,
_value,
_namespace
]);
}
const attributeList = element._attributeList;
attributeList.push(attribute);
attribute._element = element;
// Sync name cache
const name = attribute._qualifiedName;
const cache = element._attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.push(attribute);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added."
element._attrModified(name, _value, null);
};
exports.removeAttribute = function (element, attribute) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove
const { _localName, _namespace, _value } = attribute;
queueAttributeMutationRecord(element, _localName, _namespace, _value);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
_value,
null,
_namespace
]);
}
const attributeList = element._attributeList;
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === attribute) {
attributeList.splice(i, 1);
attribute._element = null;
// Sync name cache
const name = attribute._qualifiedName;
const cache = element._attributesByNameMap;
const entry = cache.get(name);
entry.splice(entry.indexOf(attribute), 1);
if (entry.length === 0) {
cache.delete(name);
}
// Run jsdom hooks; roughly correspond to spec's "An attribute is removed."
element._attrModified(name, null, attribute._value);
return;
}
}
};
exports.replaceAttribute = function (element, oldAttr, newAttr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-replace
const { _localName, _namespace, _value } = oldAttr;
queueAttributeMutationRecord(element, _localName, _namespace, _value);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
_value,
newAttr._value,
_namespace
]);
}
const attributeList = element._attributeList;
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === oldAttr) {
attributeList.splice(i, 1, newAttr);
oldAttr._element = null;
newAttr._element = element;
// Sync name cache
const name = newAttr._qualifiedName;
const cache = element._attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.splice(entry.indexOf(oldAttr), 1, newAttr);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(name, newAttr._value, oldAttr._value);
return;
}
}
};
exports.getAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
if (element._namespaceURI === HTML_NS &&
element._ownerDocument._parsingMode === "html") {
name = asciiLowercase(name);
}
const cache = element._attributesByNameMap;
const entry = cache.get(name);
if (!entry) {
return null;
}
return entry[0];
};
exports.getAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
if (namespace === "") {
namespace = null;
}
const attributeList = element._attributeList;
for (let i = 0; i < attributeList.length; ++i) {
const attr = attributeList[i];
if (attr._namespace === namespace && attr._localName === localName) {
return attr;
}
}
return null;
};
// Both of the following functions implement https://dom.spec.whatwg.org/#concept-element-attributes-get-value.
// Separated them into two to keep symmetry with other functions.
exports.getAttributeValue = function (element, localName) {
const attr = exports.getAttributeByNameNS(element, null, localName);
if (!attr) {
return "";
}
return attr._value;
};
exports.getAttributeValueNS = function (element, namespace, localName) {
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (!attr) {
return "";
}
return attr._value;
};
exports.setAttribute = function (element, attr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set
if (attr._element !== null && attr._element !== element) {
throw DOMException.create(element._globalObject, ["The attribute is in use.", "InUseAttributeError"]);
}
const oldAttr = exports.getAttributeByNameNS(element, attr._namespace, attr._localName);
if (oldAttr === attr) {
return attr;
}
if (oldAttr !== null) {
exports.replaceAttribute(element, oldAttr, attr);
} else {
exports.appendAttribute(element, attr);
}
return oldAttr;
};
exports.setAttributeValue = function (element, localName, value, prefix, namespace) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set-value
if (prefix === undefined) {
prefix = null;
}
if (namespace === undefined) {
namespace = null;
}
const attribute = exports.getAttributeByNameNS(element, namespace, localName);
if (attribute === null) {
const newAttribute = element._ownerDocument._createAttribute({
namespace,
namespacePrefix: prefix,
localName,
value
});
exports.appendAttribute(element, newAttribute);
return;
}
exports.changeAttribute(element, attribute, value);
};
// https://dom.spec.whatwg.org/#set-an-existing-attribute-value
exports.setAnExistingAttributeValue = (attribute, value) => {
const element = attribute._element;
if (element === null) {
attribute._value = value;
} else {
exports.changeAttribute(element, attribute, value);
}
};
exports.removeAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
const attr = exports.getAttributeByName(element, name);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.removeAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.attributeNames = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-getattributenames
return element._attributeList.map(a => a._qualifiedName);
};
exports.hasAttributes = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-hasattributes
return element._attributeList.length > 0;
};
@@ -0,0 +1,60 @@
"use strict";
const { setAnExistingAttributeValue } = require("../attributes.js");
const NodeImpl = require("../nodes/Node-impl.js").implementation;
const { ATTRIBUTE_NODE } = require("../node-type.js");
exports.implementation = class AttrImpl extends NodeImpl {
constructor(globalObject, args, privateData) {
super(globalObject, args, privateData);
this._namespace = privateData.namespace !== undefined ? privateData.namespace : null;
this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null;
this._localName = privateData.localName;
this._value = privateData.value !== undefined ? privateData.value : "";
this._element = privateData.element !== undefined ? privateData.element : null;
this.nodeType = ATTRIBUTE_NODE;
this.specified = true;
}
get namespaceURI() {
return this._namespace;
}
get prefix() {
return this._namespacePrefix;
}
get localName() {
return this._localName;
}
get name() {
return this._qualifiedName;
}
get nodeName() {
return this._qualifiedName;
}
get value() {
return this._value;
}
set value(value) {
setAnExistingAttributeValue(this, value);
}
get ownerElement() {
return this._element;
}
get _qualifiedName() {
// https://dom.spec.whatwg.org/#concept-attribute-qualified-name
if (this._namespacePrefix === null) {
return this._localName;
}
return this._namespacePrefix + ":" + this._localName;
}
};
@@ -0,0 +1,78 @@
"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const idlUtils = require("../generated/utils.js");
const attributes = require("../attributes.js");
const { HTML_NS } = require("../helpers/namespaces");
exports.implementation = class NamedNodeMapImpl {
constructor(globalObject, args, privateData) {
this._element = privateData.element;
this._globalObject = globalObject;
}
get _attributeList() {
return this._element._attributeList;
}
get [idlUtils.supportedPropertyIndices]() {
return this._attributeList.keys();
}
get length() {
return this._attributeList.length;
}
item(index) {
if (index >= this._attributeList.length) {
return null;
}
return this._attributeList[index];
}
get [idlUtils.supportedPropertyNames]() {
const names = new Set(this._attributeList.map(a => a._qualifiedName));
const el = this._element;
if (el._namespaceURI === HTML_NS && el._ownerDocument._parsingMode === "html") {
for (const name of names) {
const lowercaseName = name.toLowerCase();
if (lowercaseName !== name) {
names.delete(name);
}
}
}
return names;
}
getNamedItem(qualifiedName) {
return attributes.getAttributeByName(this._element, qualifiedName);
}
getNamedItemNS(namespace, localName) {
return attributes.getAttributeByNameNS(this._element, namespace, localName);
}
setNamedItem(attr) {
// eslint-disable-next-line no-restricted-properties
return attributes.setAttribute(this._element, attr);
}
setNamedItemNS(attr) {
// eslint-disable-next-line no-restricted-properties
return attributes.setAttribute(this._element, attr);
}
removeNamedItem(qualifiedName) {
const attr = attributes.removeAttributeByName(this._element, qualifiedName);
if (attr === null) {
throw DOMException.create(this._globalObject, [
"Tried to remove an attribute that was not present",
"NotFoundError"
]);
}
return attr;
}
removeNamedItemNS(namespace, localName) {
const attr = attributes.removeAttributeByNameNS(this._element, namespace, localName);
if (attr === null) {
throw DOMException.create(this._globalObject, [
"Tried to remove an attribute that was not present",
"NotFoundError"
]);
}
return attr;
}
};
@@ -0,0 +1,75 @@
"use strict";
const ValidityState = require("../generated/ValidityState");
const { isDisabled } = require("../helpers/form-controls");
const { closest } = require("../helpers/traversal");
const { fireAnEvent } = require("../helpers/events");
exports.implementation = class DefaultConstraintValidationImpl {
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
get willValidate() {
return this._isCandidateForConstraintValidation();
}
get validity() {
if (!this._validity) {
this._validity = ValidityState.createImpl(this._globalObject, [], {
element: this
});
}
return this._validity;
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
checkValidity() {
if (!this._isCandidateForConstraintValidation()) {
return true;
}
if (this._satisfiesConstraints()) {
return true;
}
fireAnEvent("invalid", this, undefined, { cancelable: true });
return false;
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-setcustomvalidity
setCustomValidity(message) {
this._customValidityErrorMessage = message;
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity
// Since jsdom has no user interaction, it's the same as #checkValidity
reportValidity() {
return this.checkValidity();
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validationmessage
get validationMessage() {
const { validity } = this;
if (!this._isCandidateForConstraintValidation() || this._satisfiesConstraints()) {
return "";
}
const isSufferingFromCustomError = validity.customError;
if (isSufferingFromCustomError) {
return this._customValidityErrorMessage;
}
return "Constraints not satisfied";
}
_isCandidateForConstraintValidation() {
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-disabled
return !isDisabled(this) &&
// If an element has a datalist element ancestor,
// it is barred from constraint validation.
closest(this, "datalist") === null &&
!this._barredFromConstraintValidationSpecialization();
}
_isBarredFromConstraintValidation() {
return !this._isCandidateForConstraintValidation();
}
_satisfiesConstraints() {
return this.validity.valid;
}
};
@@ -0,0 +1,66 @@
"use strict";
exports.implementation = class ValidityStateImpl {
constructor(globalObject, args, privateData) {
const { element, state = {} } = privateData;
this._element = element;
this._state = state;
}
get badInput() {
return this._failsConstraint("badInput");
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-custom-error
get customError() {
return this._element._customValidityErrorMessage !== "";
}
get patternMismatch() {
return this._failsConstraint("patternMismatch");
}
get rangeOverflow() {
return this._failsConstraint("rangeOverflow");
}
get rangeUnderflow() {
return this._failsConstraint("rangeUnderflow");
}
get stepMismatch() {
return this._failsConstraint("stepMismatch");
}
get tooLong() {
return this._failsConstraint("tooLong");
}
get tooShort() {
return this._failsConstraint("tooShort");
}
get typeMismatch() {
return this._failsConstraint("typeMismatch");
}
get valueMissing() {
return this._failsConstraint("valueMissing");
}
_failsConstraint(method) {
const validationMethod = this._state[method];
if (validationMethod) {
return validationMethod();
}
return false;
}
get valid() {
return !(this.badInput || this.valueMissing || this.customError ||
this.patternMismatch || this.rangeOverflow || this.rangeUnderflow ||
this.stepMismatch || this.tooLong || this.tooShort || this.typeMismatch);
}
};
@@ -0,0 +1,38 @@
"use strict";
const idlUtils = require("../generated/utils.js");
exports.implementation = class StyleSheetList {
constructor() {
this._list = [];
}
get length() {
return this._list.length;
}
item(index) {
const result = this._list[index];
return result !== undefined ? result : null;
}
get [idlUtils.supportedPropertyIndices]() {
return this._list.keys();
}
_add(sheet) {
const { _list } = this;
if (!_list.includes(sheet)) {
_list.push(sheet);
}
}
_remove(sheet) {
const { _list } = this;
const index = _list.indexOf(sheet);
if (index >= 0) {
_list.splice(index, 1);
}
}
};
@@ -0,0 +1,265 @@
"use strict";
const webIDLConversions = require("webidl-conversions");
const DOMException = require("domexception/webidl2js-wrapper");
const NODE_TYPE = require("../node-type");
const { HTML_NS } = require("../helpers/namespaces");
const { getHTMLElementInterface } = require("../helpers/create-element");
const { shadowIncludingInclusiveDescendantsIterator } = require("../helpers/shadow-dom");
const { isValidCustomElementName, tryUpgradeElement, enqueueCEUpgradeReaction } = require("../helpers/custom-elements");
const idlUtils = require("../generated/utils");
const IDLFunction = require("../generated/Function.js");
const HTMLUnknownElement = require("../generated/HTMLUnknownElement");
const LIFECYCLE_CALLBACKS = [
"connectedCallback",
"disconnectedCallback",
"adoptedCallback",
"attributeChangedCallback"
];
function convertToSequenceDOMString(obj) {
if (!obj || !obj[Symbol.iterator]) {
throw new TypeError("Invalid Sequence");
}
return Array.from(obj).map(webIDLConversions.DOMString);
}
// Returns true is the passed value is a valid constructor.
// Borrowed from: https://stackoverflow.com/a/39336206/3832710
function isConstructor(value) {
if (typeof value !== "function") {
return false;
}
try {
const P = new Proxy(value, {
construct() {
return {};
}
});
// eslint-disable-next-line no-new
new P();
return true;
} catch {
return false;
}
}
// https://html.spec.whatwg.org/#customelementregistry
class CustomElementRegistryImpl {
constructor(globalObject) {
this._customElementDefinitions = [];
this._elementDefinitionIsRunning = false;
this._whenDefinedPromiseMap = Object.create(null);
this._globalObject = globalObject;
}
// https://html.spec.whatwg.org/#dom-customelementregistry-define
define(name, constructor, options) {
const { _globalObject } = this;
const ctor = constructor.objectReference;
if (!isConstructor(ctor)) {
throw new TypeError("Constructor argument is not a constructor.");
}
if (!isValidCustomElementName(name)) {
throw DOMException.create(_globalObject, ["Name argument is not a valid custom element name.", "SyntaxError"]);
}
const nameAlreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
if (nameAlreadyRegistered) {
throw DOMException.create(_globalObject, [
"This name has already been registered in the registry.",
"NotSupportedError"
]);
}
const ctorAlreadyRegistered = this._customElementDefinitions.some(entry => entry.objectReference === ctor);
if (ctorAlreadyRegistered) {
throw DOMException.create(_globalObject, [
"This constructor has already been registered in the registry.",
"NotSupportedError"
]);
}
let localName = name;
let extendsOption = null;
if (options !== undefined && options.extends) {
extendsOption = options.extends;
}
if (extendsOption !== null) {
if (isValidCustomElementName(extendsOption)) {
throw DOMException.create(_globalObject, [
"Option extends value can't be a valid custom element name.",
"NotSupportedError"
]);
}
const extendsInterface = getHTMLElementInterface(extendsOption);
if (extendsInterface === HTMLUnknownElement) {
throw DOMException.create(_globalObject, [
`${extendsOption} is an HTMLUnknownElement.`,
"NotSupportedError"
]);
}
localName = extendsOption;
}
if (this._elementDefinitionIsRunning) {
throw DOMException.create(_globalObject, [
"Invalid nested custom element definition.",
"NotSupportedError"
]);
}
this._elementDefinitionIsRunning = true;
let disableShadow = false;
let observedAttributes = [];
const lifecycleCallbacks = {
connectedCallback: null,
disconnectedCallback: null,
adoptedCallback: null,
attributeChangedCallback: null
};
let caughtError;
try {
const { prototype } = ctor;
if (typeof prototype !== "object") {
throw new TypeError("Invalid constructor prototype.");
}
for (const callbackName of LIFECYCLE_CALLBACKS) {
const callbackValue = prototype[callbackName];
if (callbackValue !== undefined) {
lifecycleCallbacks[callbackName] = IDLFunction.convert(callbackValue, {
context: `The lifecycle callback "${callbackName}"`
});
}
}
if (lifecycleCallbacks.attributeChangedCallback !== null) {
const observedAttributesIterable = ctor.observedAttributes;
if (observedAttributesIterable !== undefined) {
observedAttributes = convertToSequenceDOMString(observedAttributesIterable);
}
}
let disabledFeatures = [];
const disabledFeaturesIterable = ctor.disabledFeatures;
if (disabledFeaturesIterable) {
disabledFeatures = convertToSequenceDOMString(disabledFeaturesIterable);
}
disableShadow = disabledFeatures.includes("shadow");
} catch (err) {
caughtError = err;
} finally {
this._elementDefinitionIsRunning = false;
}
if (caughtError !== undefined) {
throw caughtError;
}
const definition = {
name,
localName,
constructor,
objectReference: ctor,
observedAttributes,
lifecycleCallbacks,
disableShadow,
constructionStack: []
};
this._customElementDefinitions.push(definition);
const document = idlUtils.implForWrapper(this._globalObject._document);
const upgradeCandidates = [];
for (const candidate of shadowIncludingInclusiveDescendantsIterator(document)) {
if (
(candidate._namespaceURI === HTML_NS && candidate._localName === localName) &&
(extendsOption === null || candidate._isValue === name)
) {
upgradeCandidates.push(candidate);
}
}
for (const upgradeCandidate of upgradeCandidates) {
enqueueCEUpgradeReaction(upgradeCandidate, definition);
}
if (this._whenDefinedPromiseMap[name] !== undefined) {
this._whenDefinedPromiseMap[name].resolve(ctor);
delete this._whenDefinedPromiseMap[name];
}
}
// https://html.spec.whatwg.org/#dom-customelementregistry-get
get(name) {
const definition = this._customElementDefinitions.find(entry => entry.name === name);
return definition && definition.objectReference;
}
// https://html.spec.whatwg.org/#dom-customelementregistry-whendefined
whenDefined(name) {
if (!isValidCustomElementName(name)) {
return Promise.reject(DOMException.create(
this._globalObject,
["Name argument is not a valid custom element name.", "SyntaxError"]
));
}
const alreadyRegistered = this._customElementDefinitions.find(entry => entry.name === name);
if (alreadyRegistered) {
return Promise.resolve(alreadyRegistered.objectReference);
}
if (this._whenDefinedPromiseMap[name] === undefined) {
let resolve;
const promise = new Promise(r => {
resolve = r;
});
// Store the pending Promise along with the extracted resolve callback to actually resolve the returned Promise,
// once the custom element is registered.
this._whenDefinedPromiseMap[name] = {
promise,
resolve
};
}
return this._whenDefinedPromiseMap[name].promise;
}
// https://html.spec.whatwg.org/#dom-customelementregistry-upgrade
upgrade(root) {
for (const candidate of shadowIncludingInclusiveDescendantsIterator(root)) {
if (candidate.nodeType === NODE_TYPE.ELEMENT_NODE) {
tryUpgradeElement(candidate);
}
}
}
}
module.exports = {
implementation: CustomElementRegistryImpl
};
+15
View File
@@ -0,0 +1,15 @@
"use strict";
const XMLDocument = require("../living/generated/XMLDocument.js");
const Document = require("../living/generated/Document.js");
const { wrapperForImpl } = require("./generated/utils.js");
exports.createImpl = (globalObject, options, { alwaysUseDocumentClass = false } = {}) => {
if (options.parsingMode === "xml" && !alwaysUseDocumentClass) {
return XMLDocument.createImpl(globalObject, [], { options });
}
return Document.createImpl(globalObject, [], { options });
};
exports.createWrapper = (...args) => {
return wrapperForImpl(exports.createImpl(...args));
};
@@ -0,0 +1,58 @@
"use strict";
const { parseIntoDocument } = require("../../browser/parser");
const Document = require("../generated/Document");
exports.implementation = class DOMParserImpl {
constructor(globalObject) {
this._globalObject = globalObject;
}
parseFromString(string, contentType) {
switch (String(contentType)) {
case "text/html": {
return this.createScriptingDisabledDocument("html", contentType, string);
}
case "text/xml":
case "application/xml":
case "application/xhtml+xml":
case "image/svg+xml": {
try {
return this.createScriptingDisabledDocument("xml", contentType, string);
} catch (error) {
const document = this.createScriptingDisabledDocument("xml", contentType);
const element = document.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
element.textContent = error.message;
document.appendChild(element);
return document;
}
}
default:
throw new TypeError("Invalid contentType");
}
}
createScriptingDisabledDocument(parsingMode, contentType, string) {
const document = Document.createImpl(this._globalObject, [], {
options: {
parsingMode,
encoding: "UTF-8",
contentType,
readyState: "complete",
scriptingDisabled: true
// TODO: somehow set URL to active document's URL
}
});
if (string !== undefined) {
parseIntoDocument(string, document);
}
return document;
}
};
@@ -0,0 +1,29 @@
"use strict";
const { parseFragment } = require("../../browser/parser");
const { HTML_NS } = require("../helpers/namespaces.js");
const { isShadowRoot } = require("../helpers/shadow-dom.js");
const NODE_TYPE = require("../node-type.js");
const { fragmentSerialization } = require("./serialization.js");
// https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin
exports.implementation = class InnerHTMLImpl {
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
get innerHTML() {
return fragmentSerialization(this, {
requireWellFormed: true,
globalObject: this._globalObject
});
}
set innerHTML(markup) {
const contextElement = isShadowRoot(this) ? this.host : this;
const fragment = parseFragment(markup, contextElement);
let contextObject = this;
if (this.nodeType === NODE_TYPE.ELEMENT_NODE && this.localName === "template" && this.namespaceURI === HTML_NS) {
contextObject = this._templateContents;
}
contextObject._replaceAll(fragment);
}
};
@@ -0,0 +1,18 @@
"use strict";
const serialize = require("w3c-xmlserializer");
const DOMException = require("domexception/webidl2js-wrapper");
const utils = require("../generated/utils");
exports.implementation = class XMLSerializerImpl {
constructor(globalObject) {
this._globalObject = globalObject;
}
serializeToString(root) {
try {
return serialize(utils.wrapperForImpl(root), { requireWellFormed: false });
} catch (e) {
throw DOMException.create(this._globalObject, [e.message, "InvalidStateError"]);
}
}
};
@@ -0,0 +1,63 @@
"use strict";
const nodeTypes = require("../node-type");
const { domSymbolTree } = require("../helpers/internal-constants");
// Serialization only requires a subset of the tree adapter interface.
// Tree traversing
exports.getFirstChild = node => node.firstChild;
exports.getChildNodes = node => node.childNodesForSerializing || domSymbolTree.childrenToArray(node);
exports.getParentNode = node => node.parentNode;
exports.getAttrList = element => {
const attributeList = [...element._attributeList];
if (element._isValue && attributeList.every(attr => attr.name !== "is")) {
attributeList.unshift({
name: "is",
namespace: null,
prefix: null,
value: element._isValue
});
}
return attributeList;
};
// Node data
exports.getTagName = element => element._qualifiedName; // https://github.com/inikulin/parse5/issues/231
exports.getNamespaceURI = element => element.namespaceURI;
exports.getTextNodeContent = exports.getCommentNodeContent = node => node.data;
exports.getDocumentTypeNodeName = node => node.name;
exports.getDocumentTypeNodePublicId = node => node.publicId;
exports.getDocumentTypeNodeSystemId = node => node.systemId;
exports.getTemplateContent = templateElement => templateElement._templateContents;
exports.getDocumentMode = document => document._mode;
// Node types
exports.isTextNode = node => node.nodeType === nodeTypes.TEXT_NODE;
exports.isCommentNode = node => node.nodeType === nodeTypes.COMMENT_NODE;
exports.isDocumentTypeNode = node => node.nodeType === nodeTypes.DOCUMENT_TYPE_NODE;
exports.isElementNode = node => node.nodeType === nodeTypes.ELEMENT_NODE;
// Source code location
exports.setNodeSourceCodeLocation = (node, location) => {
node.sourceCodeLocation = location;
};
exports.getNodeSourceCodeLocation = node => node.sourceCodeLocation;
exports.updateNodeSourceCodeLocation = (node, endLocation) => {
Object.assign(node.sourceCodeLocation, endLocation);
};
@@ -0,0 +1,45 @@
"use strict";
const produceXMLSerialization = require("w3c-xmlserializer");
const parse5 = require("parse5");
const DOMException = require("domexception/webidl2js-wrapper");
const utils = require("../generated/utils");
const treeAdapter = require("./parse5-adapter-serialization");
const NODE_TYPE = require("../node-type");
const NAMESPACES = require("../helpers/namespaces");
function htmlSerialization(node) {
if (
node.nodeType === NODE_TYPE.ELEMENT_NODE &&
node.namespaceURI === NAMESPACES.HTML_NS &&
node.tagName === "TEMPLATE"
) {
node = node.content;
}
return parse5.serialize(node, { treeAdapter });
}
module.exports.fragmentSerialization = (node, { requireWellFormed, globalObject }) => {
const contextDocument =
node.nodeType === NODE_TYPE.DOCUMENT_NODE ? node : node._ownerDocument;
if (contextDocument._parsingMode === "html") {
return htmlSerialization(node);
}
const childNodes = node.childNodesForSerializing || node.childNodes;
try {
let serialized = "";
for (let i = 0; i < childNodes.length; ++i) {
serialized += produceXMLSerialization(
utils.wrapperForImpl(childNodes[i] || childNodes.item(i)),
{ requireWellFormed }
);
}
return serialized;
} catch (e) {
throw DOMException.create(globalObject, [e.message, "InvalidStateError"]);
}
};
@@ -0,0 +1,10 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const CloseEventInit = require("../generated/CloseEventInit");
class CloseEventImpl extends EventImpl {}
CloseEventImpl.defaultInit = CloseEventInit.convert(undefined);
exports.implementation = CloseEventImpl;
@@ -0,0 +1,20 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const CompositionEventInit = require("../generated/CompositionEventInit");
class CompositionEventImpl extends UIEventImpl {
initCompositionEvent(type, bubbles, cancelable, view, data) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, 0);
this.data = data;
}
}
CompositionEventImpl.defaultInit = CompositionEventInit.convert(undefined);
module.exports = {
implementation: CompositionEventImpl
};
@@ -0,0 +1,21 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const CustomEventInit = require("../generated/CustomEventInit");
class CustomEventImpl extends EventImpl {
initCustomEvent(type, bubbles, cancelable, detail) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.detail = detail;
}
}
CustomEventImpl.defaultInit = CustomEventInit.convert(undefined);
module.exports = {
implementation: CustomEventImpl
};
@@ -0,0 +1,14 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const ErrorEventInit = require("../generated/ErrorEventInit");
class ErrorEventImpl extends EventImpl {
}
ErrorEventImpl.defaultInit = ErrorEventInit.convert(undefined);
module.exports = {
implementation: ErrorEventImpl
};
+197
View File
@@ -0,0 +1,197 @@
"use strict";
const idlUtils = require("../generated/utils");
const EventInit = require("../generated/EventInit");
class EventImpl {
constructor(globalObject, args, privateData) {
const [type, eventInitDict = this.constructor.defaultInit] = args;
this.type = type;
this.bubbles = false;
this.cancelable = false;
for (const key in eventInitDict) {
if (key in this.constructor.defaultInit) {
this[key] = eventInitDict[key];
}
}
for (const key in this.constructor.defaultInit) {
if (!(key in this)) {
this[key] = this.constructor.defaultInit[key];
}
}
this.target = null;
this.currentTarget = null;
this.eventPhase = 0;
this._globalObject = globalObject;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this._inPassiveListenerFlag = false;
this._dispatchFlag = false;
this._path = [];
this.isTrusted = privateData.isTrusted || false;
this.timeStamp = Date.now();
}
// https://dom.spec.whatwg.org/#set-the-canceled-flag
_setTheCanceledFlag() {
if (this.cancelable && !this._inPassiveListenerFlag) {
this._canceledFlag = true;
}
}
get srcElement() {
return this.target;
}
get returnValue() {
return !this._canceledFlag;
}
set returnValue(v) {
if (v === false) {
this._setTheCanceledFlag();
}
}
get defaultPrevented() {
return this._canceledFlag;
}
stopPropagation() {
this._stopPropagationFlag = true;
}
get cancelBubble() {
return this._stopPropagationFlag;
}
set cancelBubble(v) {
if (v) {
this._stopPropagationFlag = true;
}
}
stopImmediatePropagation() {
this._stopPropagationFlag = true;
this._stopImmediatePropagationFlag = true;
}
preventDefault() {
this._setTheCanceledFlag();
}
// https://dom.spec.whatwg.org/#dom-event-composedpath
// Current implementation is based of https://whatpr.org/dom/699.html#dom-event-composedpath
// due to a bug in composed path implementation https://github.com/whatwg/dom/issues/684
composedPath() {
const composedPath = [];
const { currentTarget, _path: path } = this;
if (path.length === 0) {
return composedPath;
}
composedPath.push(currentTarget);
let currentTargetIndex = 0;
let currentTargetHiddenSubtreeLevel = 0;
for (let index = path.length - 1; index >= 0; index--) {
const { item, rootOfClosedTree, slotInClosedTree } = path[index];
if (rootOfClosedTree) {
currentTargetHiddenSubtreeLevel++;
}
if (item === idlUtils.implForWrapper(currentTarget)) {
currentTargetIndex = index;
break;
}
if (slotInClosedTree) {
currentTargetHiddenSubtreeLevel--;
}
}
let currentHiddenLevel = currentTargetHiddenSubtreeLevel;
let maxHiddenLevel = currentTargetHiddenSubtreeLevel;
for (let i = currentTargetIndex - 1; i >= 0; i--) {
const { item, rootOfClosedTree, slotInClosedTree } = path[i];
if (rootOfClosedTree) {
currentHiddenLevel++;
}
if (currentHiddenLevel <= maxHiddenLevel) {
composedPath.unshift(idlUtils.wrapperForImpl(item));
}
if (slotInClosedTree) {
currentHiddenLevel--;
if (currentHiddenLevel < maxHiddenLevel) {
maxHiddenLevel = currentHiddenLevel;
}
}
}
currentHiddenLevel = currentTargetHiddenSubtreeLevel;
maxHiddenLevel = currentTargetHiddenSubtreeLevel;
for (let index = currentTargetIndex + 1; index < path.length; index++) {
const { item, rootOfClosedTree, slotInClosedTree } = path[index];
if (slotInClosedTree) {
currentHiddenLevel++;
}
if (currentHiddenLevel <= maxHiddenLevel) {
composedPath.push(idlUtils.wrapperForImpl(item));
}
if (rootOfClosedTree) {
currentHiddenLevel--;
if (currentHiddenLevel < maxHiddenLevel) {
maxHiddenLevel = currentHiddenLevel;
}
}
}
return composedPath;
}
_initialize(type, bubbles, cancelable) {
this.type = type;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this.isTrusted = false;
this.target = null;
this.bubbles = bubbles;
this.cancelable = cancelable;
}
initEvent(type, bubbles, cancelable) {
if (this._dispatchFlag) {
return;
}
this._initialize(type, bubbles, cancelable);
}
}
EventImpl.defaultInit = EventInit.convert(undefined);
module.exports = {
implementation: EventImpl
};
@@ -0,0 +1,18 @@
"use strict";
// This mixin doesn't have an IDL equivalent, but since MouseEvent and KeyboardEvent implement getModifierState() the
// same way, its implementation is shared here.
class EventModifierMixinImpl {
// Event's constructor assumes all options correspond to IDL attributes with the same names, and sets them on `this`.
// That is not the case for these modifier boolean options, but since the options are set on `this` anyway we'll
// access them that way. The spec doesn't say much about the case where keyArg is not one of the valid ones
// (https://w3c.github.io/uievents-key/#keys-modifier), but at least Chrome returns false for invalid modifiers. Since
// these invalid modifiers will be undefined on `this` (thus `false` after casting it to boolean), we don't need to do
// extra checking for validity.
getModifierState(keyArg) {
return Boolean(this[`modifier${keyArg}`]);
}
}
exports.implementation = EventModifierMixinImpl;
@@ -0,0 +1,403 @@
"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const reportException = require("../helpers/runtime-script-errors");
const idlUtils = require("../generated/utils");
const { nodeRoot } = require("../helpers/node");
const {
isNode, isShadowRoot, isSlotable, getEventTargetParent,
isShadowInclusiveAncestor, retarget
} = require("../helpers/shadow-dom");
const MouseEvent = require("../generated/MouseEvent");
const EVENT_PHASE = {
NONE: 0,
CAPTURING_PHASE: 1,
AT_TARGET: 2,
BUBBLING_PHASE: 3
};
class EventTargetImpl {
constructor(globalObject) {
this._globalObject = globalObject;
this._eventListeners = Object.create(null);
}
addEventListener(type, callback, options) {
options = normalizeEventHandlerOptions(options, ["capture", "once", "passive"]);
if (callback === null) {
return;
}
if (!this._eventListeners[type]) {
this._eventListeners[type] = [];
}
for (let i = 0; i < this._eventListeners[type].length; ++i) {
const listener = this._eventListeners[type][i];
if (
listener.callback.objectReference === callback.objectReference &&
listener.options.capture === options.capture
) {
return;
}
}
this._eventListeners[type].push({
callback,
options
});
}
removeEventListener(type, callback, options) {
options = normalizeEventHandlerOptions(options, ["capture"]);
if (callback === null) {
// Optimization, not in the spec.
return;
}
if (!this._eventListeners[type]) {
return;
}
for (let i = 0; i < this._eventListeners[type].length; ++i) {
const listener = this._eventListeners[type][i];
if (
listener.callback.objectReference === callback.objectReference &&
listener.options.capture === options.capture
) {
this._eventListeners[type].splice(i, 1);
break;
}
}
}
dispatchEvent(eventImpl) {
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
throw DOMException.create(this._globalObject, [
"Tried to dispatch an uninitialized event",
"InvalidStateError"
]);
}
if (eventImpl.eventPhase !== EVENT_PHASE.NONE) {
throw DOMException.create(this._globalObject, [
"Tried to dispatch a dispatching event",
"InvalidStateError"
]);
}
eventImpl.isTrusted = false;
return this._dispatch(eventImpl);
}
// https://dom.spec.whatwg.org/#get-the-parent
_getTheParent() {
return null;
}
// https://dom.spec.whatwg.org/#concept-event-dispatch
// legacyOutputDidListenersThrowFlag optional parameter is not necessary here since it is only used by indexDB.
_dispatch(eventImpl, targetOverride /* , legacyOutputDidListenersThrowFlag */) {
let targetImpl = this;
let clearTargets = false;
let activationTarget = null;
eventImpl._dispatchFlag = true;
targetOverride = targetOverride || targetImpl;
let relatedTarget = retarget(eventImpl.relatedTarget, targetImpl);
if (targetImpl !== relatedTarget || targetImpl === eventImpl.relatedTarget) {
const touchTargets = [];
appendToEventPath(eventImpl, targetImpl, targetOverride, relatedTarget, touchTargets, false);
const isActivationEvent = MouseEvent.isImpl(eventImpl) && eventImpl.type === "click";
if (isActivationEvent && targetImpl._hasActivationBehavior) {
activationTarget = targetImpl;
}
let slotInClosedTree = false;
let slotable = isSlotable(targetImpl) && targetImpl._assignedSlot ? targetImpl : null;
let parent = getEventTargetParent(targetImpl, eventImpl);
// Populate event path
// https://dom.spec.whatwg.org/#event-path
while (parent !== null) {
if (slotable !== null) {
if (parent.localName !== "slot") {
throw new Error(`JSDOM Internal Error: Expected parent to be a Slot`);
}
slotable = null;
const parentRoot = nodeRoot(parent);
if (isShadowRoot(parentRoot) && parentRoot.mode === "closed") {
slotInClosedTree = true;
}
}
if (isSlotable(parent) && parent._assignedSlot) {
slotable = parent;
}
relatedTarget = retarget(eventImpl.relatedTarget, parent);
if (
(isNode(parent) && isShadowInclusiveAncestor(nodeRoot(targetImpl), parent)) ||
idlUtils.wrapperForImpl(parent).constructor.name === "Window"
) {
if (isActivationEvent && eventImpl.bubbles && activationTarget === null &&
parent._hasActivationBehavior) {
activationTarget = parent;
}
appendToEventPath(eventImpl, parent, null, relatedTarget, touchTargets, slotInClosedTree);
} else if (parent === relatedTarget) {
parent = null;
} else {
targetImpl = parent;
if (isActivationEvent && activationTarget === null && targetImpl._hasActivationBehavior) {
activationTarget = targetImpl;
}
appendToEventPath(eventImpl, parent, targetImpl, relatedTarget, touchTargets, slotInClosedTree);
}
if (parent !== null) {
parent = getEventTargetParent(parent, eventImpl);
}
slotInClosedTree = false;
}
let clearTargetsStructIndex = -1;
for (let i = eventImpl._path.length - 1; i >= 0 && clearTargetsStructIndex === -1; i--) {
if (eventImpl._path[i].target !== null) {
clearTargetsStructIndex = i;
}
}
const clearTargetsStruct = eventImpl._path[clearTargetsStructIndex];
clearTargets =
(isNode(clearTargetsStruct.target) && isShadowRoot(nodeRoot(clearTargetsStruct.target))) ||
(isNode(clearTargetsStruct.relatedTarget) && isShadowRoot(nodeRoot(clearTargetsStruct.relatedTarget)));
if (activationTarget !== null && activationTarget._legacyPreActivationBehavior) {
activationTarget._legacyPreActivationBehavior();
}
for (let i = eventImpl._path.length - 1; i >= 0; --i) {
const struct = eventImpl._path[i];
if (struct.target !== null) {
eventImpl.eventPhase = EVENT_PHASE.AT_TARGET;
} else {
eventImpl.eventPhase = EVENT_PHASE.CAPTURING_PHASE;
}
invokeEventListeners(struct, eventImpl, "capturing");
}
for (let i = 0; i < eventImpl._path.length; i++) {
const struct = eventImpl._path[i];
if (struct.target !== null) {
eventImpl.eventPhase = EVENT_PHASE.AT_TARGET;
} else {
if (!eventImpl.bubbles) {
continue;
}
eventImpl.eventPhase = EVENT_PHASE.BUBBLING_PHASE;
}
invokeEventListeners(struct, eventImpl, "bubbling");
}
}
eventImpl.eventPhase = EVENT_PHASE.NONE;
eventImpl.currentTarget = null;
eventImpl._path = [];
eventImpl._dispatchFlag = false;
eventImpl._stopPropagationFlag = false;
eventImpl._stopImmediatePropagationFlag = false;
if (clearTargets) {
eventImpl.target = null;
eventImpl.relatedTarget = null;
}
if (activationTarget !== null) {
if (!eventImpl._canceledFlag) {
activationTarget._activationBehavior(eventImpl);
} else if (activationTarget._legacyCanceledActivationBehavior) {
activationTarget._legacyCanceledActivationBehavior();
}
}
return !eventImpl._canceledFlag;
}
}
module.exports = {
implementation: EventTargetImpl
};
// https://dom.spec.whatwg.org/#concept-event-listener-invoke
function invokeEventListeners(struct, eventImpl, phase) {
const structIndex = eventImpl._path.indexOf(struct);
for (let i = structIndex; i >= 0; i--) {
const t = eventImpl._path[i];
if (t.target) {
eventImpl.target = t.target;
break;
}
}
eventImpl.relatedTarget = idlUtils.wrapperForImpl(struct.relatedTarget);
if (eventImpl._stopPropagationFlag) {
return;
}
eventImpl.currentTarget = idlUtils.wrapperForImpl(struct.item);
const listeners = struct.item._eventListeners;
innerInvokeEventListeners(eventImpl, listeners, phase, struct.itemInShadowTree);
}
// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke
function innerInvokeEventListeners(eventImpl, listeners, phase, itemInShadowTree) {
let found = false;
const { type, target } = eventImpl;
const wrapper = idlUtils.wrapperForImpl(target);
if (!listeners || !listeners[type]) {
return found;
}
// Copy event listeners before iterating since the list can be modified during the iteration.
const handlers = listeners[type].slice();
for (let i = 0; i < handlers.length; i++) {
const listener = handlers[i];
const { capture, once, passive } = listener.options;
// Check if the event listener has been removed since the listeners has been cloned.
if (!listeners[type].includes(listener)) {
continue;
}
found = true;
if (
(phase === "capturing" && !capture) ||
(phase === "bubbling" && capture)
) {
continue;
}
if (once) {
listeners[type].splice(listeners[type].indexOf(listener), 1);
}
let window = null;
if (wrapper && wrapper._document) {
// Triggered by Window
window = wrapper;
} else if (target._ownerDocument) {
// Triggered by most webidl2js'ed instances
window = target._ownerDocument._defaultView;
} else if (wrapper._ownerDocument) {
// Currently triggered by some non-webidl2js things
window = wrapper._ownerDocument._defaultView;
}
let currentEvent;
if (window) {
currentEvent = window._currentEvent;
if (!itemInShadowTree) {
window._currentEvent = eventImpl;
}
}
if (passive) {
eventImpl._inPassiveListenerFlag = true;
}
try {
listener.callback.call(eventImpl.currentTarget, eventImpl);
} catch (e) {
if (window) {
reportException(window, e);
}
// Errors in window-less documents just get swallowed... can you think of anything better?
}
eventImpl._inPassiveListenerFlag = false;
if (window) {
window._currentEvent = currentEvent;
}
if (eventImpl._stopImmediatePropagationFlag) {
return found;
}
}
return found;
}
/**
* Normalize the event listeners options argument in order to get always a valid options object
* @param {Object} options - user defined options
* @param {Array} defaultBoolKeys - boolean properties that should belong to the options object
* @returns {Object} object containing at least the "defaultBoolKeys"
*/
function normalizeEventHandlerOptions(options, defaultBoolKeys) {
const returnValue = {};
// no need to go further here
if (typeof options === "boolean" || options === null || typeof options === "undefined") {
returnValue.capture = Boolean(options);
return returnValue;
}
// non objects options so we typecast its value as "capture" value
if (typeof options !== "object") {
returnValue.capture = Boolean(options);
// at this point we don't need to loop the "capture" key anymore
defaultBoolKeys = defaultBoolKeys.filter(k => k !== "capture");
}
for (const key of defaultBoolKeys) {
returnValue[key] = Boolean(options[key]);
}
return returnValue;
}
// https://dom.spec.whatwg.org/#concept-event-path-append
function appendToEventPath(eventImpl, target, targetOverride, relatedTarget, touchTargets, slotInClosedTree) {
const itemInShadowTree = isNode(target) && isShadowRoot(nodeRoot(target));
const rootOfClosedTree = isShadowRoot(target) && target.mode === "closed";
eventImpl._path.push({
item: target,
itemInShadowTree,
target: targetOverride,
relatedTarget,
touchTargets,
rootOfClosedTree,
slotInClosedTree
});
}
@@ -0,0 +1,9 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const FocusEventInit = require("../generated/FocusEventInit");
class FocusEventImpl extends UIEventImpl {}
FocusEventImpl.defaultInit = FocusEventInit.convert(undefined);
exports.implementation = FocusEventImpl;
@@ -0,0 +1,14 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const HashChangeEventInit = require("../generated/HashChangeEventInit");
class HashChangeEventImpl extends EventImpl {
}
HashChangeEventImpl.defaultInit = HashChangeEventInit.convert(undefined);
module.exports = {
implementation: HashChangeEventImpl
};
@@ -0,0 +1,11 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const InputEventInit = require("../generated/InputEventInit");
// https://w3c.github.io/uievents/#interface-inputevent
class InputEventImpl extends UIEventImpl { }
InputEventImpl.defaultInit = InputEventInit.convert(undefined);
module.exports = {
implementation: InputEventImpl
};
@@ -0,0 +1,29 @@
"use strict";
const { mixin } = require("../../utils");
const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation;
const UIEventImpl = require("./UIEvent-impl").implementation;
const KeyboardEventInit = require("../generated/KeyboardEventInit");
class KeyboardEventImpl extends UIEventImpl {
initKeyboardEvent(type, bubbles, cancelable, view, key, location, ctrlKey, altKey, shiftKey, metaKey) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, 0);
this.key = key;
this.location = location;
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
this.metaKey = metaKey;
}
}
mixin(KeyboardEventImpl.prototype, EventModifierMixinImpl.prototype);
KeyboardEventImpl.defaultInit = KeyboardEventInit.convert(undefined);
module.exports = {
implementation: KeyboardEventImpl
};
@@ -0,0 +1,25 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const MessageEventInit = require("../generated/MessageEventInit");
class MessageEventImpl extends EventImpl {
initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.data = data;
this.origin = origin;
this.lastEventId = lastEventId;
this.source = source;
this.ports = ports;
}
}
MessageEventImpl.defaultInit = MessageEventInit.convert(undefined);
module.exports = {
implementation: MessageEventImpl
};
@@ -0,0 +1,49 @@
"use strict";
const { mixin } = require("../../utils");
const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation;
const UIEventImpl = require("./UIEvent-impl").implementation;
const MouseEventInit = require("../generated/MouseEventInit");
class MouseEventImpl extends UIEventImpl {
initMouseEvent(
type,
bubbles,
cancelable,
view,
detail,
screenX,
screenY,
clientX,
clientY,
ctrlKey,
altKey,
shiftKey,
metaKey,
button,
relatedTarget
) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, detail);
this.screenX = screenX;
this.screenY = screenY;
this.clientX = clientX;
this.clientY = clientY;
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
this.metaKey = metaKey;
this.button = button;
this.relatedTarget = relatedTarget;
}
}
mixin(MouseEventImpl.prototype, EventModifierMixinImpl.prototype);
MouseEventImpl.defaultInit = MouseEventInit.convert(undefined);
module.exports = {
implementation: MouseEventImpl
};
@@ -0,0 +1,20 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const PageTransitionEventInit = require("../generated/PageTransitionEventInit");
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#pagetransitionevent
class PageTransitionEventImpl extends EventImpl {
initPageTransitionEvent(type, bubbles, cancelable, persisted) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.persisted = persisted;
}
}
PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined);
exports.implementation = PageTransitionEventImpl;
@@ -0,0 +1,9 @@
"use strict";
const EventImpl = require("./Event-impl.js").implementation;
const PopStateEventInit = require("../generated/PopStateEventInit");
class PopStateEventImpl extends EventImpl {}
PopStateEventImpl.defaultInit = PopStateEventInit.convert(undefined);
exports.implementation = PopStateEventImpl;
@@ -0,0 +1,14 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const ProgressEventInit = require("../generated/ProgressEventInit");
class ProgressEventImpl extends EventImpl {
}
ProgressEventImpl.defaultInit = ProgressEventInit.convert(undefined);
module.exports = {
implementation: ProgressEventImpl
};
@@ -0,0 +1,26 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
const StorageEventInit = require("../generated/StorageEventInit");
// https://html.spec.whatwg.org/multipage/webstorage.html#the-storageevent-interface
class StorageEventImpl extends EventImpl {
initStorageEvent(type, bubbles, cancelable, key, oldValue, newValue, url, storageArea) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.key = key;
this.oldValue = oldValue;
this.newValue = newValue;
this.url = url;
this.storageArea = storageArea;
}
}
StorageEventImpl.defaultInit = StorageEventInit.convert(undefined);
module.exports = {
implementation: StorageEventImpl
};
@@ -0,0 +1,14 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const TouchEventInit = require("../generated/TouchEventInit");
class TouchEventImpl extends UIEventImpl {
}
TouchEventImpl.defaultInit = TouchEventInit.convert(undefined);
module.exports = {
implementation: TouchEventImpl
};
@@ -0,0 +1,59 @@
"use strict";
const idlUtils = require("../generated/utils");
const UIEventInit = require("../generated/UIEventInit");
const EventImpl = require("./Event-impl").implementation;
// Until webidl2js gains support for checking for Window, this would have to do.
function isWindow(val) {
if (typeof val !== "object") {
return false;
}
const wrapper = idlUtils.wrapperForImpl(val);
if (typeof wrapper === "object") {
return wrapper === wrapper._globalProxy;
}
// `val` may be either impl or wrapper currently, because webidl2js currently unwraps Window objects (and their global
// proxies) to their underlying EventTargetImpl during conversion, which is not what we want. But at the same time,
// some internal usage call this constructor with the actual global proxy.
return isWindow(idlUtils.implForWrapper(val));
}
class UIEventImpl extends EventImpl {
constructor(globalObject, args, privateData) {
const eventInitDict = args[1];
// undefined check included so that we can omit the property in internal usage.
if (eventInitDict && eventInitDict.view !== null && eventInitDict.view !== undefined) {
if (!isWindow(eventInitDict.view)) {
throw new TypeError(`Failed to construct '${new.target.name.replace(/Impl$/, "")}': member view is not of ` +
"type Window.");
}
}
super(globalObject, args, privateData);
}
initUIEvent(type, bubbles, cancelable, view, detail) {
if (view !== null) {
if (!isWindow(view)) {
throw new TypeError(`Failed to execute 'initUIEvent' on '${this.constructor.name.replace(/Impl$/, "")}': ` +
"parameter 4 is not of type 'Window'.");
}
}
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.view = view;
this.detail = detail;
}
}
UIEventImpl.defaultInit = UIEventInit.convert(undefined);
module.exports = {
implementation: UIEventImpl
};
@@ -0,0 +1,12 @@
"use strict";
const MouseEventImpl = require("./MouseEvent-impl").implementation;
const WheelEventInit = require("../generated/WheelEventInit");
class WheelEventImpl extends MouseEventImpl {}
WheelEventImpl.defaultInit = WheelEventInit.convert(undefined);
module.exports = {
implementation: WheelEventImpl
};
+165
View File
@@ -0,0 +1,165 @@
"use strict";
const {
isForbidden,
isForbiddenResponse,
isPrivilegedNoCORSRequest,
isNoCORSSafelistedRequest,
isCORSWhitelisted
} = require("./header-types");
const HeaderList = require("./header-list");
function assertName(name) {
if (!name.match(/^[!#$%&'*+\-.^`|~\w]+$/)) {
throw new TypeError("name is invalid");
}
}
function assertValue(value) {
if (value.match(/[\0\r\n]/)) {
throw new TypeError("value is invalid");
}
}
class HeadersImpl {
constructor(globalObject, args) {
this.guard = "none";
this.headersList = new HeaderList();
if (args[0]) {
this._fill(args[0]);
}
}
_fill(init) {
if (Array.isArray(init)) {
for (const header of init) {
if (header.length !== 2) {
throw new TypeError("init is invalid");
}
this.append(header[0], header[1]);
}
} else {
for (const key of Object.keys(init)) {
this.append(key, init[key]);
}
}
}
has(name) {
assertName(name);
return this.headersList.contains(name);
}
get(name) {
assertName(name);
return this.headersList.get(name);
}
_removePrivilegedNoCORSHeaders() {
this.headersList.delete("range");
}
append(name, value) {
value = value.trim();
assertName(name);
assertValue(value);
switch (this.guard) {
case "immutable":
throw new TypeError("Headers is immutable");
case "request":
if (isForbidden(name)) {
return;
}
break;
case "request-no-cors": {
let temporaryValue = this.get(name);
if (temporaryValue === null) {
temporaryValue = value;
} else {
temporaryValue += `, ${value}`;
}
if (!isCORSWhitelisted(name, value)) {
return;
}
break;
}
case "response":
if (isForbiddenResponse(name)) {
return;
}
break;
}
this.headersList.append(name, value);
this._removePrivilegedNoCORSHeaders();
}
set(name, value) {
value = value.trim();
assertName(name);
assertValue(value);
switch (this.guard) {
case "immutable":
throw new TypeError("Headers is immutable");
case "request":
if (isForbidden(name)) {
return;
}
break;
case "request-no-cors": {
if (!isCORSWhitelisted(name, value)) {
return;
}
break;
}
case "response":
if (isForbiddenResponse(name)) {
return;
}
break;
}
this.headersList.set(name, value);
this._removePrivilegedNoCORSHeaders();
}
delete(name) {
assertName(name);
switch (this.guard) {
case "immutable":
throw new TypeError("Headers is immutable");
case "request":
if (isForbidden(name)) {
return;
}
break;
case "request-no-cors": {
if (
!isNoCORSSafelistedRequest(name) &&
!isPrivilegedNoCORSRequest(name)
) {
return;
}
break;
}
case "response":
if (isForbiddenResponse(name)) {
return;
}
break;
}
this.headersList.delete(name);
this._removePrivilegedNoCORSHeaders();
}
* [Symbol.iterator]() {
for (const header of this.headersList.sortAndCombine()) {
yield header;
}
}
}
exports.implementation = HeadersImpl;
+54
View File
@@ -0,0 +1,54 @@
"use strict";
/**
* Provides some utility functions for somewhat efficiently modifying a
* collection of headers.
*
* Note that this class only operates on ByteStrings (which is also why we use
* toLowerCase internally).
*/
class HeaderList {
constructor() {
this.headers = new Map();
}
append(name, value) {
const existing = this.headers.get(name.toLowerCase());
if (existing) {
name = existing[0].name;
existing.push({ name, value });
} else {
this.headers.set(name.toLowerCase(), [{ name, value }]);
}
}
contains(name) {
return this.headers.has(name.toLowerCase());
}
get(name) {
name = name.toLowerCase();
const values = this.headers.get(name);
if (!values) {
return null;
}
return values.map(h => h.value).join(", ");
}
delete(name) {
this.headers.delete(name.toLowerCase());
}
set(name, value) {
const lowerName = name.toLowerCase();
this.headers.delete(lowerName);
this.headers.set(lowerName, [{ name, value }]);
}
sortAndCombine() {
const names = [...this.headers.keys()].sort();
return names.map(n => [n, this.get(n)]);
}
}
module.exports = HeaderList;
+103
View File
@@ -0,0 +1,103 @@
"use strict";
const MIMEType = require("whatwg-mimetype");
const PRIVILEGED_NO_CORS_REQUEST = new Set(["range"]);
function isPrivilegedNoCORSRequest(name) {
return PRIVILEGED_NO_CORS_REQUEST.has(name.toLowerCase());
}
const NO_CORS_SAFELISTED_REQUEST = new Set([
`accept`,
`accept-language`,
`content-language`,
`content-type`
]);
function isNoCORSSafelistedRequest(name) {
return NO_CORS_SAFELISTED_REQUEST.has(name.toLowerCase());
}
const FORBIDDEN = new Set([
`accept-charset`,
`accept-encoding`,
`access-control-request-headers`,
`access-control-request-method`,
`connection`,
`content-length`,
`cookie`,
`cookie2`,
`date`,
`dnt`,
`expect`,
`host`,
`keep-alive`,
`origin`,
`referer`,
`te`,
`trailer`,
`transfer-encoding`,
`upgrade`,
`via`
]);
function isForbidden(name) {
name = name.toLowerCase();
return (
FORBIDDEN.has(name) || name.startsWith("proxy-") || name.startsWith("sec-")
);
}
const FORBIDDEN_RESPONSE = new Set(["set-cookie", "set-cookie2"]);
function isForbiddenResponse(name) {
return FORBIDDEN_RESPONSE.has(name.toLowerCase());
}
const CORS_UNSAFE_BYTE = /[\x00-\x08\x0A-\x1F"():<>?@[\\\]{}\x7F]/;
function isCORSWhitelisted(name, value) {
name = name.toLowerCase();
switch (name) {
case "accept":
if (value.match(CORS_UNSAFE_BYTE)) {
return false;
}
break;
case "accept-language":
case "content-language":
if (value.match(/[^\x30-\x39\x41-\x5A\x61-\x7A *,\-.;=]/)) {
return false;
}
break;
case "content-type": {
if (value.match(CORS_UNSAFE_BYTE)) {
return false;
}
const mimeType = MIMEType.parse(value);
if (mimeType === null) {
return false;
}
if (
![
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
].includes(mimeType.essence)
) {
return false;
}
break;
}
default:
return false;
}
if (Buffer.from(value).length > 128) {
return false;
}
return true;
}
module.exports = {
isPrivilegedNoCORSRequest,
isNoCORSSafelistedRequest,
isForbidden,
isForbiddenResponse,
isCORSWhitelisted
};
+93
View File
@@ -0,0 +1,93 @@
"use strict";
const Blob = require("../generated/Blob");
const { isArrayBuffer } = require("../generated/utils");
function convertLineEndingsToNative(s) {
// jsdom always pretends to be *nix, for consistency.
// See also https://github.com/jsdom/jsdom/issues/2396.
return s.replace(/\r\n|\r|\n/g, "\n");
}
exports.implementation = class BlobImpl {
constructor(globalObject, args) {
const parts = args[0];
const properties = args[1];
const buffers = [];
if (parts !== undefined) {
for (const part of parts) {
let buffer;
if (isArrayBuffer(part)) {
buffer = Buffer.from(part);
} else if (ArrayBuffer.isView(part)) {
buffer = Buffer.from(part.buffer, part.byteOffset, part.byteLength);
} else if (Blob.isImpl(part)) {
buffer = part._buffer;
} else {
let s = part;
if (properties.endings === "native") {
s = convertLineEndingsToNative(part);
}
buffer = Buffer.from(s);
}
buffers.push(buffer);
}
}
this._buffer = Buffer.concat(buffers);
this._globalObject = globalObject;
this.type = properties.type;
if (/[^\u0020-\u007E]/.test(this.type)) {
this.type = "";
} else {
this.type = this.type.toLowerCase();
}
}
get size() {
return this._buffer.length;
}
slice(start, end, contentType) {
const { size } = this;
let relativeStart, relativeEnd, relativeContentType;
if (start === undefined) {
relativeStart = 0;
} else if (start < 0) {
relativeStart = Math.max(size + start, 0);
} else {
relativeStart = Math.min(start, size);
}
if (end === undefined) {
relativeEnd = size;
} else if (end < 0) {
relativeEnd = Math.max(size + end, 0);
} else {
relativeEnd = Math.min(end, size);
}
if (contentType === undefined) {
relativeContentType = "";
} else {
// sanitization (lower case and invalid char check) is done in the
// constructor
relativeContentType = contentType;
}
const span = Math.max(relativeEnd - relativeStart, 0);
const buffer = this._buffer;
const slicedBuffer = buffer.slice(
relativeStart,
relativeStart + span
);
const blob = Blob.createImpl(this._globalObject, [[], { type: relativeContentType }], {});
blob._buffer = slicedBuffer;
return blob;
}
};
+12
View File
@@ -0,0 +1,12 @@
"use strict";
const BlobImpl = require("./Blob-impl").implementation;
exports.implementation = class FileImpl extends BlobImpl {
constructor(globalObject, [fileBits, fileName, options], privateData) {
super(globalObject, [fileBits, options], privateData);
this.name = fileName;
this.lastModified = "lastModified" in options ? options.lastModified : Date.now();
}
};
@@ -0,0 +1,15 @@
"use strict";
const idlUtils = require("../generated/utils.js");
exports.implementation = class FileListImpl extends Array {
constructor() {
super(0);
}
item(index) {
return this[index] || null;
}
get [idlUtils.supportedPropertyIndices]() {
return this.keys();
}
};
@@ -0,0 +1,130 @@
"use strict";
const whatwgEncoding = require("whatwg-encoding");
const MIMEType = require("whatwg-mimetype");
const DOMException = require("domexception/webidl2js-wrapper");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const ProgressEvent = require("../generated/ProgressEvent");
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
const { fireAnEvent } = require("../helpers/events");
const { copyToArrayBufferInNewRealm } = require("../helpers/binary-data");
const READY_STATES = Object.freeze({
EMPTY: 0,
LOADING: 1,
DONE: 2
});
const events = ["loadstart", "progress", "load", "abort", "error", "loadend"];
class FileReaderImpl extends EventTargetImpl {
constructor(globalObject, args, privateData) {
super(globalObject, args, privateData);
this.error = null;
this.readyState = READY_STATES.EMPTY;
this.result = null;
this._globalObject = globalObject;
this._ownerDocument = globalObject.document;
this._terminated = false;
}
readAsArrayBuffer(file) {
this._readFile(file, "buffer");
}
readAsBinaryString(file) {
this._readFile(file, "binaryString");
}
readAsDataURL(file) {
this._readFile(file, "dataURL");
}
readAsText(file, encoding) {
this._readFile(file, "text", whatwgEncoding.labelToName(encoding) || "UTF-8");
}
abort() {
if (this.readyState === READY_STATES.EMPTY || this.readyState === READY_STATES.DONE) {
this.result = null;
return;
}
if (this.readyState === READY_STATES.LOADING) {
this.readyState = READY_STATES.DONE;
this.result = null;
}
this._terminated = true;
this._fireProgressEvent("abort");
this._fireProgressEvent("loadend");
}
_fireProgressEvent(name, props) {
fireAnEvent(name, this, ProgressEvent, props);
}
_readFile(file, format, encoding) {
if (this.readyState === READY_STATES.LOADING) {
throw DOMException.create(this._globalObject, [
"The object is in an invalid state.",
"InvalidStateError"
]);
}
this.readyState = READY_STATES.LOADING;
setImmediate(() => {
if (this._terminated) {
this._terminated = false;
return;
}
this._fireProgressEvent("loadstart");
let data = file._buffer;
if (!data) {
data = Buffer.alloc(0);
}
this._fireProgressEvent("progress", {
lengthComputable: !isNaN(file.size),
total: file.size,
loaded: data.length
});
setImmediate(() => {
if (this._terminated) {
this._terminated = false;
return;
}
switch (format) {
case "binaryString": {
this.result = data.toString("binary");
break;
}
case "dataURL": {
// Spec seems very unclear here; see https://github.com/w3c/FileAPI/issues/104.
const contentType = MIMEType.parse(file.type) || "application/octet-stream";
this.result = `data:${contentType};base64,${data.toString("base64")}`;
break;
}
case "text": {
this.result = whatwgEncoding.decode(data, encoding);
break;
}
case "buffer":
default: {
this.result = copyToArrayBufferInNewRealm(data, this._globalObject);
break;
}
}
this.readyState = READY_STATES.DONE;
this._fireProgressEvent("load");
this._fireProgressEvent("loadend");
});
});
}
}
setupForSimpleEventAccessors(FileReaderImpl.prototype, events);
exports.implementation = FileReaderImpl;
@@ -0,0 +1,130 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "AbortController";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'AbortController'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["AbortController"];
if (ctor === undefined) {
throw new Error("Internal error: constructor AbortController is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class AbortController {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
abort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'abort' called on an object that is not a valid instance of AbortController.");
}
return esValue[implSymbol].abort();
}
get signal() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get signal' called on an object that is not a valid instance of AbortController.");
}
return utils.getSameObject(this, "signal", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["signal"]);
});
}
}
Object.defineProperties(AbortController.prototype, {
abort: { enumerable: true },
signal: { enumerable: true },
[Symbol.toStringTag]: { value: "AbortController", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = AbortController;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: AbortController
});
};
const Impl = require("../aborting/AbortController-impl.js");
@@ -0,0 +1,159 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const EventTarget = require("./EventTarget.js");
const interfaceName = "AbortSignal";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'AbortSignal'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["AbortSignal"];
if (ctor === undefined) {
throw new Error("Internal error: constructor AbortSignal is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
EventTarget._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.EventTarget === undefined) {
throw new Error("Internal error: attempting to evaluate AbortSignal before EventTarget");
}
class AbortSignal extends globalObject.EventTarget {
constructor() {
throw new TypeError("Illegal constructor");
}
get aborted() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get aborted' called on an object that is not a valid instance of AbortSignal.");
}
return esValue[implSymbol]["aborted"];
}
get onabort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onabort' called on an object that is not a valid instance of AbortSignal.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
}
set onabort(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onabort' called on an object that is not a valid instance of AbortSignal.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onabort' property on 'AbortSignal': The provided value"
});
}
esValue[implSymbol]["onabort"] = V;
}
static abort() {
return utils.tryWrapperForImpl(Impl.implementation.abort(globalObject));
}
}
Object.defineProperties(AbortSignal.prototype, {
aborted: { enumerable: true },
onabort: { enumerable: true },
[Symbol.toStringTag]: { value: "AbortSignal", configurable: true }
});
Object.defineProperties(AbortSignal, { abort: { enumerable: true } });
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = AbortSignal;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: AbortSignal
});
};
const Impl = require("../aborting/AbortSignal-impl.js");
@@ -0,0 +1,162 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "AbstractRange";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'AbstractRange'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["AbstractRange"];
if (ctor === undefined) {
throw new Error("Internal error: constructor AbstractRange is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class AbstractRange {
constructor() {
throw new TypeError("Illegal constructor");
}
get startContainer() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get startContainer' called on an object that is not a valid instance of AbstractRange.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["startContainer"]);
}
get startOffset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get startOffset' called on an object that is not a valid instance of AbstractRange.");
}
return esValue[implSymbol]["startOffset"];
}
get endContainer() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get endContainer' called on an object that is not a valid instance of AbstractRange.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["endContainer"]);
}
get endOffset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get endOffset' called on an object that is not a valid instance of AbstractRange.");
}
return esValue[implSymbol]["endOffset"];
}
get collapsed() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get collapsed' called on an object that is not a valid instance of AbstractRange.");
}
return esValue[implSymbol]["collapsed"];
}
}
Object.defineProperties(AbstractRange.prototype, {
startContainer: { enumerable: true },
startOffset: { enumerable: true },
endContainer: { enumerable: true },
endOffset: { enumerable: true },
collapsed: { enumerable: true },
[Symbol.toStringTag]: { value: "AbstractRange", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = AbstractRange;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: AbstractRange
});
};
const Impl = require("../range/AbstractRange-impl.js");
@@ -0,0 +1,44 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventListenerOptions = require("./EventListenerOptions.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventListenerOptions._convertInherit(obj, ret, { context });
{
const key = "once";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'once' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "passive";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'passive' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,28 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "flatten";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'flatten' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
+215
View File
@@ -0,0 +1,215 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Node = require("./Node.js");
const interfaceName = "Attr";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Attr'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["Attr"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Attr is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate Attr before Node");
}
class Attr extends globalObject.Node {
constructor() {
throw new TypeError("Illegal constructor");
}
get namespaceURI() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get namespaceURI' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["namespaceURI"];
}
get prefix() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get prefix' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["prefix"];
}
get localName() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get localName' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["localName"];
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["name"];
}
get value() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get value' called on an object that is not a valid instance of Attr.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["value"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set value(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set value' called on an object that is not a valid instance of Attr.");
}
V = conversions["DOMString"](V, { context: "Failed to set the 'value' property on 'Attr': The provided value" });
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["value"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get ownerElement() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get ownerElement' called on an object that is not a valid instance of Attr.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["ownerElement"]);
}
get specified() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get specified' called on an object that is not a valid instance of Attr.");
}
return esValue[implSymbol]["specified"];
}
}
Object.defineProperties(Attr.prototype, {
namespaceURI: { enumerable: true },
prefix: { enumerable: true },
localName: { enumerable: true },
name: { enumerable: true },
value: { enumerable: true },
ownerElement: { enumerable: true },
specified: { enumerable: true },
[Symbol.toStringTag]: { value: "Attr", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Attr;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Attr
});
};
const Impl = require("../attributes/Attr-impl.js");
+118
View File
@@ -0,0 +1,118 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "BarProp";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'BarProp'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["BarProp"];
if (ctor === undefined) {
throw new Error("Internal error: constructor BarProp is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class BarProp {
constructor() {
throw new TypeError("Illegal constructor");
}
get visible() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get visible' called on an object that is not a valid instance of BarProp.");
}
return esValue[implSymbol]["visible"];
}
}
Object.defineProperties(BarProp.prototype, {
visible: { enumerable: true },
[Symbol.toStringTag]: { value: "BarProp", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = BarProp;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: BarProp
});
};
const Impl = require("../window/BarProp-impl.js");
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["blob", "arraybuffer"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for BinaryType`);
}
return string;
};
+198
View File
@@ -0,0 +1,198 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "Blob";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Blob'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["Blob"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Blob is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class Blob {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
if (!utils.isObject(curArg)) {
throw new TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object.");
} else {
const V = [];
const tmp = curArg;
for (let nextItem of tmp) {
if (exports.is(nextItem)) {
nextItem = utils.implForWrapper(nextItem);
} else if (utils.isArrayBuffer(nextItem)) {
} else if (ArrayBuffer.isView(nextItem)) {
} else {
nextItem = conversions["USVString"](nextItem, {
context: "Failed to construct 'Blob': parameter 1" + "'s element"
});
}
V.push(nextItem);
}
curArg = V;
}
}
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = BlobPropertyBag.convert(curArg, { context: "Failed to construct 'Blob': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
slice() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'slice' called on an object that is not a valid instance of Blob.");
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["long long"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 1",
clamp: true
});
}
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["long long"](curArg, {
context: "Failed to execute 'slice' on 'Blob': parameter 2",
clamp: true
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'slice' on 'Blob': parameter 3" });
}
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].slice(...args));
}
get size() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get size' called on an object that is not a valid instance of Blob.");
}
return esValue[implSymbol]["size"];
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of Blob.");
}
return esValue[implSymbol]["type"];
}
}
Object.defineProperties(Blob.prototype, {
slice: { enumerable: true },
size: { enumerable: true },
type: { enumerable: true },
[Symbol.toStringTag]: { value: "Blob", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Blob;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Blob
});
};
const Impl = require("../file-api/Blob-impl.js");
@@ -0,0 +1,34 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(blob) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
blob = utils.tryWrapperForImpl(blob);
callResult = Reflect.apply(value, thisArg, [blob]);
}
invokeTheCallbackFunction.construct = blob => {
blob = utils.tryWrapperForImpl(blob);
let callResult = Reflect.construct(value, [blob]);
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
@@ -0,0 +1,42 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EndingType = require("./EndingType.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "endings";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = EndingType.convert(value, { context: context + " has member 'endings' that" });
ret[key] = value;
} else {
ret[key] = "transparent";
}
}
{
const key = "type";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'type' that" });
ret[key] = value;
} else {
ret[key] = "";
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,114 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Text = require("./Text.js");
const interfaceName = "CDATASection";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CDATASection'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["CDATASection"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CDATASection is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Text._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Text === undefined) {
throw new Error("Internal error: attempting to evaluate CDATASection before Text");
}
class CDATASection extends globalObject.Text {
constructor() {
throw new TypeError("Illegal constructor");
}
}
Object.defineProperties(CDATASection.prototype, {
[Symbol.toStringTag]: { value: "CDATASection", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CDATASection;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CDATASection
});
};
const Impl = require("../nodes/CDATASection-impl.js");
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["", "maybe", "probably"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for CanPlayTypeResult`);
}
return string;
};
@@ -0,0 +1,436 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "CharacterData";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CharacterData'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["CharacterData"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CharacterData is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate CharacterData before Node");
}
class CharacterData extends globalObject.Node {
constructor() {
throw new TypeError("Illegal constructor");
}
substringData(offset, count) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'substringData' called on an object that is not a valid instance of CharacterData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'substringData' on 'CharacterData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'substringData' on 'CharacterData': parameter 2"
});
args.push(curArg);
}
return esValue[implSymbol].substringData(...args);
}
appendData(data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'appendData' called on an object that is not a valid instance of CharacterData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'appendData' on 'CharacterData': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].appendData(...args);
}
insertData(offset, data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'insertData' called on an object that is not a valid instance of CharacterData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'insertData' on 'CharacterData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'insertData' on 'CharacterData': parameter 2"
});
args.push(curArg);
}
return esValue[implSymbol].insertData(...args);
}
deleteData(offset, count) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'deleteData' called on an object that is not a valid instance of CharacterData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2"
});
args.push(curArg);
}
return esValue[implSymbol].deleteData(...args);
}
replaceData(offset, count, data) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceData' called on an object that is not a valid instance of CharacterData.");
}
if (arguments.length < 3) {
throw new TypeError(
"Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceData' on 'CharacterData': parameter 3"
});
args.push(curArg);
}
return esValue[implSymbol].replaceData(...args);
}
before() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'before' called on an object that is not a valid instance of CharacterData.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].before(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
after() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'after' called on an object that is not a valid instance of CharacterData.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].after(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
replaceWith() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceWith' called on an object that is not a valid instance of CharacterData.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replaceWith(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'remove' called on an object that is not a valid instance of CharacterData.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].remove();
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get data() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get data' called on an object that is not a valid instance of CharacterData.");
}
return esValue[implSymbol]["data"];
}
set data(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set data' called on an object that is not a valid instance of CharacterData.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'data' property on 'CharacterData': The provided value",
treatNullAsEmptyString: true
});
esValue[implSymbol]["data"] = V;
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of CharacterData.");
}
return esValue[implSymbol]["length"];
}
get previousElementSibling() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'get previousElementSibling' called on an object that is not a valid instance of CharacterData."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["previousElementSibling"]);
}
get nextElementSibling() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'get nextElementSibling' called on an object that is not a valid instance of CharacterData."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["nextElementSibling"]);
}
}
Object.defineProperties(CharacterData.prototype, {
substringData: { enumerable: true },
appendData: { enumerable: true },
insertData: { enumerable: true },
deleteData: { enumerable: true },
replaceData: { enumerable: true },
before: { enumerable: true },
after: { enumerable: true },
replaceWith: { enumerable: true },
remove: { enumerable: true },
data: { enumerable: true },
length: { enumerable: true },
previousElementSibling: { enumerable: true },
nextElementSibling: { enumerable: true },
[Symbol.toStringTag]: { value: "CharacterData", configurable: true },
[Symbol.unscopables]: {
value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null },
configurable: true
}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CharacterData;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CharacterData
});
};
const Impl = require("../nodes/CharacterData-impl.js");
@@ -0,0 +1,164 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CloseEventInit = require("./CloseEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "CloseEvent";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CloseEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["CloseEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CloseEvent is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Event === undefined) {
throw new Error("Internal error: attempting to evaluate CloseEvent before Event");
}
class CloseEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'CloseEvent': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CloseEvent': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CloseEventInit.convert(curArg, { context: "Failed to construct 'CloseEvent': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get wasClean() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get wasClean' called on an object that is not a valid instance of CloseEvent.");
}
return esValue[implSymbol]["wasClean"];
}
get code() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get code' called on an object that is not a valid instance of CloseEvent.");
}
return esValue[implSymbol]["code"];
}
get reason() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get reason' called on an object that is not a valid instance of CloseEvent.");
}
return esValue[implSymbol]["reason"];
}
}
Object.defineProperties(CloseEvent.prototype, {
wasClean: { enumerable: true },
code: { enumerable: true },
reason: { enumerable: true },
[Symbol.toStringTag]: { value: "CloseEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CloseEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CloseEvent
});
};
const Impl = require("../events/CloseEvent-impl.js");
@@ -0,0 +1,56 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(obj, ret, { context });
{
const key = "code";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned short"](value, { context: context + " has member 'code' that" });
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "reason";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["USVString"](value, { context: context + " has member 'reason' that" });
ret[key] = value;
} else {
ret[key] = "";
}
}
{
const key = "wasClean";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'wasClean' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
+122
View File
@@ -0,0 +1,122 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const CharacterData = require("./CharacterData.js");
const interfaceName = "Comment";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Comment'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["Comment"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Comment is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
CharacterData._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.CharacterData === undefined) {
throw new Error("Internal error: attempting to evaluate Comment before CharacterData");
}
class Comment extends globalObject.CharacterData {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Comment': parameter 1" });
} else {
curArg = "";
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
}
Object.defineProperties(Comment.prototype, { [Symbol.toStringTag]: { value: "Comment", configurable: true } });
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Comment;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Comment
});
};
const Impl = require("../nodes/Comment-impl.js");
@@ -0,0 +1,217 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CompositionEventInit = require("./CompositionEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const UIEvent = require("./UIEvent.js");
const interfaceName = "CompositionEvent";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CompositionEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["CompositionEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CompositionEvent is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
UIEvent._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.UIEvent === undefined) {
throw new Error("Internal error: attempting to evaluate CompositionEvent before UIEvent");
}
class CompositionEvent extends globalObject.UIEvent {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'CompositionEvent': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CompositionEvent': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CompositionEventInit.convert(curArg, {
context: "Failed to construct 'CompositionEvent': parameter 2"
});
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
initCompositionEvent(typeArg) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'initCompositionEvent' called on an object that is not a valid instance of CompositionEvent."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'initCompositionEvent' on 'CompositionEvent': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2"
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3"
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[3];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = utils.tryImplForWrapper(curArg);
}
} else {
curArg = null;
}
args.push(curArg);
}
{
let curArg = arguments[4];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5"
});
} else {
curArg = "";
}
args.push(curArg);
}
return esValue[implSymbol].initCompositionEvent(...args);
}
get data() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get data' called on an object that is not a valid instance of CompositionEvent.");
}
return esValue[implSymbol]["data"];
}
}
Object.defineProperties(CompositionEvent.prototype, {
initCompositionEvent: { enumerable: true },
data: { enumerable: true },
[Symbol.toStringTag]: { value: "CompositionEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CompositionEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CompositionEvent
});
};
const Impl = require("../events/CompositionEvent-impl.js");
@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(obj, ret, { context });
{
const key = "data";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'data' that" });
ret[key] = value;
} else {
ret[key] = "";
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,38 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
}
function invokeTheCallbackFunction() {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
callResult = Reflect.apply(value, thisArg, []);
callResult = conversions["any"](callResult, { context: context });
return callResult;
}
invokeTheCallbackFunction.construct = () => {
let callResult = Reflect.construct(value, []);
callResult = conversions["any"](callResult, { context: context });
return callResult;
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
@@ -0,0 +1,242 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CustomElementConstructor = require("./CustomElementConstructor.js");
const ElementDefinitionOptions = require("./ElementDefinitionOptions.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const Node = require("./Node.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "CustomElementRegistry";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CustomElementRegistry'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["CustomElementRegistry"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CustomElementRegistry is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class CustomElementRegistry {
constructor() {
throw new TypeError("Illegal constructor");
}
define(name, constructor) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'define' called on an object that is not a valid instance of CustomElementRegistry.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'define' on 'CustomElementRegistry': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CustomElementConstructor.convert(curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = ElementDefinitionOptions.convert(curArg, {
context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 3"
});
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].define(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get' called on an object that is not a valid instance of CustomElementRegistry.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'get' on 'CustomElementRegistry': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'get' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].get(...args);
}
whenDefined(name) {
try {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'whenDefined' called on an object that is not a valid instance of CustomElementRegistry."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'whenDefined' on 'CustomElementRegistry': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'whenDefined' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].whenDefined(...args));
} catch (e) {
return Promise.reject(e);
}
}
upgrade(root) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'upgrade' called on an object that is not a valid instance of CustomElementRegistry.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'upgrade' on 'CustomElementRegistry': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Node.convert(curArg, {
context: "Failed to execute 'upgrade' on 'CustomElementRegistry': parameter 1"
});
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].upgrade(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(CustomElementRegistry.prototype, {
define: { enumerable: true },
get: { enumerable: true },
whenDefined: { enumerable: true },
upgrade: { enumerable: true },
[Symbol.toStringTag]: { value: "CustomElementRegistry", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CustomElementRegistry;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CustomElementRegistry
});
};
const Impl = require("../custom-elements/CustomElementRegistry-impl.js");
@@ -0,0 +1,200 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CustomEventInit = require("./CustomEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "CustomEvent";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'CustomEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["CustomEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor CustomEvent is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Event === undefined) {
throw new Error("Internal error: attempting to evaluate CustomEvent before Event");
}
class CustomEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'CustomEvent': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = CustomEventInit.convert(curArg, { context: "Failed to construct 'CustomEvent': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
initCustomEvent(type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'initCustomEvent' called on an object that is not a valid instance of CustomEvent.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'initCustomEvent' on 'CustomEvent': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2"
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3"
});
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[3];
if (curArg !== undefined) {
curArg = conversions["any"](curArg, {
context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4"
});
} else {
curArg = null;
}
args.push(curArg);
}
return esValue[implSymbol].initCustomEvent(...args);
}
get detail() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get detail' called on an object that is not a valid instance of CustomEvent.");
}
return esValue[implSymbol]["detail"];
}
}
Object.defineProperties(CustomEvent.prototype, {
initCustomEvent: { enumerable: true },
detail: { enumerable: true },
[Symbol.toStringTag]: { value: "CustomEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = CustomEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: CustomEvent
});
};
const Impl = require("../events/CustomEvent-impl.js");
@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(obj, ret, { context });
{
const key = "detail";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["any"](value, { context: context + " has member 'detail' that" });
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,232 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const DocumentType = require("./DocumentType.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMImplementation";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMImplementation'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["DOMImplementation"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMImplementation is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class DOMImplementation {
constructor() {
throw new TypeError("Illegal constructor");
}
createDocumentType(qualifiedName, publicId, systemId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'createDocumentType' called on an object that is not a valid instance of DOMImplementation."
);
}
if (arguments.length < 3) {
throw new TypeError(
"Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2"
});
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentType(...args));
}
createDocument(namespace, qualifiedName) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'createDocument' called on an object that is not a valid instance of DOMImplementation.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1"
});
}
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 2",
treatNullAsEmptyString: true
});
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = DocumentType.convert(curArg, {
context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 3"
});
}
} else {
curArg = null;
}
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args));
}
createHTMLDocument() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'createHTMLDocument' called on an object that is not a valid instance of DOMImplementation."
);
}
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1"
});
}
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args));
}
hasFeature() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'hasFeature' called on an object that is not a valid instance of DOMImplementation.");
}
return esValue[implSymbol].hasFeature();
}
}
Object.defineProperties(DOMImplementation.prototype, {
createDocumentType: { enumerable: true },
createDocument: { enumerable: true },
createHTMLDocument: { enumerable: true },
hasFeature: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMImplementation", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMImplementation;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMImplementation
});
};
const Impl = require("../nodes/DOMImplementation-impl.js");
+140
View File
@@ -0,0 +1,140 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const SupportedType = require("./SupportedType.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMParser";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMParser'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["DOMParser"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMParser is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class DOMParser {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
parseFromString(str, type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'parseFromString' called on an object that is not a valid instance of DOMParser.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = SupportedType.convert(curArg, {
context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 2"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].parseFromString(...args));
}
}
Object.defineProperties(DOMParser.prototype, {
parseFromString: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMParser", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMParser;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMParser
});
};
const Impl = require("../domparsing/DOMParser-impl.js");
@@ -0,0 +1,322 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMStringMap";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMStringMap'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["DOMStringMap"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMStringMap is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
function makeProxy(wrapper, globalObject) {
let proxyHandler = proxyHandlerCache.get(globalObject);
if (proxyHandler === undefined) {
proxyHandler = new ProxyHandler(globalObject);
proxyHandlerCache.set(globalObject, proxyHandler);
}
return new Proxy(wrapper, proxyHandler);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class DOMStringMap {
constructor() {
throw new TypeError("Illegal constructor");
}
}
Object.defineProperties(DOMStringMap.prototype, {
[Symbol.toStringTag]: { value: "DOMStringMap", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMStringMap;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMStringMap
});
};
const proxyHandlerCache = new WeakMap();
class ProxyHandler {
constructor(globalObject) {
this._globalObject = globalObject;
}
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
}
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
}
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyNames]) {
if (!utils.hasOwn(target, key)) {
keys.add(`${key}`);
}
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
}
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
const namedValue = target[implSymbol][utils.namedGet](P);
if (namedValue !== undefined && !utils.hasOwn(target, P) && !ignoreNamedProps) {
return {
writable: true,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(namedValue)
};
}
return Reflect.getOwnPropertyDescriptor(target, P);
}
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
const globalObject = this._globalObject;
if (typeof P === "string") {
let namedValue = V;
namedValue = conversions["DOMString"](namedValue, {
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const creating = !(target[implSymbol][utils.namedGet](P) !== undefined);
if (creating) {
target[implSymbol][utils.namedSetNew](P, namedValue);
} else {
target[implSymbol][utils.namedSetExisting](P, namedValue);
}
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
return true;
}
}
let ownDesc;
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
if (ownDesc === undefined) {
const parent = Reflect.getPrototypeOf(target);
if (parent !== null) {
return Reflect.set(parent, P, V, receiver);
}
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
}
if (!ownDesc.writable) {
return false;
}
if (!utils.isObject(receiver)) {
return false;
}
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
let valueDesc;
if (existingDesc !== undefined) {
if (existingDesc.get || existingDesc.set) {
return false;
}
if (!existingDesc.writable) {
return false;
}
valueDesc = { value: V };
} else {
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
}
return Reflect.defineProperty(receiver, P, valueDesc);
}
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
const globalObject = this._globalObject;
if (desc.get || desc.set) {
return false;
}
let namedValue = desc.value;
namedValue = conversions["DOMString"](namedValue, {
context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const creating = !(target[implSymbol][utils.namedGet](P) !== undefined);
if (creating) {
target[implSymbol][utils.namedSetNew](P, namedValue);
} else {
target[implSymbol][utils.namedSetExisting](P, namedValue);
}
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
return true;
}
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
const globalObject = this._globalObject;
if (target[implSymbol][utils.namedGet](P) !== undefined && !utils.hasOwn(target, P)) {
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
target[implSymbol][utils.namedDelete](P);
return true;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../nodes/DOMStringMap-impl.js");
@@ -0,0 +1,531 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DOMTokenList";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DOMTokenList'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["DOMTokenList"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DOMTokenList is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class DOMTokenList {
constructor() {
throw new TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'item' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'item' on 'DOMTokenList': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'item' on 'DOMTokenList': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].item(...args);
}
contains(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'contains' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'contains' on 'DOMTokenList': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].contains(...args);
}
add() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'add' called on an object that is not a valid instance of DOMTokenList.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'add' on 'DOMTokenList': parameter " + (i + 1)
});
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].add(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'remove' called on an object that is not a valid instance of DOMTokenList.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'remove' on 'DOMTokenList': parameter " + (i + 1)
});
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].remove(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
toggle(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'toggle' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2"
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].toggle(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
replace(token, newToken) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replace' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'replace' on 'DOMTokenList': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2"
});
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replace(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
supports(token) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'supports' called on an object that is not a valid instance of DOMTokenList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'supports' on 'DOMTokenList': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'supports' on 'DOMTokenList': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].supports(...args);
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of DOMTokenList.");
}
return esValue[implSymbol]["length"];
}
get value() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get value' called on an object that is not a valid instance of DOMTokenList.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["value"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set value(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set value' called on an object that is not a valid instance of DOMTokenList.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'value' property on 'DOMTokenList': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["value"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new TypeError("'toString' called on an object that is not a valid instance of DOMTokenList.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["value"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(DOMTokenList.prototype, {
item: { enumerable: true },
contains: { enumerable: true },
add: { enumerable: true },
remove: { enumerable: true },
toggle: { enumerable: true },
replace: { enumerable: true },
supports: { enumerable: true },
length: { enumerable: true },
value: { enumerable: true },
toString: { enumerable: true },
[Symbol.toStringTag]: { value: "DOMTokenList", configurable: true },
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true },
keys: { value: Array.prototype.keys, configurable: true, enumerable: true, writable: true },
values: { value: Array.prototype[Symbol.iterator], configurable: true, enumerable: true, writable: true },
entries: { value: Array.prototype.entries, configurable: true, enumerable: true, writable: true },
forEach: { value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DOMTokenList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DOMTokenList
});
};
const proxyHandler = {
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
},
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
},
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
},
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
return Reflect.getOwnPropertyDescriptor(target, P);
},
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
if (ownDesc === undefined) {
const parent = Reflect.getPrototypeOf(target);
if (parent !== null) {
return Reflect.set(parent, P, V, receiver);
}
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
}
if (!ownDesc.writable) {
return false;
}
if (!utils.isObject(receiver)) {
return false;
}
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
let valueDesc;
if (existingDesc !== undefined) {
if (existingDesc.get || existingDesc.set) {
return false;
}
if (!existingDesc.writable) {
return false;
}
valueDesc = { value: V };
} else {
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
}
return Reflect.defineProperty(receiver, P, valueDesc);
},
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
if (utils.isArrayIndexPropName(P)) {
return false;
}
return Reflect.defineProperty(target, P, desc);
},
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
return !(target[implSymbol].item(index) !== null);
}
return Reflect.deleteProperty(target, P);
},
preventExtensions() {
return false;
}
};
const Impl = require("../nodes/DOMTokenList-impl.js");
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,325 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DocumentFragment";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DocumentFragment'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["DocumentFragment"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DocumentFragment is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate DocumentFragment before Node");
}
class DocumentFragment extends globalObject.Node {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
getElementById(elementId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'getElementById' called on an object that is not a valid instance of DocumentFragment.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'getElementById' on 'DocumentFragment': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'getElementById' on 'DocumentFragment': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args));
}
prepend() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'prepend' called on an object that is not a valid instance of DocumentFragment.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].prepend(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
append() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'append' called on an object that is not a valid instance of DocumentFragment.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].append(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
replaceChildren() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceChildren' called on an object that is not a valid instance of DocumentFragment.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceChildren' on 'DocumentFragment': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return utils.tryWrapperForImpl(esValue[implSymbol].replaceChildren(...args));
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
querySelector(selectors) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'querySelector' called on an object that is not a valid instance of DocumentFragment.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'querySelector' on 'DocumentFragment': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'querySelector' on 'DocumentFragment': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args));
}
querySelectorAll(selectors) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'querySelectorAll' called on an object that is not a valid instance of DocumentFragment.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'querySelectorAll' on 'DocumentFragment': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'querySelectorAll' on 'DocumentFragment': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args));
}
get children() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get children' called on an object that is not a valid instance of DocumentFragment.");
}
return utils.getSameObject(this, "children", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["children"]);
});
}
get firstElementChild() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'get firstElementChild' called on an object that is not a valid instance of DocumentFragment."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["firstElementChild"]);
}
get lastElementChild() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'get lastElementChild' called on an object that is not a valid instance of DocumentFragment."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol]["lastElementChild"]);
}
get childElementCount() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'get childElementCount' called on an object that is not a valid instance of DocumentFragment."
);
}
return esValue[implSymbol]["childElementCount"];
}
}
Object.defineProperties(DocumentFragment.prototype, {
getElementById: { enumerable: true },
prepend: { enumerable: true },
append: { enumerable: true },
replaceChildren: { enumerable: true },
querySelector: { enumerable: true },
querySelectorAll: { enumerable: true },
children: { enumerable: true },
firstElementChild: { enumerable: true },
lastElementChild: { enumerable: true },
childElementCount: { enumerable: true },
[Symbol.toStringTag]: { value: "DocumentFragment", configurable: true },
[Symbol.unscopables]: {
value: { prepend: true, append: true, replaceChildren: true, __proto__: null },
configurable: true
}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DocumentFragment;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DocumentFragment
});
};
const Impl = require("../nodes/DocumentFragment-impl.js");
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["loading", "interactive", "complete"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for DocumentReadyState`);
}
return string;
};
@@ -0,0 +1,246 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "DocumentType";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'DocumentType'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["DocumentType"];
if (ctor === undefined) {
throw new Error("Internal error: constructor DocumentType is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Node._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Node === undefined) {
throw new Error("Internal error: attempting to evaluate DocumentType before Node");
}
class DocumentType extends globalObject.Node {
constructor() {
throw new TypeError("Illegal constructor");
}
before() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'before' called on an object that is not a valid instance of DocumentType.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].before(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
after() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'after' called on an object that is not a valid instance of DocumentType.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].after(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
replaceWith() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'replaceWith' called on an object that is not a valid instance of DocumentType.");
}
const args = [];
for (let i = 0; i < arguments.length; i++) {
let curArg = arguments[i];
if (Node.is(curArg)) {
curArg = utils.implForWrapper(curArg);
} else {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1)
});
}
args.push(curArg);
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].replaceWith(...args);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
remove() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'remove' called on an object that is not a valid instance of DocumentType.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].remove();
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of DocumentType.");
}
return esValue[implSymbol]["name"];
}
get publicId() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get publicId' called on an object that is not a valid instance of DocumentType.");
}
return esValue[implSymbol]["publicId"];
}
get systemId() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get systemId' called on an object that is not a valid instance of DocumentType.");
}
return esValue[implSymbol]["systemId"];
}
}
Object.defineProperties(DocumentType.prototype, {
before: { enumerable: true },
after: { enumerable: true },
replaceWith: { enumerable: true },
remove: { enumerable: true },
name: { enumerable: true },
publicId: { enumerable: true },
systemId: { enumerable: true },
[Symbol.toStringTag]: { value: "DocumentType", configurable: true },
[Symbol.unscopables]: {
value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null },
configurable: true
}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = DocumentType;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: DocumentType
});
};
const Impl = require("../nodes/DocumentType-impl.js");
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,26 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "is";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'is' that" });
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,26 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "extends";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'extends' that" });
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,12 @@
"use strict";
const enumerationValues = new Set(["transparent", "native"]);
exports.enumerationValues = enumerationValues;
exports.convert = function convert(value, { context = "The provided value" } = {}) {
const string = `${value}`;
if (!enumerationValues.has(string)) {
throw new TypeError(`${context} '${string}' is not a valid enumeration value for EndingType`);
}
return string;
};
@@ -0,0 +1,186 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const ErrorEventInit = require("./ErrorEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const Event = require("./Event.js");
const interfaceName = "ErrorEvent";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'ErrorEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["ErrorEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor ErrorEvent is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Event._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Event === undefined) {
throw new Error("Internal error: attempting to evaluate ErrorEvent before Event");
}
class ErrorEvent extends globalObject.Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'ErrorEvent': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = ErrorEventInit.convert(curArg, { context: "Failed to construct 'ErrorEvent': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get message() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get message' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["message"];
}
get filename() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get filename' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["filename"];
}
get lineno() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get lineno' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["lineno"];
}
get colno() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get colno' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["colno"];
}
get error() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get error' called on an object that is not a valid instance of ErrorEvent.");
}
return esValue[implSymbol]["error"];
}
}
Object.defineProperties(ErrorEvent.prototype, {
message: { enumerable: true },
filename: { enumerable: true },
lineno: { enumerable: true },
colno: { enumerable: true },
error: { enumerable: true },
[Symbol.toStringTag]: { value: "ErrorEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = ErrorEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: ErrorEvent
});
};
const Impl = require("../events/ErrorEvent-impl.js");
@@ -0,0 +1,80 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
EventInit._convertInherit(obj, ret, { context });
{
const key = "colno";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned long"](value, { context: context + " has member 'colno' that" });
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "error";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["any"](value, { context: context + " has member 'error' that" });
ret[key] = value;
} else {
ret[key] = null;
}
}
{
const key = "filename";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["USVString"](value, { context: context + " has member 'filename' that" });
ret[key] = value;
} else {
ret[key] = "";
}
}
{
const key = "lineno";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned long"](value, { context: context + " has member 'lineno' that" });
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "message";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member 'message' that" });
ret[key] = value;
} else {
ret[key] = "";
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
+390
View File
@@ -0,0 +1,390 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "Event";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'Event'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["Event"];
if (ctor === undefined) {
throw new Error("Internal error: constructor Event is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Object.defineProperties(
wrapper,
Object.getOwnPropertyDescriptors({
get isTrusted() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get isTrusted' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["isTrusted"];
}
})
);
Object.defineProperties(wrapper, { isTrusted: { configurable: false } });
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker", "AudioWorklet"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class Event {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'Event': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = EventInit.convert(curArg, { context: "Failed to construct 'Event': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
composedPath() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'composedPath' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol].composedPath());
}
stopPropagation() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'stopPropagation' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol].stopPropagation();
}
stopImmediatePropagation() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'stopImmediatePropagation' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol].stopImmediatePropagation();
}
preventDefault() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'preventDefault' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol].preventDefault();
}
initEvent(type) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'initEvent' called on an object that is not a valid instance of Event.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'initEvent' on 'Event': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 2" });
} else {
curArg = false;
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["boolean"](curArg, { context: "Failed to execute 'initEvent' on 'Event': parameter 3" });
} else {
curArg = false;
}
args.push(curArg);
}
return esValue[implSymbol].initEvent(...args);
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["type"];
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["target"]);
}
get srcElement() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get srcElement' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["srcElement"]);
}
get currentTarget() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get currentTarget' called on an object that is not a valid instance of Event.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["currentTarget"]);
}
get eventPhase() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get eventPhase' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["eventPhase"];
}
get cancelBubble() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get cancelBubble' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["cancelBubble"];
}
set cancelBubble(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set cancelBubble' called on an object that is not a valid instance of Event.");
}
V = conversions["boolean"](V, {
context: "Failed to set the 'cancelBubble' property on 'Event': The provided value"
});
esValue[implSymbol]["cancelBubble"] = V;
}
get bubbles() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get bubbles' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["bubbles"];
}
get cancelable() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get cancelable' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["cancelable"];
}
get returnValue() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get returnValue' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["returnValue"];
}
set returnValue(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set returnValue' called on an object that is not a valid instance of Event.");
}
V = conversions["boolean"](V, {
context: "Failed to set the 'returnValue' property on 'Event': The provided value"
});
esValue[implSymbol]["returnValue"] = V;
}
get defaultPrevented() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get defaultPrevented' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["defaultPrevented"];
}
get composed() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get composed' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["composed"];
}
get timeStamp() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get timeStamp' called on an object that is not a valid instance of Event.");
}
return esValue[implSymbol]["timeStamp"];
}
}
Object.defineProperties(Event.prototype, {
composedPath: { enumerable: true },
stopPropagation: { enumerable: true },
stopImmediatePropagation: { enumerable: true },
preventDefault: { enumerable: true },
initEvent: { enumerable: true },
type: { enumerable: true },
target: { enumerable: true },
srcElement: { enumerable: true },
currentTarget: { enumerable: true },
eventPhase: { enumerable: true },
cancelBubble: { enumerable: true },
bubbles: { enumerable: true },
cancelable: { enumerable: true },
returnValue: { enumerable: true },
defaultPrevented: { enumerable: true },
composed: { enumerable: true },
timeStamp: { enumerable: true },
[Symbol.toStringTag]: { value: "Event", configurable: true },
NONE: { value: 0, enumerable: true },
CAPTURING_PHASE: { value: 1, enumerable: true },
AT_TARGET: { value: 2, enumerable: true },
BUBBLING_PHASE: { value: 3, enumerable: true }
});
Object.defineProperties(Event, {
NONE: { value: 0, enumerable: true },
CAPTURING_PHASE: { value: 1, enumerable: true },
AT_TARGET: { value: 2, enumerable: true },
BUBBLING_PHASE: { value: 3, enumerable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Event;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Event
});
};
const Impl = require("../events/Event-impl.js");
@@ -0,0 +1,40 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
function invokeTheCallbackFunction(event) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
if (typeof value === "function") {
event = utils.tryWrapperForImpl(event);
callResult = Reflect.apply(value, thisArg, [event]);
}
callResult = conversions["any"](callResult, { context: context });
return callResult;
}
invokeTheCallbackFunction.construct = event => {
event = utils.tryWrapperForImpl(event);
let callResult = Reflect.construct(value, [event]);
callResult = conversions["any"](callResult, { context: context });
return callResult;
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
@@ -0,0 +1,52 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "bubbles";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'bubbles' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "cancelable";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'cancelable' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "composed";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'composed' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,35 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = function convert(value, { context = "The provided value" } = {}) {
if (!utils.isObject(value)) {
throw new TypeError(`${context} is not an object.`);
}
function callTheUserObjectsOperation(event) {
let thisArg = utils.tryWrapperForImpl(this);
let O = value;
let X = O;
if (typeof O !== "function") {
X = O["handleEvent"];
if (typeof X !== "function") {
throw new TypeError(`${context} does not correctly implement EventListener.`);
}
thisArg = O;
}
event = utils.tryWrapperForImpl(event);
let callResult = Reflect.apply(X, thisArg, [event]);
}
callTheUserObjectsOperation[utils.wrapperSymbol] = value;
callTheUserObjectsOperation.objectReference = value;
return callTheUserObjectsOperation;
};
exports.install = (globalObject, globalNames) => {};
@@ -0,0 +1,28 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "capture";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'capture' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,188 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(obj, ret, { context });
{
const key = "altKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'altKey' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "ctrlKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'ctrlKey' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "metaKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'metaKey' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierAltGraph";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierAltGraph' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierCapsLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierCapsLock' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierFn";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierFn' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierFnLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierFnLock' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierHyper";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierHyper' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierNumLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierNumLock' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierScrollLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierScrollLock' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierSuper";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierSuper' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierSymbol";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierSymbol' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "modifierSymbolLock";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'modifierSymbolLock' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
{
const key = "shiftKey";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'shiftKey' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,252 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventListener = require("./EventListener.js");
const AddEventListenerOptions = require("./AddEventListenerOptions.js");
const EventListenerOptions = require("./EventListenerOptions.js");
const Event = require("./Event.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "EventTarget";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'EventTarget'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["EventTarget"];
if (ctor === undefined) {
throw new Error("Internal error: constructor EventTarget is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker", "AudioWorklet"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class EventTarget {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
addEventListener(type, callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'addEventListener' called on an object that is not a valid instance of EventTarget.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = EventListener.convert(curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 2"
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = AddEventListenerOptions.convert(curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
});
} else if (utils.isObject(curArg)) {
curArg = AddEventListenerOptions.convert(curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3" + " dictionary"
});
} else if (typeof curArg === "boolean") {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
});
} else {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3"
});
}
}
args.push(curArg);
}
return esValue[implSymbol].addEventListener(...args);
}
removeEventListener(type, callback) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'removeEventListener' called on an object that is not a valid instance of EventTarget.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg === null || curArg === undefined) {
curArg = null;
} else {
curArg = EventListener.convert(curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 2"
});
}
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
if (curArg === null || curArg === undefined) {
curArg = EventListenerOptions.convert(curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
});
} else if (utils.isObject(curArg)) {
curArg = EventListenerOptions.convert(curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3" + " dictionary"
});
} else if (typeof curArg === "boolean") {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
});
} else {
curArg = conversions["boolean"](curArg, {
context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3"
});
}
}
args.push(curArg);
}
return esValue[implSymbol].removeEventListener(...args);
}
dispatchEvent(event) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'dispatchEvent' called on an object that is not a valid instance of EventTarget.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Event.convert(curArg, { context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1" });
args.push(curArg);
}
return esValue[implSymbol].dispatchEvent(...args);
}
}
Object.defineProperties(EventTarget.prototype, {
addEventListener: { enumerable: true },
removeEventListener: { enumerable: true },
dispatchEvent: { enumerable: true },
[Symbol.toStringTag]: { value: "EventTarget", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = EventTarget;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: EventTarget
});
};
const Impl = require("../events/EventTarget-impl.js");
+129
View File
@@ -0,0 +1,129 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "External";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'External'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["External"];
if (ctor === undefined) {
throw new Error("Internal error: constructor External is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class External {
constructor() {
throw new TypeError("Illegal constructor");
}
AddSearchProvider() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'AddSearchProvider' called on an object that is not a valid instance of External.");
}
return esValue[implSymbol].AddSearchProvider();
}
IsSearchProviderInstalled() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError(
"'IsSearchProviderInstalled' called on an object that is not a valid instance of External."
);
}
return esValue[implSymbol].IsSearchProviderInstalled();
}
}
Object.defineProperties(External.prototype, {
AddSearchProvider: { enumerable: true },
IsSearchProviderInstalled: { enumerable: true },
[Symbol.toStringTag]: { value: "External", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = External;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: External
});
};
const Impl = require("../window/External-impl.js");
+176
View File
@@ -0,0 +1,176 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const FilePropertyBag = require("./FilePropertyBag.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "File";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'File'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["File"];
if (ctor === undefined) {
throw new Error("Internal error: constructor File is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
Blob._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.Blob === undefined) {
throw new Error("Internal error: attempting to evaluate File before Blob");
}
class File extends globalObject.Blob {
constructor(fileBits, fileName) {
if (arguments.length < 2) {
throw new TypeError(
"Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
if (!utils.isObject(curArg)) {
throw new TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object.");
} else {
const V = [];
const tmp = curArg;
for (let nextItem of tmp) {
if (Blob.is(nextItem)) {
nextItem = utils.implForWrapper(nextItem);
} else if (utils.isArrayBuffer(nextItem)) {
} else if (ArrayBuffer.isView(nextItem)) {
} else {
nextItem = conversions["USVString"](nextItem, {
context: "Failed to construct 'File': parameter 1" + "'s element"
});
}
V.push(nextItem);
}
curArg = V;
}
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, { context: "Failed to construct 'File': parameter 2" });
args.push(curArg);
}
{
let curArg = arguments[2];
curArg = FilePropertyBag.convert(curArg, { context: "Failed to construct 'File': parameter 3" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of File.");
}
return esValue[implSymbol]["name"];
}
get lastModified() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get lastModified' called on an object that is not a valid instance of File.");
}
return esValue[implSymbol]["lastModified"];
}
}
Object.defineProperties(File.prototype, {
name: { enumerable: true },
lastModified: { enumerable: true },
[Symbol.toStringTag]: { value: "File", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = File;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: File
});
};
const Impl = require("../file-api/File-impl.js");
+305
View File
@@ -0,0 +1,305 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "FileList";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FileList'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["FileList"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FileList is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
let wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper = new Proxy(wrapper, proxyHandler);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class FileList {
constructor() {
throw new TypeError("Illegal constructor");
}
item(index) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'item' called on an object that is not a valid instance of FileList.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'item' on 'FileList': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["unsigned long"](curArg, {
context: "Failed to execute 'item' on 'FileList': parameter 1"
});
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].item(...args));
}
get length() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get length' called on an object that is not a valid instance of FileList.");
}
return esValue[implSymbol]["length"];
}
}
Object.defineProperties(FileList.prototype, {
item: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "FileList", configurable: true },
[Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FileList;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FileList
});
};
const proxyHandler = {
get(target, P, receiver) {
if (typeof P === "symbol") {
return Reflect.get(target, P, receiver);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc === undefined) {
const parent = Object.getPrototypeOf(target);
if (parent === null) {
return undefined;
}
return Reflect.get(target, P, receiver);
}
if (!desc.get && !desc.set) {
return desc.value;
}
const getter = desc.get;
if (getter === undefined) {
return undefined;
}
return Reflect.apply(getter, receiver, []);
},
has(target, P) {
if (typeof P === "symbol") {
return Reflect.has(target, P);
}
const desc = this.getOwnPropertyDescriptor(target, P);
if (desc !== undefined) {
return true;
}
const parent = Object.getPrototypeOf(target);
if (parent !== null) {
return Reflect.has(parent, P);
}
return false;
},
ownKeys(target) {
const keys = new Set();
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
keys.add(`${key}`);
}
for (const key of Reflect.ownKeys(target)) {
keys.add(key);
}
return [...keys];
},
getOwnPropertyDescriptor(target, P) {
if (typeof P === "symbol") {
return Reflect.getOwnPropertyDescriptor(target, P);
}
let ignoreNamedProps = false;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
return {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
ignoreNamedProps = true;
}
return Reflect.getOwnPropertyDescriptor(target, P);
},
set(target, P, V, receiver) {
if (typeof P === "symbol") {
return Reflect.set(target, P, V, receiver);
}
// The `receiver` argument refers to the Proxy exotic object or an object
// that inherits from it, whereas `target` refers to the Proxy target:
if (target[implSymbol][utils.wrapperSymbol] === receiver) {
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol].item(index);
if (indexedValue !== null) {
ownDesc = {
writable: false,
enumerable: true,
configurable: true,
value: utils.tryWrapperForImpl(indexedValue)
};
}
}
if (ownDesc === undefined) {
ownDesc = Reflect.getOwnPropertyDescriptor(target, P);
}
if (ownDesc === undefined) {
const parent = Reflect.getPrototypeOf(target);
if (parent !== null) {
return Reflect.set(parent, P, V, receiver);
}
ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined };
}
if (!ownDesc.writable) {
return false;
}
if (!utils.isObject(receiver)) {
return false;
}
const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P);
let valueDesc;
if (existingDesc !== undefined) {
if (existingDesc.get || existingDesc.set) {
return false;
}
if (!existingDesc.writable) {
return false;
}
valueDesc = { value: V };
} else {
valueDesc = { writable: true, enumerable: true, configurable: true, value: V };
}
return Reflect.defineProperty(receiver, P, valueDesc);
},
defineProperty(target, P, desc) {
if (typeof P === "symbol") {
return Reflect.defineProperty(target, P, desc);
}
if (utils.isArrayIndexPropName(P)) {
return false;
}
return Reflect.defineProperty(target, P, desc);
},
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
return !(target[implSymbol].item(index) !== null);
}
return Reflect.deleteProperty(target, P);
},
preventExtensions() {
return false;
}
};
const Impl = require("../file-api/FileList-impl.js");
@@ -0,0 +1,30 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
BlobPropertyBag._convertInherit(obj, ret, { context });
{
const key = "lastModified";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["long long"](value, { context: context + " has member 'lastModified' that" });
ret[key] = value;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,440 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const EventTarget = require("./EventTarget.js");
const interfaceName = "FileReader";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FileReader'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["FileReader"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FileReader is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
EventTarget._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.EventTarget === undefined) {
throw new Error("Internal error: attempting to evaluate FileReader before EventTarget");
}
class FileReader extends globalObject.EventTarget {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
readAsArrayBuffer(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsArrayBuffer' called on an object that is not a valid instance of FileReader.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsArrayBuffer' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, {
context: "Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].readAsArrayBuffer(...args);
}
readAsBinaryString(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsBinaryString' called on an object that is not a valid instance of FileReader.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsBinaryString' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, {
context: "Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1"
});
args.push(curArg);
}
return esValue[implSymbol].readAsBinaryString(...args);
}
readAsText(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsText' called on an object that is not a valid instance of FileReader.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsText' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, { context: "Failed to execute 'readAsText' on 'FileReader': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
if (curArg !== undefined) {
curArg = conversions["DOMString"](curArg, {
context: "Failed to execute 'readAsText' on 'FileReader': parameter 2"
});
}
args.push(curArg);
}
return esValue[implSymbol].readAsText(...args);
}
readAsDataURL(blob) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'readAsDataURL' called on an object that is not a valid instance of FileReader.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'readAsDataURL' on 'FileReader': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = Blob.convert(curArg, { context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1" });
args.push(curArg);
}
return esValue[implSymbol].readAsDataURL(...args);
}
abort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'abort' called on an object that is not a valid instance of FileReader.");
}
return esValue[implSymbol].abort();
}
get readyState() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get readyState' called on an object that is not a valid instance of FileReader.");
}
return esValue[implSymbol]["readyState"];
}
get result() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get result' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["result"]);
}
get error() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get error' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["error"]);
}
get onloadstart() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onloadstart' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]);
}
set onloadstart(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onloadstart' called on an object that is not a valid instance of FileReader.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onloadstart' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onloadstart"] = V;
}
get onprogress() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onprogress' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]);
}
set onprogress(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onprogress' called on an object that is not a valid instance of FileReader.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onprogress' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onprogress"] = V;
}
get onload() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onload' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]);
}
set onload(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onload' called on an object that is not a valid instance of FileReader.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onload' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onload"] = V;
}
get onabort() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onabort' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]);
}
set onabort(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onabort' called on an object that is not a valid instance of FileReader.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onabort' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onabort"] = V;
}
get onerror() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onerror' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]);
}
set onerror(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onerror' called on an object that is not a valid instance of FileReader.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onerror' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onerror"] = V;
}
get onloadend() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get onloadend' called on an object that is not a valid instance of FileReader.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]);
}
set onloadend(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set onloadend' called on an object that is not a valid instance of FileReader.");
}
if (!utils.isObject(V)) {
V = null;
} else {
V = EventHandlerNonNull.convert(V, {
context: "Failed to set the 'onloadend' property on 'FileReader': The provided value"
});
}
esValue[implSymbol]["onloadend"] = V;
}
}
Object.defineProperties(FileReader.prototype, {
readAsArrayBuffer: { enumerable: true },
readAsBinaryString: { enumerable: true },
readAsText: { enumerable: true },
readAsDataURL: { enumerable: true },
abort: { enumerable: true },
readyState: { enumerable: true },
result: { enumerable: true },
error: { enumerable: true },
onloadstart: { enumerable: true },
onprogress: { enumerable: true },
onload: { enumerable: true },
onabort: { enumerable: true },
onerror: { enumerable: true },
onloadend: { enumerable: true },
[Symbol.toStringTag]: { value: "FileReader", configurable: true },
EMPTY: { value: 0, enumerable: true },
LOADING: { value: 1, enumerable: true },
DONE: { value: 2, enumerable: true }
});
Object.defineProperties(FileReader, {
EMPTY: { value: 0, enumerable: true },
LOADING: { value: 1, enumerable: true },
DONE: { value: 2, enumerable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FileReader;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FileReader
});
};
const Impl = require("../file-api/FileReader-impl.js");
@@ -0,0 +1,142 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const FocusEventInit = require("./FocusEventInit.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const UIEvent = require("./UIEvent.js");
const interfaceName = "FocusEvent";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FocusEvent'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["FocusEvent"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FocusEvent is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
UIEvent._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.UIEvent === undefined) {
throw new Error("Internal error: attempting to evaluate FocusEvent before UIEvent");
}
class FocusEvent extends globalObject.UIEvent {
constructor(type) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'FocusEvent': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'FocusEvent': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = FocusEventInit.convert(curArg, { context: "Failed to construct 'FocusEvent': parameter 2" });
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
get relatedTarget() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get relatedTarget' called on an object that is not a valid instance of FocusEvent.");
}
return utils.tryWrapperForImpl(esValue[implSymbol]["relatedTarget"]);
}
}
Object.defineProperties(FocusEvent.prototype, {
relatedTarget: { enumerable: true },
[Symbol.toStringTag]: { value: "FocusEvent", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FocusEvent;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FocusEvent
});
};
const Impl = require("../events/FocusEvent-impl.js");
@@ -0,0 +1,36 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventTarget = require("./EventTarget.js");
const UIEventInit = require("./UIEventInit.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
UIEventInit._convertInherit(obj, ret, { context });
{
const key = "relatedTarget";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
if (value === null || value === undefined) {
value = null;
} else {
value = EventTarget.convert(value, { context: context + " has member 'relatedTarget' that" });
}
ret[key] = value;
} else {
ret[key] = null;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
+421
View File
@@ -0,0 +1,421 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLFormElement = require("./HTMLFormElement.js");
const Blob = require("./Blob.js");
const Function = require("./Function.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "FormData";
const IteratorPrototype = Object.create(utils.IteratorPrototype, {
next: {
value: function next() {
const internal = this && this[utils.iterInternalSymbol];
if (!internal) {
throw new TypeError("next() called on a value that is not an iterator prototype object");
}
const { target, kind, index } = internal;
const values = Array.from(target[implSymbol]);
const len = values.length;
if (index >= len) {
return { value: undefined, done: true };
}
const pair = values[index];
internal.index = index + 1;
return utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind);
},
writable: true,
enumerable: true,
configurable: true
},
[Symbol.toStringTag]: {
value: "FormData Iterator",
configurable: true
}
});
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'FormData'.`);
};
exports.createDefaultIterator = (target, kind) => {
const iterator = Object.create(IteratorPrototype);
Object.defineProperty(iterator, utils.iterInternalSymbol, {
value: { target, kind, index: 0 },
configurable: true
});
return iterator;
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["FormData"];
if (ctor === undefined) {
throw new Error("Internal error: constructor FormData is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window", "Worker"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
class FormData {
constructor() {
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = HTMLFormElement.convert(curArg, { context: "Failed to construct 'FormData': parameter 1" });
}
args.push(curArg);
}
return exports.setup(Object.create(new.target.prototype), globalObject, args);
}
append(name, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'append' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'append' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
);
}
const args = [];
switch (arguments.length) {
case 2:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (Blob.is(curArg)) {
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
args.push(curArg);
}
} else {
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 2"
});
args.push(curArg);
}
}
}
break;
default:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'append' on 'FormData': parameter 2" });
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'append' on 'FormData': parameter 3"
});
}
args.push(curArg);
}
}
return esValue[implSymbol].append(...args);
}
delete(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'delete' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'delete' on 'FormData': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'delete' on 'FormData': parameter 1" });
args.push(curArg);
}
return esValue[implSymbol].delete(...args);
}
get(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'get' on 'FormData': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'get' on 'FormData': parameter 1" });
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].get(...args));
}
getAll(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'getAll' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'getAll' on 'FormData': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'getAll' on 'FormData': parameter 1" });
args.push(curArg);
}
return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
}
has(name) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'has' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'has' on 'FormData': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, { context: "Failed to execute 'has' on 'FormData': parameter 1" });
args.push(curArg);
}
return esValue[implSymbol].has(...args);
}
set(name, value) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 2) {
throw new TypeError(
"Failed to execute 'set' on 'FormData': 2 arguments required, but only " + arguments.length + " present."
);
}
const args = [];
switch (arguments.length) {
case 2:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
if (Blob.is(curArg)) {
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
args.push(curArg);
}
} else {
{
let curArg = arguments[1];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 2"
});
args.push(curArg);
}
}
}
break;
default:
{
let curArg = arguments[0];
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 1"
});
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = Blob.convert(curArg, { context: "Failed to execute 'set' on 'FormData': parameter 2" });
args.push(curArg);
}
{
let curArg = arguments[2];
if (curArg !== undefined) {
curArg = conversions["USVString"](curArg, {
context: "Failed to execute 'set' on 'FormData': parameter 3"
});
}
args.push(curArg);
}
}
return esValue[implSymbol].set(...args);
}
keys() {
if (!exports.is(this)) {
throw new TypeError("'keys' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(this, "key");
}
values() {
if (!exports.is(this)) {
throw new TypeError("'values' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(this, "value");
}
entries() {
if (!exports.is(this)) {
throw new TypeError("'entries' called on an object that is not a valid instance of FormData.");
}
return exports.createDefaultIterator(this, "key+value");
}
forEach(callback) {
if (!exports.is(this)) {
throw new TypeError("'forEach' called on an object that is not a valid instance of FormData.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'forEach' on 'iterable': 1 argument required, " + "but only 0 present.");
}
callback = Function.convert(callback, {
context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
});
const thisArg = arguments[1];
let pairs = Array.from(this[implSymbol]);
let i = 0;
while (i < pairs.length) {
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
callback.call(thisArg, value, key, this);
pairs = Array.from(this[implSymbol]);
i++;
}
}
}
Object.defineProperties(FormData.prototype, {
append: { enumerable: true },
delete: { enumerable: true },
get: { enumerable: true },
getAll: { enumerable: true },
has: { enumerable: true },
set: { enumerable: true },
keys: { enumerable: true },
values: { enumerable: true },
entries: { enumerable: true },
forEach: { enumerable: true },
[Symbol.toStringTag]: { value: "FormData", configurable: true },
[Symbol.iterator]: { value: FormData.prototype.entries, configurable: true, writable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = FormData;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: FormData
});
};
const Impl = require("../xhr/FormData-impl.js");
+46
View File
@@ -0,0 +1,46 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports.convert = (value, { context = "The provided value" } = {}) => {
if (typeof value !== "function") {
throw new TypeError(context + " is not a function");
}
function invokeTheCallbackFunction(...args) {
if (new.target !== undefined) {
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
}
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
for (let i = 0; i < args.length; i++) {
args[i] = utils.tryWrapperForImpl(args[i]);
}
callResult = Reflect.apply(value, thisArg, args);
callResult = conversions["any"](callResult, { context: context });
return callResult;
}
invokeTheCallbackFunction.construct = (...args) => {
for (let i = 0; i < args.length; i++) {
args[i] = utils.tryWrapperForImpl(args[i]);
}
let callResult = Reflect.construct(value, args);
callResult = conversions["any"](callResult, { context: context });
return callResult;
};
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
invokeTheCallbackFunction.objectReference = value;
return invokeTheCallbackFunction;
};
@@ -0,0 +1,28 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
exports._convertInherit = (obj, ret, { context = "The provided value" } = {}) => {
{
const key = "composed";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member 'composed' that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
};
exports.convert = function convert(obj, { context = "The provided value" } = {}) {
if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
throw new TypeError(`${context} is not an object.`);
}
const ret = Object.create(null);
exports._convertInherit(obj, ret, { context });
return ret;
};
@@ -0,0 +1,915 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLAnchorElement";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLAnchorElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLAnchorElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLAnchorElement is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLAnchorElement before HTMLElement");
}
class HTMLAnchorElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "target");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set target(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set target' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'target' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "target", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get download() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get download' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "download");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set download(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set download' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'download' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "download", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get rel() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get rel' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "rel");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set rel(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set rel' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rel' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "rel", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get relList() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get relList' called on an object that is not a valid instance of HTMLAnchorElement.");
}
return utils.getSameObject(this, "relList", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["relList"]);
});
}
set relList(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set relList' called on an object that is not a valid instance of HTMLAnchorElement.");
}
const Q = esValue["relList"];
if (!utils.isObject(Q)) {
throw new TypeError("Property 'relList' is not an object");
}
Reflect.set(Q, "value", V);
}
get hreflang() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hreflang' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "hreflang");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set hreflang(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hreflang' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'hreflang' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "hreflang", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get type() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get type' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "type");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set type(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set type' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'type' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "type", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get text() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get text' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["text"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set text(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set text' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'text' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["text"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get coords() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get coords' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "coords");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set coords(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set coords' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'coords' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "coords", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get charset() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get charset' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "charset");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set charset(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set charset' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'charset' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "charset", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get name() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get name' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "name");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set name(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set name' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'name' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "name", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get rev() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get rev' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "rev");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set rev(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set rev' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rev' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "rev", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get shape() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get shape' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "shape");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set shape(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set shape' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'shape' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "shape", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get href() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get href' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set href(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set href' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'href' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["href"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new TypeError("'toString' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get origin() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get origin' called on an object that is not a valid instance of HTMLAnchorElement.");
}
return esValue[implSymbol]["origin"];
}
get protocol() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get protocol' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["protocol"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set protocol(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set protocol' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'protocol' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["protocol"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get username() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get username' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["username"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set username(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set username' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'username' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["username"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get password() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get password' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["password"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set password(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set password' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'password' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["password"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get host() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get host' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["host"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set host(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set host' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'host' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["host"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get hostname() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hostname' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["hostname"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set hostname(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hostname' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hostname' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["hostname"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get port() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get port' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["port"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set port(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set port' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'port' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["port"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get pathname() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get pathname' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["pathname"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set pathname(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set pathname' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'pathname' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["pathname"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get search() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get search' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["search"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set search(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set search' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'search' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["search"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get hash() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hash' called on an object that is not a valid instance of HTMLAnchorElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["hash"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set hash(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hash' called on an object that is not a valid instance of HTMLAnchorElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hash' property on 'HTMLAnchorElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["hash"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLAnchorElement.prototype, {
target: { enumerable: true },
download: { enumerable: true },
rel: { enumerable: true },
relList: { enumerable: true },
hreflang: { enumerable: true },
type: { enumerable: true },
text: { enumerable: true },
coords: { enumerable: true },
charset: { enumerable: true },
name: { enumerable: true },
rev: { enumerable: true },
shape: { enumerable: true },
href: { enumerable: true },
toString: { enumerable: true },
origin: { enumerable: true },
protocol: { enumerable: true },
username: { enumerable: true },
password: { enumerable: true },
host: { enumerable: true },
hostname: { enumerable: true },
port: { enumerable: true },
pathname: { enumerable: true },
search: { enumerable: true },
hash: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLAnchorElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLAnchorElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLAnchorElement
});
};
const Impl = require("../nodes/HTMLAnchorElement-impl.js");
@@ -0,0 +1,739 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLAreaElement";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLAreaElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLAreaElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLAreaElement is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLAreaElement before HTMLElement");
}
class HTMLAreaElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get alt() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get alt' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "alt");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set alt(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set alt' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'alt' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "alt", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get coords() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get coords' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "coords");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set coords(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set coords' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'coords' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "coords", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get shape() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get shape' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "shape");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set shape(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set shape' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'shape' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "shape", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get target() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get target' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "target");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set target(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set target' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'target' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "target", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get rel() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get rel' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "rel");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set rel(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set rel' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'rel' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "rel", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get relList() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get relList' called on an object that is not a valid instance of HTMLAreaElement.");
}
return utils.getSameObject(this, "relList", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["relList"]);
});
}
set relList(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set relList' called on an object that is not a valid instance of HTMLAreaElement.");
}
const Q = esValue["relList"];
if (!utils.isObject(Q)) {
throw new TypeError("Property 'relList' is not an object");
}
Reflect.set(Q, "value", V);
}
get noHref() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get noHref' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol].hasAttributeNS(null, "nohref");
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set noHref(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set noHref' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["boolean"](V, {
context: "Failed to set the 'noHref' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
if (V) {
esValue[implSymbol].setAttributeNS(null, "nohref", "");
} else {
esValue[implSymbol].removeAttributeNS(null, "nohref");
}
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get href() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get href' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set href(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set href' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'href' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["href"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
toString() {
const esValue = this;
if (!exports.is(esValue)) {
throw new TypeError("'toString' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["href"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get origin() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get origin' called on an object that is not a valid instance of HTMLAreaElement.");
}
return esValue[implSymbol]["origin"];
}
get protocol() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get protocol' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["protocol"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set protocol(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set protocol' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'protocol' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["protocol"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get username() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get username' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["username"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set username(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set username' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'username' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["username"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get password() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get password' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["password"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set password(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set password' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'password' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["password"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get host() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get host' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["host"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set host(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set host' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'host' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["host"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get hostname() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hostname' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["hostname"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set hostname(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hostname' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hostname' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["hostname"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get port() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get port' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["port"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set port(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set port' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'port' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["port"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get pathname() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get pathname' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["pathname"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set pathname(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set pathname' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'pathname' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["pathname"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get search() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get search' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["search"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set search(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set search' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'search' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["search"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
get hash() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get hash' called on an object that is not a valid instance of HTMLAreaElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
return esValue[implSymbol]["hash"];
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set hash(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set hash' called on an object that is not a valid instance of HTMLAreaElement.");
}
V = conversions["USVString"](V, {
context: "Failed to set the 'hash' property on 'HTMLAreaElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol]["hash"] = V;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLAreaElement.prototype, {
alt: { enumerable: true },
coords: { enumerable: true },
shape: { enumerable: true },
target: { enumerable: true },
rel: { enumerable: true },
relList: { enumerable: true },
noHref: { enumerable: true },
href: { enumerable: true },
toString: { enumerable: true },
origin: { enumerable: true },
protocol: { enumerable: true },
username: { enumerable: true },
password: { enumerable: true },
host: { enumerable: true },
hostname: { enumerable: true },
port: { enumerable: true },
pathname: { enumerable: true },
search: { enumerable: true },
hash: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLAreaElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLAreaElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLAreaElement
});
};
const Impl = require("../nodes/HTMLAreaElement-impl.js");
@@ -0,0 +1,115 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLMediaElement = require("./HTMLMediaElement.js");
const interfaceName = "HTMLAudioElement";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLAudioElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLAudioElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLAudioElement is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
HTMLMediaElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.HTMLMediaElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLAudioElement before HTMLMediaElement");
}
class HTMLAudioElement extends globalObject.HTMLMediaElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
}
}
Object.defineProperties(HTMLAudioElement.prototype, {
[Symbol.toStringTag]: { value: "HTMLAudioElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLAudioElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLAudioElement
});
};
const Impl = require("../nodes/HTMLAudioElement-impl.js");
@@ -0,0 +1,153 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLBRElement";
exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new TypeError(`${context} is not of type 'HTMLBRElement'.`);
};
function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object");
}
const ctor = globalObject[ctorRegistrySymbol]["HTMLBRElement"];
if (ctor === undefined) {
throw new Error("Internal error: constructor HTMLBRElement is not installed on the passed global object");
}
return Object.create(ctor.prototype);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper;
};
exports.new = globalObject => {
const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype),
configurable: true
});
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
}
return wrapper[implSymbol];
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
if (globalObject.HTMLElement === undefined) {
throw new Error("Internal error: attempting to evaluate HTMLBRElement before HTMLElement");
}
class HTMLBRElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get clear() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get clear' called on an object that is not a valid instance of HTMLBRElement.");
}
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
const value = esValue[implSymbol].getAttributeNS(null, "clear");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
set clear(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'set clear' called on an object that is not a valid instance of HTMLBRElement.");
}
V = conversions["DOMString"](V, {
context: "Failed to set the 'clear' property on 'HTMLBRElement': The provided value"
});
ceReactionsPreSteps_helpers_custom_elements(globalObject);
try {
esValue[implSymbol].setAttributeNS(null, "clear", V);
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLBRElement.prototype, {
clear: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLBRElement", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = HTMLBRElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLBRElement
});
};
const Impl = require("../nodes/HTMLBRElement-impl.js");

Some files were not shown because too many files have changed in this diff Show More