Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2025-04-21 18:01:41 +00:00
parent c9f0d30a86
commit 95d52b7807
647 changed files with 498055 additions and 3880 deletions

2
node_modules/jsdom/README.md generated vendored
View file

@ -437,7 +437,7 @@ console.log(frag.firstChild.outerHTML); // logs "<p>Hello</p>"
### Canvas support
jsdom includes support for using the [`canvas`](https://www.npmjs.com/package/canvas) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include `canvas` as a dependency in your project, as a peer of `jsdom`. If jsdom can find the `canvas` package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s. Since jsdom v13, version 2.x of `canvas` is required; version 1.x is no longer supported.
jsdom includes support for using the [`canvas`](https://www.npmjs.com/package/canvas) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include `canvas` as a dependency in your project, as a peer of `jsdom`. If jsdom can find version 3.x of the `canvas` package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s.
### Encoding sniffing

View file

@ -139,6 +139,11 @@
"enumerable": false,
"configurable": true
},
"Atomics": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Uint8Array": {
"writable": true,
"enumerable": false,
@ -289,12 +294,12 @@
"enumerable": false,
"configurable": true
},
"SharedArrayBuffer": {
"Iterator": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Atomics": {
"SharedArrayBuffer": {
"writable": true,
"enumerable": false,
"configurable": true

View file

@ -3,7 +3,7 @@
const produceXMLSerialization = require("w3c-xmlserializer");
const parse5 = require("parse5");
const DOMException = require("../generated/DOMException");
const { domSymbolTree } = require("../helpers/internal-constants");
const utils = require("../generated/utils");
const treeAdapter = require("./parse5-adapter-serialization");
const NODE_TYPE = require("../node-type");
@ -19,13 +19,13 @@ module.exports.fragmentSerialization = (node, { outer, requireWellFormed, global
return outer ? parse5.serializeOuter(node, config) : parse5.serialize(node, config);
}
const childNodes = outer ? [node] : node.childNodes;
const childNodes = outer ? [node] : domSymbolTree.childrenToArray(node);
try {
let serialized = "";
for (let i = 0; i < childNodes.length; ++i) {
serialized += produceXMLSerialization(
utils.wrapperForImpl(childNodes[i] || childNodes.item(i)),
utils.wrapperForImpl(childNodes[i]),
{ requireWellFormed }
);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -115,14 +113,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -38,6 +38,15 @@ function makeWrapper(globalObject, newTarget) {
return Object.create(proto);
}
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);
@ -61,6 +70,8 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
@ -69,7 +80,7 @@ exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {})
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
let wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, {
@ -77,6 +88,8 @@ exports.new = (globalObject, newTarget) => {
configurable: true
});
wrapper = makeProxy(wrapper, globalObject);
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(wrapper[implSymbol]);
@ -487,7 +500,8 @@ exports.install = (globalObject, globalNames) => {
target: { enumerable: true },
elements: { enumerable: true },
length: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLFormElement", configurable: true }
[Symbol.toStringTag]: { value: "HTMLFormElement", configurable: true },
[Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }
});
ctorRegistry[interfaceName] = HTMLFormElement;
@ -498,4 +512,173 @@ exports.install = (globalObject, globalNames) => {
});
};
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.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][utils.indexedGet](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) {
const globalObject = this._globalObject;
}
let ownDesc;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
const indexedValue = target[implSymbol][utils.indexedGet](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);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
return false;
}
return Reflect.defineProperty(target, P, desc);
}
deleteProperty(target, P) {
if (typeof P === "symbol") {
return Reflect.deleteProperty(target, P);
}
const globalObject = this._globalObject;
if (utils.isArrayIndexPropName(P)) {
const index = P >>> 0;
return !(target[implSymbol][utils.indexedGet](index) !== null);
}
return Reflect.deleteProperty(target, P);
}
preventExtensions() {
return false;
}
}
const Impl = require("../nodes/HTMLFormElement-impl.js");

View file

@ -6,8 +6,6 @@ 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 parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
@ -195,14 +193,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
@ -285,14 +289,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._longdescURLCacheKey === value) {
return this._longdescURLCache;
}
return conversions.USVString(value);
this._longdescURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._longdescURLCache = serializeURLwhatwg_url(urlRecord);
return this._longdescURLCache;
}
this._longdescURLCache = conversions.USVString(value);
return this._longdescURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -126,14 +124,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
@ -523,14 +527,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._longdescURLCacheKey === value) {
return this._longdescURLCache;
}
return conversions.USVString(value);
this._longdescURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._longdescURLCache = serializeURLwhatwg_url(urlRecord);
return this._longdescURLCache;
}
this._longdescURLCache = conversions.USVString(value);
return this._longdescURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -6,8 +6,6 @@ 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 parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger;
const implSymbol = utils.implSymbol;
@ -156,14 +154,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
@ -582,14 +586,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._lowsrcURLCacheKey === value) {
return this._lowsrcURLCache;
}
return conversions.USVString(value);
this._lowsrcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._lowsrcURLCache = serializeURLwhatwg_url(urlRecord);
return this._lowsrcURLCache;
}
this._lowsrcURLCache = conversions.USVString(value);
return this._lowsrcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
@ -766,14 +776,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._longdescURLCacheKey === value) {
return this._longdescURLCache;
}
return conversions.USVString(value);
this._longdescURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._longdescURLCache = serializeURLwhatwg_url(urlRecord);
return this._longdescURLCache;
}
this._longdescURLCache = conversions.USVString(value);
return this._longdescURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -10,8 +10,6 @@ const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-
const FileList = require("./FileList.js");
const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger;
const create_DOMException = require("./DOMException.js").create;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
@ -1376,14 +1374,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -115,14 +113,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._hrefURLCacheKey === value) {
return this._hrefURLCache;
}
return conversions.USVString(value);
this._hrefURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._hrefURLCache = serializeURLwhatwg_url(urlRecord);
return this._hrefURLCache;
}
this._hrefURLCache = conversions.USVString(value);
return this._hrefURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const TextTrackKind = require("./TextTrackKind.js");
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -225,14 +223,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -115,14 +113,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._citeURLCacheKey === value) {
return this._citeURLCache;
}
return conversions.USVString(value);
this._citeURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._citeURLCache = serializeURLwhatwg_url(urlRecord);
return this._citeURLCache;
}
this._citeURLCache = conversions.USVString(value);
return this._citeURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -163,14 +161,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._dataURLCacheKey === value) {
return this._dataURLCache;
}
return conversions.USVString(value);
this._dataURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._dataURLCache = serializeURLwhatwg_url(urlRecord);
return this._dataURLCache;
}
this._dataURLCache = conversions.USVString(value);
return this._dataURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}
@ -770,14 +774,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._codebaseURLCacheKey === value) {
return this._codebaseURLCache;
}
return conversions.USVString(value);
this._codebaseURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._codebaseURLCache = serializeURLwhatwg_url(urlRecord);
return this._codebaseURLCache;
}
this._codebaseURLCache = conversions.USVString(value);
return this._codebaseURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -115,14 +113,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._citeURLCacheKey === value) {
return this._citeURLCache;
}
return conversions.USVString(value);
this._citeURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._citeURLCache = serializeURLwhatwg_url(urlRecord);
return this._citeURLCache;
}
this._citeURLCache = conversions.USVString(value);
return this._citeURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -115,14 +113,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -4,8 +4,6 @@ const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
@ -115,14 +113,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -6,8 +6,6 @@ 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 parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
@ -155,14 +153,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._srcURLCacheKey === value) {
return this._srcURLCache;
}
return conversions.USVString(value);
this._srcURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._srcURLCache = serializeURLwhatwg_url(urlRecord);
return this._srcURLCache;
}
this._srcURLCache = conversions.USVString(value);
return this._srcURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -7,8 +7,6 @@ const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constr
const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger;
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps;
const parseURLToResultingURLRecord_helpers_document_base_url =
require("../helpers/document-base-url.js").parseURLToResultingURLRecord;
const serializeURLwhatwg_url = require("whatwg-url").serializeURL;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
@ -234,14 +232,20 @@ exports.install = (globalObject, globalNames) => {
if (value === null) {
return "";
}
const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url(
value,
esValue[implSymbol]._ownerDocument
);
if (urlRecord !== null) {
return serializeURLwhatwg_url(urlRecord);
if (this._posterURLCacheKey === value) {
return this._posterURLCache;
}
return conversions.USVString(value);
this._posterURLCacheKey = value;
const urlRecord = esValue[implSymbol]._ownerDocument.encodingParseAURL(value);
if (urlRecord !== null) {
this._posterURLCache = serializeURLwhatwg_url(urlRecord);
return this._posterURLCache;
}
this._posterURLCache = conversions.USVString(value);
return this._posterURLCache;
} finally {
ceReactionsPostSteps_helpers_custom_elements(globalObject);
}

View file

@ -0,0 +1,136 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "SVGAnimatedPreserveAspectRatio";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGAnimatedPreserveAspectRatio'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGAnimatedPreserveAspectRatio"].prototype;
}
return Object.create(proto);
}
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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGAnimatedPreserveAspectRatio {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get baseVal() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get baseVal' called on an object that is not a valid instance of SVGAnimatedPreserveAspectRatio."
);
}
return utils.getSameObject(this, "baseVal", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["baseVal"]);
});
}
get animVal() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get animVal' called on an object that is not a valid instance of SVGAnimatedPreserveAspectRatio."
);
}
return utils.getSameObject(this, "animVal", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["animVal"]);
});
}
}
Object.defineProperties(SVGAnimatedPreserveAspectRatio.prototype, {
baseVal: { enumerable: true },
animVal: { enumerable: true },
[Symbol.toStringTag]: { value: "SVGAnimatedPreserveAspectRatio", configurable: true }
});
ctorRegistry[interfaceName] = SVGAnimatedPreserveAspectRatio;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGAnimatedPreserveAspectRatio
});
};
const Impl = require("../svg/SVGAnimatedPreserveAspectRatio-impl.js");

View file

@ -0,0 +1,136 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "SVGAnimatedRect";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGAnimatedRect'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGAnimatedRect"].prototype;
}
return Object.create(proto);
}
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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGAnimatedRect {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get baseVal() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get baseVal' called on an object that is not a valid instance of SVGAnimatedRect."
);
}
return utils.getSameObject(this, "baseVal", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["baseVal"]);
});
}
get animVal() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get animVal' called on an object that is not a valid instance of SVGAnimatedRect."
);
}
return utils.getSameObject(this, "animVal", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["animVal"]);
});
}
}
Object.defineProperties(SVGAnimatedRect.prototype, {
baseVal: { enumerable: true },
animVal: { enumerable: true },
[Symbol.toStringTag]: { value: "SVGAnimatedRect", configurable: true }
});
ctorRegistry[interfaceName] = SVGAnimatedRect;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGAnimatedRect
});
};
const Impl = require("../svg/SVGAnimatedRect-impl.js");

View file

@ -0,0 +1,109 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const SVGGraphicsElement = require("./SVGGraphicsElement.js");
const interfaceName = "SVGDefsElement";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGDefsElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGDefsElement"].prototype;
}
return Object.create(proto);
}
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) => {
SVGGraphicsElement._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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGDefsElement extends globalObject.SVGGraphicsElement {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(SVGDefsElement.prototype, {
[Symbol.toStringTag]: { value: "SVGDefsElement", configurable: true }
});
ctorRegistry[interfaceName] = SVGDefsElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGDefsElement
});
};
const Impl = require("../nodes/SVGDefsElement-impl.js");

View file

@ -0,0 +1,109 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const SVGElement = require("./SVGElement.js");
const interfaceName = "SVGDescElement";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGDescElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGDescElement"].prototype;
}
return Object.create(proto);
}
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) => {
SVGElement._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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGDescElement extends globalObject.SVGElement {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(SVGDescElement.prototype, {
[Symbol.toStringTag]: { value: "SVGDescElement", configurable: true }
});
ctorRegistry[interfaceName] = SVGDescElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGDescElement
});
};
const Impl = require("../nodes/SVGDescElement-impl.js");

View file

@ -3,6 +3,7 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const create_SVGAnimatedString = require("./SVGAnimatedString.js").create;
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const OnErrorEventHandlerNonNull = require("./OnErrorEventHandlerNonNull.js");
const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps;
@ -126,7 +127,10 @@ exports.install = (globalObject, globalNames) => {
}
return utils.getSameObject(this, "className", () => {
return utils.tryWrapperForImpl(esValue[implSymbol]["className"]);
return create_SVGAnimatedString(globalObject, [], {
element: esValue[implSymbol],
attribute: "class"
});
});
}

View file

@ -0,0 +1,109 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const SVGGraphicsElement = require("./SVGGraphicsElement.js");
const interfaceName = "SVGGElement";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGGElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGGElement"].prototype;
}
return Object.create(proto);
}
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) => {
SVGGraphicsElement._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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGGElement extends globalObject.SVGGraphicsElement {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(SVGGElement.prototype, {
[Symbol.toStringTag]: { value: "SVGGElement", configurable: true }
});
ctorRegistry[interfaceName] = SVGGElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGGElement
});
};
const Impl = require("../nodes/SVGGElement-impl.js");

View file

@ -0,0 +1,109 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const SVGElement = require("./SVGElement.js");
const interfaceName = "SVGMetadataElement";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGMetadataElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGMetadataElement"].prototype;
}
return Object.create(proto);
}
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) => {
SVGElement._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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGMetadataElement extends globalObject.SVGElement {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(SVGMetadataElement.prototype, {
[Symbol.toStringTag]: { value: "SVGMetadataElement", configurable: true }
});
ctorRegistry[interfaceName] = SVGMetadataElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGMetadataElement
});
};
const Impl = require("../nodes/SVGMetadataElement-impl.js");

View file

@ -0,0 +1,196 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "SVGPreserveAspectRatio";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGPreserveAspectRatio'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGPreserveAspectRatio"].prototype;
}
return Object.create(proto);
}
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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGPreserveAspectRatio {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get align() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get align' called on an object that is not a valid instance of SVGPreserveAspectRatio."
);
}
return esValue[implSymbol]["align"];
}
set align(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set align' called on an object that is not a valid instance of SVGPreserveAspectRatio."
);
}
V = conversions["unsigned short"](V, {
context: "Failed to set the 'align' property on 'SVGPreserveAspectRatio': The provided value",
globals: globalObject
});
esValue[implSymbol]["align"] = V;
}
get meetOrSlice() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get meetOrSlice' called on an object that is not a valid instance of SVGPreserveAspectRatio."
);
}
return esValue[implSymbol]["meetOrSlice"];
}
set meetOrSlice(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'set meetOrSlice' called on an object that is not a valid instance of SVGPreserveAspectRatio."
);
}
V = conversions["unsigned short"](V, {
context: "Failed to set the 'meetOrSlice' property on 'SVGPreserveAspectRatio': The provided value",
globals: globalObject
});
esValue[implSymbol]["meetOrSlice"] = V;
}
}
Object.defineProperties(SVGPreserveAspectRatio.prototype, {
align: { enumerable: true },
meetOrSlice: { enumerable: true },
[Symbol.toStringTag]: { value: "SVGPreserveAspectRatio", configurable: true },
SVG_PRESERVEASPECTRATIO_UNKNOWN: { value: 0, enumerable: true },
SVG_PRESERVEASPECTRATIO_NONE: { value: 1, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMINYMIN: { value: 2, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMIDYMIN: { value: 3, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMAXYMIN: { value: 4, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMINYMID: { value: 5, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMIDYMID: { value: 6, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMAXYMID: { value: 7, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMINYMAX: { value: 8, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMIDYMAX: { value: 9, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMAXYMAX: { value: 10, enumerable: true },
SVG_MEETORSLICE_UNKNOWN: { value: 0, enumerable: true },
SVG_MEETORSLICE_MEET: { value: 1, enumerable: true },
SVG_MEETORSLICE_SLICE: { value: 2, enumerable: true }
});
Object.defineProperties(SVGPreserveAspectRatio, {
SVG_PRESERVEASPECTRATIO_UNKNOWN: { value: 0, enumerable: true },
SVG_PRESERVEASPECTRATIO_NONE: { value: 1, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMINYMIN: { value: 2, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMIDYMIN: { value: 3, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMAXYMIN: { value: 4, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMINYMID: { value: 5, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMIDYMID: { value: 6, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMAXYMID: { value: 7, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMINYMAX: { value: 8, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMIDYMAX: { value: 9, enumerable: true },
SVG_PRESERVEASPECTRATIO_XMAXYMAX: { value: 10, enumerable: true },
SVG_MEETORSLICE_UNKNOWN: { value: 0, enumerable: true },
SVG_MEETORSLICE_MEET: { value: 1, enumerable: true },
SVG_MEETORSLICE_SLICE: { value: 2, enumerable: true }
});
ctorRegistry[interfaceName] = SVGPreserveAspectRatio;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGPreserveAspectRatio
});
};
const Impl = require("../svg/SVGPreserveAspectRatio-impl.js");

View file

@ -0,0 +1,210 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "SVGRect";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGRect'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGRect"].prototype;
}
return Object.create(proto);
}
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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGRect {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get x() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get x' called on an object that is not a valid instance of SVGRect.");
}
return esValue[implSymbol]["x"];
}
set x(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set x' called on an object that is not a valid instance of SVGRect.");
}
V = conversions["float"](V, {
context: "Failed to set the 'x' property on 'SVGRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["x"] = V;
}
get y() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get y' called on an object that is not a valid instance of SVGRect.");
}
return esValue[implSymbol]["y"];
}
set y(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set y' called on an object that is not a valid instance of SVGRect.");
}
V = conversions["float"](V, {
context: "Failed to set the 'y' property on 'SVGRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["y"] = V;
}
get width() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get width' called on an object that is not a valid instance of SVGRect.");
}
return esValue[implSymbol]["width"];
}
set width(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set width' called on an object that is not a valid instance of SVGRect.");
}
V = conversions["float"](V, {
context: "Failed to set the 'width' property on 'SVGRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["width"] = V;
}
get height() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'get height' called on an object that is not a valid instance of SVGRect.");
}
return esValue[implSymbol]["height"];
}
set height(V) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError("'set height' called on an object that is not a valid instance of SVGRect.");
}
V = conversions["float"](V, {
context: "Failed to set the 'height' property on 'SVGRect': The provided value",
globals: globalObject
});
esValue[implSymbol]["height"] = V;
}
}
Object.defineProperties(SVGRect.prototype, {
x: { enumerable: true },
y: { enumerable: true },
width: { enumerable: true },
height: { enumerable: true },
[Symbol.toStringTag]: { value: "SVGRect", configurable: true }
});
ctorRegistry[interfaceName] = SVGRect;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGRect
});
};
const Impl = require("../svg/SVGRect-impl.js");

View file

@ -3,6 +3,8 @@
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const create_SVGAnimatedRect = require("./SVGAnimatedRect.js").create;
const create_SVGAnimatedPreserveAspectRatio = require("./SVGAnimatedPreserveAspectRatio.js").create;
const EventHandlerNonNull = require("./EventHandlerNonNull.js");
const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js");
const implSymbol = utils.implSymbol;
@ -107,6 +109,17 @@ exports.install = (globalObject, globalNames) => {
return utils.tryWrapperForImpl(esValue[implSymbol].createSVGNumber());
}
createSVGRect() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'createSVGRect' called on an object that is not a valid instance of SVGSVGElement."
);
}
return utils.tryWrapperForImpl(esValue[implSymbol].createSVGRect());
}
getElementById(elementId) {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
@ -204,6 +217,39 @@ exports.install = (globalObject, globalNames) => {
return esValue[implSymbol].forceRedraw();
}
get viewBox() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get viewBox' called on an object that is not a valid instance of SVGSVGElement."
);
}
return utils.getSameObject(this, "viewBox", () => {
return create_SVGAnimatedRect(globalObject, [], {
element: esValue[implSymbol],
attribute: "viewBox"
});
});
}
get preserveAspectRatio() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get preserveAspectRatio' called on an object that is not a valid instance of SVGSVGElement."
);
}
return utils.getSameObject(this, "preserveAspectRatio", () => {
return create_SVGAnimatedPreserveAspectRatio(globalObject, [], {
element: esValue[implSymbol]
});
});
}
get onafterprint() {
const esValue = this !== null && this !== undefined ? this : globalObject;
@ -702,11 +748,14 @@ exports.install = (globalObject, globalNames) => {
}
Object.defineProperties(SVGSVGElement.prototype, {
createSVGNumber: { enumerable: true },
createSVGRect: { enumerable: true },
getElementById: { enumerable: true },
suspendRedraw: { enumerable: true },
unsuspendRedraw: { enumerable: true },
unsuspendRedrawAll: { enumerable: true },
forceRedraw: { enumerable: true },
viewBox: { enumerable: true },
preserveAspectRatio: { enumerable: true },
onafterprint: { enumerable: true },
onbeforeprint: { enumerable: true },
onbeforeunload: { enumerable: true },

View file

@ -0,0 +1,109 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const SVGGraphicsElement = require("./SVGGraphicsElement.js");
const interfaceName = "SVGSwitchElement";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGSwitchElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGSwitchElement"].prototype;
}
return Object.create(proto);
}
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) => {
SVGGraphicsElement._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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGSwitchElement extends globalObject.SVGGraphicsElement {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
}
Object.defineProperties(SVGSwitchElement.prototype, {
[Symbol.toStringTag]: { value: "SVGSwitchElement", configurable: true }
});
ctorRegistry[interfaceName] = SVGSwitchElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGSwitchElement
});
};
const Impl = require("../nodes/SVGSwitchElement-impl.js");

View file

@ -0,0 +1,146 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const create_SVGAnimatedRect = require("./SVGAnimatedRect.js").create;
const create_SVGAnimatedPreserveAspectRatio = require("./SVGAnimatedPreserveAspectRatio.js").create;
const implSymbol = utils.implSymbol;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const SVGGraphicsElement = require("./SVGGraphicsElement.js");
const interfaceName = "SVGSymbolElement";
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 = (globalObject, value, { context = "The provided value" } = {}) => {
if (exports.is(value)) {
return utils.implForWrapper(value);
}
throw new globalObject.TypeError(`${context} is not of type 'SVGSymbolElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["SVGSymbolElement"].prototype;
}
return Object.create(proto);
}
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) => {
SVGGraphicsElement._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, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
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;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class SVGSymbolElement extends globalObject.SVGGraphicsElement {
constructor() {
throw new globalObject.TypeError("Illegal constructor");
}
get viewBox() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get viewBox' called on an object that is not a valid instance of SVGSymbolElement."
);
}
return utils.getSameObject(this, "viewBox", () => {
return create_SVGAnimatedRect(globalObject, [], {
element: esValue[implSymbol],
attribute: "viewBox"
});
});
}
get preserveAspectRatio() {
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new globalObject.TypeError(
"'get preserveAspectRatio' called on an object that is not a valid instance of SVGSymbolElement."
);
}
return utils.getSameObject(this, "preserveAspectRatio", () => {
return create_SVGAnimatedPreserveAspectRatio(globalObject, [], {
element: esValue[implSymbol]
});
});
}
}
Object.defineProperties(SVGSymbolElement.prototype, {
viewBox: { enumerable: true },
preserveAspectRatio: { enumerable: true },
[Symbol.toStringTag]: { value: "SVGSymbolElement", configurable: true }
});
ctorRegistry[interfaceName] = SVGSymbolElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: SVGSymbolElement
});
};
const Impl = require("../nodes/SVGSymbolElement-impl.js");

View file

@ -100,7 +100,13 @@ const INTERFACE_TAG_MAPPING = {
__proto__: null,
SVGElement: [],
SVGGraphicsElement: [],
SVGDefsElement: ["defs"],
SVGDescElement: ["desc"],
SVGGElement: ["g"],
SVGMetadataElement: ["metadata"],
SVGSVGElement: ["svg"],
SVGSwitchElement: ["switch"],
SVGSymbolElement: ["symbol"],
SVGTitleElement: ["title"]
}
};

View file

@ -1,54 +0,0 @@
"use strict";
const whatwgURL = require("whatwg-url");
const { implForWrapper } = require("../generated/utils");
exports.documentBaseURL = document => {
// https://html.spec.whatwg.org/multipage/infrastructure.html#document-base-url
const firstBase = document.querySelector("base[href]");
const fallbackBaseURL = exports.fallbackBaseURL(document);
if (firstBase === null) {
return fallbackBaseURL;
}
return frozenBaseURL(firstBase, fallbackBaseURL);
};
exports.documentBaseURLSerialized = document => {
return whatwgURL.serializeURL(exports.documentBaseURL(document));
};
exports.fallbackBaseURL = document => {
// https://html.spec.whatwg.org/multipage/infrastructure.html#fallback-base-url
// Unimplemented: <iframe srcdoc>
if (document.URL === "about:blank" && document._defaultView &&
document._defaultView._parent !== document._defaultView) {
const parentDocument = implForWrapper(document._defaultView._parent._document);
return exports.documentBaseURL(parentDocument);
}
return document._URL;
};
exports.parseURLToResultingURLRecord = (url, document) => {
// https://html.spec.whatwg.org/#resolve-a-url
// Encoding stuff ignored; always UTF-8 for us, for now.
const baseURL = exports.documentBaseURL(document);
return whatwgURL.parseURL(url, { baseURL });
// This returns the resulting URL record; to get the resulting URL string, just serialize it.
};
function frozenBaseURL(baseElement, fallbackBaseURL) {
// https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url
// The spec is eager (setting the frozen base URL when things change); we are lazy (getting it when we need to)
const baseHrefAttribute = baseElement.getAttributeNS(null, "href");
const result = whatwgURL.parseURL(baseHrefAttribute, { baseURL: fallbackBaseURL });
return result === null ? fallbackBaseURL : result;
}

View file

@ -1,4 +1,5 @@
"use strict";
// Do not require generated files from here, as this file is shared with the Web IDL converter.
// https://infra.spec.whatwg.org/#namespaces

View file

@ -6,12 +6,26 @@ exports.asciiWhitespaceRe = asciiWhitespaceRe;
// https://infra.spec.whatwg.org/#ascii-lowercase
exports.asciiLowercase = s => {
return s.replace(/[A-Z]/g, l => l.toLowerCase());
const len = s.length;
const out = new Array(len);
for (let i = 0; i < len; i++) {
const code = s.charCodeAt(i);
// If the character is between 'A' (65) and 'Z' (90), convert using bitwise OR with 32
out[i] = code >= 65 && code <= 90 ? String.fromCharCode(code | 32) : s[i];
}
return out.join("");
};
// https://infra.spec.whatwg.org/#ascii-uppercase
exports.asciiUppercase = s => {
return s.replace(/[a-z]/g, l => l.toUpperCase());
const len = s.length;
const out = new Array(len);
for (let i = 0; i < len; i++) {
const code = s.charCodeAt(i);
// If the character is between 'a' (97) and 'z' (122), convert using bitwise AND with ~32
out[i] = code >= 97 && code <= 122 ? String.fromCharCode(code & ~32) : s[i];
}
return out.join("");
};
// https://infra.spec.whatwg.org/#strip-newlines

View file

@ -114,9 +114,20 @@ const generatedInterfaces = {
SVGElement: require("./generated/SVGElement.js"),
SVGGraphicsElement: require("./generated/SVGGraphicsElement.js"),
SVGSVGElement: require("./generated/SVGSVGElement.js"),
SVGGElement: require("./generated/SVGGElement.js"),
SVGDefsElement: require("./generated/SVGDefsElement.js"),
SVGDescElement: require("./generated/SVGDescElement.js"),
SVGMetadataElement: require("./generated/SVGMetadataElement.js"),
SVGTitleElement: require("./generated/SVGTitleElement.js"),
SVGSymbolElement: require("./generated/SVGSymbolElement.js"),
SVGSwitchElement: require("./generated/SVGSwitchElement.js"),
SVGAnimatedPreserveAspectRatio: require("./generated/SVGAnimatedPreserveAspectRatio"),
SVGAnimatedRect: require("./generated/SVGAnimatedRect"),
SVGAnimatedString: require("./generated/SVGAnimatedString"),
SVGNumber: require("./generated/SVGNumber"),
SVGPreserveAspectRatio: require("./generated/SVGPreserveAspectRatio"),
SVGRect: require("./generated/SVGRect"),
SVGStringList: require("./generated/SVGStringList"),
Event: require("./generated/Event"),

View file

@ -15,14 +15,14 @@ function isNamedPropertyElement(element) {
return true;
}
switch (element.nodeName) {
case "A":
case "AREA":
case "EMBED":
case "FORM":
case "FRAMESET":
case "IMG":
case "OBJECT":
switch (element._localName) {
case "a":
case "area":
case "embed":
case "form":
case "frameset":
case "img":
case "object":
return true;
default:
return false;

View file

@ -198,6 +198,74 @@ class DocumentImpl extends NodeImpl {
// Cache of computed element styles
this._styleCache = null;
// Cache of document base URL
this._baseURLCache = null;
this._baseURLSerializedCache = null;
}
_clearBaseURLCache() {
this._baseURLCache = null;
this._baseURLSerializedCache = null;
}
// https://html.spec.whatwg.org/multipage/infrastructure.html#document-base-url
baseURL() {
if (this._baseURLCache) {
return this._baseURLCache;
}
const firstBase = this.querySelector("base[href]");
this._baseURLCache = firstBase === null ?
this._fallbackBaseURL() :
this._frozenBaseURL(firstBase, this._fallbackBaseURL());
return this._baseURLCache;
}
baseURLSerialized() {
if (this._baseURLSerializedCache) {
return this._baseURLSerializedCache;
}
const result = whatwgURL.serializeURL(this.baseURL());
this._baseURLSerializedCache = result;
return result;
}
// https://html.spec.whatwg.org/#resolve-a-url
encodingParseAURL(url) {
// TODO account for encoding (once whatwg-url supports that)
return whatwgURL.parseURL(url, { baseURL: this.baseURL() });
}
// https://html.spec.whatwg.org/#frozen-base-url
_frozenBaseURL(baseElement, fallbackBaseURL) {
// The spec is eager (setting the frozen base URL when things change); we are lazy (getting it when we need to).
//
// There is a slight difference, which is when history.pushState() is involved. The frozen base URL does not get
// updated in response to history.pushState() per spec, but since we're lazy, it will get updated.
//
// The test in to-port-to-wpts/history.js checks for the current jsdom behavior (which is incorrect).
// We could make it pass by not invalidating the base URL cache, actually. But that would just make the fallback
// base URL case use the stale base URL.
//
// TODO: implement, with tests for all code paths, the spec's behavior.
const baseHrefAttribute = baseElement.getAttributeNS(null, "href");
const result = whatwgURL.parseURL(baseHrefAttribute, { baseURL: fallbackBaseURL });
return result === null ? fallbackBaseURL : result;
}
// https://html.spec.whatwg.org/#fallback-base-url
_fallbackBaseURL() {
if (this.URL === "about:blank" && this._defaultView &&
this._defaultView._parent !== this._defaultView) {
const parentDocument = idlUtils.implForWrapper(this._defaultView._parent._document);
return parentDocument.baseURL();
}
return this._URL;
}
_getTheParent(event) {

View file

@ -76,9 +76,7 @@ class ElementImpl extends NodeImpl {
this._attributeList = [];
// Used for caching.
this._attributesByNameMap = new Map();
this._attributes = NamedNodeMap.createImpl(this._globalObject, [], {
element: this
});
this._attributes = null;
this._cachedTagName = null;
}
@ -144,7 +142,7 @@ class ElementImpl extends NodeImpl {
// All these are invariants during the instance lifetime so we can safely cache the computed tagName.
// We could create it during construction but since we already identified this as potentially slow we do it lazily.
if (this._cachedTagName === null) {
if (this.namespaceURI === HTML_NS && this._ownerDocument._parsingMode === "html") {
if (this._namespaceURI === HTML_NS && this._ownerDocument._parsingMode === "html") {
this._cachedTagName = asciiUppercase(this._qualifiedName);
} else {
this._cachedTagName = this._qualifiedName;
@ -154,6 +152,12 @@ class ElementImpl extends NodeImpl {
}
get attributes() {
if (!this._attributes) {
this._attributes = NamedNodeMap.createImpl(this._globalObject, [], {
element: this
});
}
return this._attributes;
}

View file

@ -1,14 +1,13 @@
"use strict";
const whatwgURL = require("whatwg-url");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { fallbackBaseURL } = require("../helpers/document-base-url");
class HTMLBaseElementImpl extends HTMLElementImpl {
get href() {
const document = this._ownerDocument;
const url = this.hasAttributeNS(null, "href") ? this.getAttributeNS(null, "href") : "";
const parsed = whatwgURL.parseURL(url, { baseURL: fallbackBaseURL(document) });
const parsed = whatwgURL.parseURL(url, { baseURL: document._fallbackBaseURL() });
if (parsed === null) {
return url;
@ -20,6 +19,24 @@ class HTMLBaseElementImpl extends HTMLElementImpl {
set href(value) {
this.setAttributeNS(null, "href", value);
}
_attrModified(name, value, oldValue) {
super._attrModified(name, value, oldValue);
if (name === "href") {
this._ownerDocument._clearBaseURLCache();
}
}
_attach() {
super._attach();
this._ownerDocument._clearBaseURLCache();
}
_detach() {
super._detach();
this._ownerDocument._clearBaseURLCache();
}
}
module.exports = {

View file

@ -1,5 +1,6 @@
"use strict";
const idlUtils = require("../generated/utils.js");
const DOMException = require("../generated/DOMException");
const { serializeURL } = require("whatwg-url");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
@ -8,7 +9,6 @@ const { fireAnEvent } = require("../helpers/events");
const { formOwner, isListed, isSubmittable, isSubmitButton } = require("../helpers/form-controls");
const HTMLFormControlsCollection = require("../generated/HTMLFormControlsCollection");
const notImplemented = require("../../browser/not-implemented");
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url");
const SubmitEvent = require("../generated/SubmitEvent");
const encTypes = new Set([
@ -80,6 +80,14 @@ class HTMLFormElementImpl extends HTMLElementImpl {
});
}
[idlUtils.indexedGet](index) {
return this._getElementNodes()[index] || null;
}
get [idlUtils.supportedPropertyIndices]() {
return Object.keys(this._getElementNodes());
}
get length() {
return this.elements.length;
}
@ -179,7 +187,7 @@ class HTMLFormElementImpl extends HTMLElementImpl {
if (attributeValue === null || attributeValue === "") {
return this._ownerDocument.URL;
}
const urlRecord = parseURLToResultingURLRecord(attributeValue, this._ownerDocument);
const urlRecord = this._ownerDocument.encodingParseAURL(attributeValue);
if (urlRecord === null) {
return attributeValue;
}

View file

@ -9,7 +9,6 @@ const window = require("../../browser/Window");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { evaluateJavaScriptURL } = require("../window/navigation");
const { parseIntoDocument } = require("../../browser/parser");
const { documentBaseURL } = require("../helpers/document-base-url");
const { fireAnEvent } = require("../helpers/events");
const { getAttributeValue } = require("../attributes");
const idlUtils = require("../generated/utils");
@ -121,7 +120,7 @@ function loadFrame(frame, attaching) {
if (srcAttribute === "") {
url = parseURL("about:blank");
} else {
url = parseURL(srcAttribute, { baseURL: documentBaseURL(parentDoc) || undefined }) || parseURL("about:blank");
url = parseURL(srcAttribute, { baseURL: parentDoc.baseURL() || undefined }) || parseURL("about:blank");
}
const serializedURL = serializeURL(url);
@ -233,6 +232,11 @@ class HTMLFrameElementImpl extends HTMLElementImpl {
super._detach();
if (this.contentWindow) {
// TODO: this is not really correct behavior, because jsdom's window.close() is very aggressive and is meant for
// killing off the whole jsdom, not just moving the Window to a no-browsing-context state.
//
// If we revise this in the future, be sure to also invalidate the base URL cache.
this.contentWindow.close();
}

View file

@ -1,6 +1,5 @@
"use strict";
const whatwgURL = require("whatwg-url");
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url");
const { asciiCaseInsensitiveMatch } = require("../helpers/strings");
const { navigate } = require("../window/navigation");
@ -70,7 +69,7 @@ exports.implementation = class HTMLHyperlinkElementUtilsImpl {
return;
}
const url = parseURLToResultingURLRecord(this.href, this._ownerDocument);
const url = this._ownerDocument.encodingParseAURL(this.href);
if (url === null) {
return;
@ -357,7 +356,7 @@ function setTheURL(hheu) {
return;
}
const parsed = parseURLToResultingURLRecord(href, hheu._ownerDocument);
const parsed = hheu._ownerDocument.encodingParseAURL(href);
hheu.url = parsed === null ? null : parsed;
}

View file

@ -3,7 +3,6 @@ const conversions = require("webidl-conversions");
const { serializeURL } = require("whatwg-url");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { Canvas } = require("../../utils");
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url");
class HTMLImageElementImpl extends HTMLElementImpl {
constructor(...args) {
@ -86,7 +85,7 @@ class HTMLImageElementImpl extends HTMLElementImpl {
const srcAttributeValue = this.getAttributeNS(null, "src");
let urlString = null;
if (srcAttributeValue !== null && srcAttributeValue !== "") {
const urlRecord = parseURLToResultingURLRecord(srcAttributeValue, this._ownerDocument);
const urlRecord = this._ownerDocument.encodingParseAURL(srcAttributeValue);
if (urlRecord === null) {
return;
}

View file

@ -333,7 +333,7 @@ class HTMLInputElementImpl extends HTMLElementImpl {
while (e) {
// root node of this home sub tree
// or the form element we belong to
if (!domSymbolTree.parent(e) || e.nodeName.toUpperCase() === "FORM") {
if (!domSymbolTree.parent(e) || e._localName === "form") {
return e;
}
e = domSymbolTree.parent(e);

View file

@ -3,7 +3,6 @@ const DOMTokenList = require("../generated/DOMTokenList");
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const idlUtils = require("../generated/utils");
const { fetchStylesheet, removeStylesheet } = require("../helpers/stylesheets");
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url");
const whatwgURL = require("whatwg-url");
// Important reading: "appropriate times to obtain the resource" in
@ -83,7 +82,7 @@ function fetchAndProcess(el) {
return;
}
const url = parseURLToResultingURLRecord(href, el._ownerDocument);
const url = el._ownerDocument.encodingParseAURL(href);
if (url === null) {
return;
}

View file

@ -55,9 +55,9 @@ class HTMLOptionElementImpl extends HTMLElementImpl {
return null;
}
if (select.nodeName.toUpperCase() !== "SELECT") {
if (select._localName !== "select") {
select = domSymbolTree.parent(select);
if (!select || select.nodeName.toUpperCase() !== "SELECT") {
if (!select || select._localName !== "select") {
return null;
}
}

View file

@ -14,10 +14,13 @@ const tabIndexReflectAllowedHTMLElements = new Set([
class HTMLOrSVGElementImpl {
_initHTMLOrSVGElement() {
this._tabIndex = 0;
this._dataset = DOMStringMap.createImpl(this._globalObject, [], { element: this });
this._dataset = null;
}
get dataset() {
if (!this._dataset) {
this._dataset = DOMStringMap.createImpl(this._globalObject, [], { element: this });
}
return this._dataset;
}

View file

@ -9,7 +9,6 @@ const reportException = require("../helpers/runtime-script-errors");
const { domSymbolTree, cloningSteps } = require("../helpers/internal-constants");
const { asciiLowercase } = require("../helpers/strings");
const { childTextContent } = require("../helpers/text");
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url");
const nodeTypes = require("../node-type");
const jsMIMETypes = new Set([
@ -71,7 +70,7 @@ class HTMLScriptElementImpl extends HTMLElementImpl {
}
const src = this.getAttributeNS(null, "src");
const url = parseURLToResultingURLRecord(src, this._ownerDocument);
const url = this._ownerDocument.encodingParseAURL(src);
if (url === null) {
return;
}

View file

@ -66,7 +66,7 @@ class HTMLSelectElementImpl extends HTMLElementImpl {
let disabled = option.hasAttributeNS(null, "disabled");
const parentNode = domSymbolTree.parent(option);
if (parentNode &&
parentNode.nodeName.toUpperCase() === "OPTGROUP" &&
parentNode._localName === "optgroup" &&
parentNode.hasAttributeNS(null, "disabled")) {
disabled = true;
}

View file

@ -1,7 +1,6 @@
"use strict";
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { removeStylesheet, createStylesheet } = require("../helpers/stylesheets");
const { documentBaseURL } = require("../helpers/document-base-url");
const { childTextContent } = require("../helpers/text");
const { asciiCaseInsensitiveMatch } = require("../helpers/strings");
@ -65,7 +64,7 @@ class HTMLStyleElementImpl extends HTMLElementImpl {
const content = childTextContent(this);
// Not implemented: a bunch of other state, e.g. title/media attributes
createStylesheet(content, this, documentBaseURL(this._ownerDocument));
createStylesheet(content, this, this._ownerDocument.baseURL());
}
}

View file

@ -13,7 +13,6 @@ const NodeList = require("../generated/NodeList");
const { nodeRoot, nodeLength, isInclusiveAncestor } = require("../helpers/node");
const { domSymbolTree } = require("../helpers/internal-constants");
const { documentBaseURLSerialized } = require("../helpers/document-base-url");
const { queueTreeMutationRecord } = require("../helpers/mutation-observers");
const { enqueueCECallbackReaction, tryUpgradeElement } = require("../helpers/custom-elements");
const {
@ -36,7 +35,7 @@ function nodeEquals(a, b) {
break;
case NODE_TYPE.ELEMENT_NODE:
if (a._namespaceURI !== b._namespaceURI || a._prefix !== b._prefix || a._localName !== b._localName ||
a._attributes.length !== b._attributes.length) {
a._attributeList.length !== b._attributeList.length) {
return false;
}
break;
@ -362,7 +361,7 @@ class NodeImpl extends EventTargetImpl {
}
get baseURI() {
return documentBaseURLSerialized(this._ownerDocument);
return this._ownerDocument.baseURLSerialized();
}
compareDocumentPosition(other) {
@ -612,8 +611,8 @@ class NodeImpl extends EventTargetImpl {
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
_preInsertValidity(nodeImpl, childImpl) {
const { nodeType, nodeName } = nodeImpl;
const { nodeType: parentType, nodeName: parentName } = this;
const { nodeType } = nodeImpl;
const parentType = this.nodeType;
if (
parentType !== NODE_TYPE.DOCUMENT_NODE &&
@ -621,7 +620,7 @@ class NodeImpl extends EventTargetImpl {
parentType !== NODE_TYPE.ELEMENT_NODE
) {
throw DOMException.create(this._globalObject, [
`Node can't be inserted in a ${parentName} parent.`,
`Node can't be inserted in a ${this.nodeName} parent.`,
"HierarchyRequestError"
]);
}
@ -650,7 +649,7 @@ class NodeImpl extends EventTargetImpl {
nodeType !== NODE_TYPE.COMMENT_NODE
) {
throw DOMException.create(this._globalObject, [
`${nodeName} node can't be inserted in parent node.`,
`${nodeImpl.nodeName} node can't be inserted in parent node.`,
"HierarchyRequestError"
]);
}
@ -660,7 +659,7 @@ class NodeImpl extends EventTargetImpl {
(nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE && parentType !== NODE_TYPE.DOCUMENT_NODE)
) {
throw DOMException.create(this._globalObject, [
`${nodeName} node can't be inserted in ${parentName} parent.`,
`${nodeImpl.nodeName} node can't be inserted in ${this.nodeName} parent.`,
"HierarchyRequestError"
]);
}
@ -674,7 +673,7 @@ class NodeImpl extends EventTargetImpl {
const nodeChildrenElements = nodeChildren.filter(child => child.nodeType === NODE_TYPE.ELEMENT_NODE);
if (nodeChildrenElements.length > 1) {
throw DOMException.create(this._globalObject, [
`Invalid insertion of ${nodeName} node in ${parentName} node.`,
`Invalid insertion of ${nodeImpl.nodeName} node in ${this.nodeName} node.`,
"HierarchyRequestError"
]);
}
@ -682,7 +681,7 @@ class NodeImpl extends EventTargetImpl {
const hasNodeTextChildren = nodeChildren.some(child => child.nodeType === NODE_TYPE.TEXT_NODE);
if (hasNodeTextChildren) {
throw DOMException.create(this._globalObject, [
`Invalid insertion of ${nodeName} node in ${parentName} node.`,
`Invalid insertion of ${nodeImpl.nodeName} node in ${this.nodeName} node.`,
"HierarchyRequestError"
]);
}
@ -700,7 +699,7 @@ class NodeImpl extends EventTargetImpl {
)
) {
throw DOMException.create(this._globalObject, [
`Invalid insertion of ${nodeName} node in ${parentName} node.`,
`Invalid insertion of ${nodeImpl.nodeName} node in ${this.nodeName} node.`,
"HierarchyRequestError"
]);
}
@ -718,7 +717,7 @@ class NodeImpl extends EventTargetImpl {
)
) {
throw DOMException.create(this._globalObject, [
`Invalid insertion of ${nodeName} node in ${parentName} node.`,
`Invalid insertion of ${nodeImpl.nodeName} node in ${this.nodeName} node.`,
"HierarchyRequestError"
]);
}
@ -735,7 +734,7 @@ class NodeImpl extends EventTargetImpl {
(!childImpl && parentChildren.some(child => child.nodeType === NODE_TYPE.ELEMENT_NODE))
) {
throw DOMException.create(this._globalObject, [
`Invalid insertion of ${nodeName} node in ${parentName} node.`,
`Invalid insertion of ${nodeImpl.nodeName} node in ${this.nodeName} node.`,
"HierarchyRequestError"
]);
}

View file

@ -0,0 +1,9 @@
"use strict";
const SVGGraphicsElementImpl = require("./SVGGraphicsElement-impl").implementation;
class SVGDefsElementImpl extends SVGGraphicsElementImpl {}
module.exports = {
implementation: SVGDefsElementImpl
};

View file

@ -0,0 +1,9 @@
"use strict";
const SVGElementImpl = require("./SVGElement-impl").implementation;
class SVGDescElementImpl extends SVGElementImpl {}
module.exports = {
implementation: SVGDescElementImpl
};

View file

@ -3,7 +3,6 @@
const { domSymbolTree } = require("../helpers/internal-constants");
const { SVG_NS } = require("../helpers/namespaces");
const { mixin } = require("../../utils");
const SVGAnimatedString = require("../generated/SVGAnimatedString");
const ElementImpl = require("./Element-impl").implementation;
const ElementCSSInlineStyleImpl = require("./ElementCSSInlineStyle-impl").implementation;
const GlobalEventHandlersImpl = require("./GlobalEventHandlers-impl").implementation;
@ -30,13 +29,6 @@ class SVGElementImpl extends ElementImpl {
super._attrModified(name, value, oldValue);
}
get className() {
return SVGAnimatedString.createImpl(this._globalObject, [], {
element: this,
attribute: "class"
});
}
get ownerSVGElement() {
let e = domSymbolTree.parent(this);
while (e && e.namespaceURI === SVG_NS) {
@ -50,8 +42,16 @@ class SVGElementImpl extends ElementImpl {
}
get viewportElement() {
// TODO: <symbol>/<use> may make this different from ownerSVGElement.
return this.ownerSVGElement;
// Get the nearest ancestor that establishes the viewport.
// https://svgwg.org/svg2-draft/coords.html#EstablishingANewSVGViewport
let e = domSymbolTree.parent(this);
while (e && e.namespaceURI === SVG_NS) {
if (e.localName === "svg" || e.localName === "symbol") {
return e;
}
e = domSymbolTree.parent(e);
}
return null;
}
}

View file

@ -0,0 +1,9 @@
"use strict";
const SVGGraphicsElementImpl = require("./SVGGraphicsElement-impl").implementation;
class SVGGElementImpl extends SVGGraphicsElementImpl {}
module.exports = {
implementation: SVGGElementImpl
};

View file

@ -0,0 +1,9 @@
"use strict";
const SVGElementImpl = require("./SVGElement-impl").implementation;
class SVGMetadataElementImpl extends SVGElementImpl {}
module.exports = {
implementation: SVGMetadataElementImpl
};

View file

@ -2,6 +2,7 @@
const { mixin } = require("../../utils");
const SVGNumber = require("../generated/SVGNumber");
const SVGRect = require("../generated/SVGRect");
const SVGGraphicsElementImpl = require("./SVGGraphicsElement-impl").implementation;
const WindowEventHandlersImpl = require("./WindowEventHandlers-impl").implementation;
const { domSymbolTree } = require("../helpers/internal-constants");
@ -17,6 +18,10 @@ class SVGSVGElementImpl extends SVGGraphicsElementImpl {
return SVGNumber.createImpl(this._globalObject, [], {});
}
createSVGRect() {
return SVGRect.createImpl(this._globalObject, [], {});
}
getElementById(elementId) {
// TODO: optimize with _ids caching trick; see Document class.
for (const node of domSymbolTree.treeIterator(this)) {

View file

@ -0,0 +1,9 @@
"use strict";
const SVGGraphicsElementImpl = require("./SVGGraphicsElement-impl").implementation;
class SVGSwitchElementImpl extends SVGGraphicsElementImpl {}
module.exports = {
implementation: SVGSwitchElementImpl
};

View file

@ -0,0 +1,9 @@
"use strict";
const SVGGraphicsElementImpl = require("./SVGGraphicsElement-impl").implementation;
class SVGSymbolElementImpl extends SVGGraphicsElementImpl {}
module.exports = {
implementation: SVGSymbolElementImpl
};

View file

@ -0,0 +1,24 @@
"use strict";
const SVGPreserveAspectRatio = require("../generated/SVGPreserveAspectRatio");
class SVGAnimatedPreserveAspectRatioImpl {
constructor(globalObject, args, privateData) {
this._globalObject = globalObject;
this._element = privateData.element;
}
get baseVal() {
return SVGPreserveAspectRatio.createImpl(this._globalObject, [], {
element: this._element
});
}
get animVal() {
return SVGPreserveAspectRatio.createImpl(this._globalObject, [], {
element: this._element
});
}
}
exports.implementation = SVGAnimatedPreserveAspectRatioImpl;

View file

@ -0,0 +1,122 @@
"use strict";
const SVGRect = require("../generated/SVGRect");
// https://drafts.csswg.org/css-syntax/#number-token-diagram
const numberRe = /^[+-]?(?:\d*\.)?\d+(?:[eE][+-]?\d+)?/;
// https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute
function parseViewBox(str) {
// Use a do-while "loop" as JavaScript `goto end`.
// eslint-disable-next-line no-unreachable-loop
do {
// When the attribute does not exist.
if (typeof str !== "string") {
break;
}
let i = 0;
skipSpace();
const xStr = matchNumber();
if (!xStr) {
break;
}
if (!skipDelimiter()) {
break;
}
const yStr = matchNumber();
if (!yStr) {
break;
}
if (!skipDelimiter()) {
break;
}
const widthStr = matchNumber();
if (!widthStr) {
break;
}
if (!skipDelimiter()) {
break;
}
const heightStr = matchNumber();
if (!heightStr) {
break;
}
// Test for trailing junk.
skipSpace();
if (i < str.length) {
break;
}
// A negative value for <width> or <height> is an error and invalidates the 'viewBox' attribute.
const width = Number(widthStr);
if (width < 0) {
break;
}
const height = Number(heightStr);
if (height < 0) {
break;
}
return {
x: Number(xStr),
y: Number(yStr),
width,
height
};
function skipSpace() {
while (i < str.length && str[i] === " ") {
i += 1;
}
}
function matchNumber() {
const numMatch = numberRe.exec(str.slice(i));
if (!numMatch) {
return undefined;
}
i += numMatch[0].length;
return numMatch[0];
}
function skipDelimiter() {
const start = i;
skipSpace();
if (i < str.length && str[i] === ",") {
i += 1;
}
skipSpace();
return i > start;
}
} while (false);
return { x: 0, y: 0, width: 0, height: 0 };
}
class SVGAnimatedRectImpl {
constructor(globalObject, args, privateData) {
this._globalObject = globalObject;
this._element = privateData.element;
this._attribute = privateData.attribute;
}
get baseVal() {
return SVGRect.createImpl(this._globalObject, [], {
reflectedElement: this._element,
reflectedAttribute: this._attribute,
parser: parseViewBox
});
}
get animVal() {
return SVGRect.createImpl(this._globalObject, [], {
reflectedElement: this._element,
reflectedAttribute: this._attribute,
parser: parseViewBox,
readOnly: true
});
}
}
exports.implementation = SVGAnimatedRectImpl;

View file

@ -4,14 +4,18 @@ class SVGAnimatedStringImpl {
constructor(globalObject, args, privateData) {
this._element = privateData.element;
this._attribute = privateData.attribute;
this._attributeDeprecated = privateData.attributeDeprecated; // can be undefined
this._initialValue = privateData.initialValue; // can be undefined
// These three can be undefined.
this._attributeDeprecated = privateData.attributeDeprecated;
this._attributeDeprecatedNamespace = privateData.attributeDeprecatedNamespace;
this._initialValue = privateData.initialValue;
}
get baseVal() {
if (!this._element.hasAttributeNS(null, this._attribute)) {
if (this._attributeDeprecated !== undefined && this._element.hasAttributeNS(null, this._attributeDeprecated)) {
return this._element.getAttributeNS(null, this._attributeDeprecated);
if (this._attributeDeprecated !== undefined &&
this._element.hasAttributeNS(this._attributeDeprecatedNamespace, this._attributeDeprecated)) {
return this._element.getAttributeNS(this._attributeDeprecatedNamespace, this._attributeDeprecated);
} else if (this._initialValue !== undefined) {
return this._initialValue;
}

View file

@ -0,0 +1,100 @@
"use strict";
const DOMException = require("../generated/DOMException");
const alignmentStringsByIndex = [
"unknown", "none",
"xMinYMin", "xMidYMin", "xMaxYMin",
"xMinYMid", "xMidYMid", "xMaxYMid",
"xMinYMax", "xMidYMax", "xMaxYMax"
];
const alignmentIndicesByString = {
__proto__: null,
unknown: 0,
none: 1,
xMinYMin: 2,
xMidYMin: 3,
xMaxYMin: 4,
xMinYMid: 5,
xMidYMid: 6,
xMaxYMid: 7,
xMinYMax: 8,
xMidYMax: 9,
xMaxYMax: 10
};
const meetOrSliceStringsByIndex = ["unknown", "meet", "slice"];
const meetOrSliceIndicesByString = {
__proto__: null,
unknown: 0,
meet: 1,
slice: 2
};
// https://svgwg.org/svg2-draft/coords.html#PreserveAspectRatioAttribute
const preserveAspectRatioRegExp = /^(none|x(?:Min|Mid|Max)Y(?:Min|Mid|Max))(?: +(meet|slice))?$/;
class SVGPreserveAspectRatioImpl {
constructor(globalObject, args, privateData) {
this._globalObject = globalObject;
this._element = privateData.element;
this._readOnly = Boolean(privateData.readOnly);
}
_parse() {
const attrValue = this._element.getAttributeNS(null, "preserveAspectRatio");
if (attrValue) {
const value = preserveAspectRatioRegExp.exec(attrValue);
if (value) {
return {
align: value[1],
meetOrSlice: value[2] || "meet"
};
}
}
return {
align: "xMidYMid",
meetOrSlice: "meet"
};
}
get align() {
const { align } = this._parse();
return alignmentIndicesByString[align];
}
set align(value) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, [
"Attempting to modify a read-only SVGPreserveAspectRatio",
"NoModificationAllowedError"
]);
}
const string = alignmentStringsByIndex[value];
if (string === "unknown" || string === undefined) {
throw new TypeError("Invalid alignment");
}
this._element.setAttributeNS(null, "preserveAspectRatio", `${string} ${this._parse().meetOrSlice}`);
}
get meetOrSlice() {
const { meetOrSlice } = this._parse();
return meetOrSliceIndicesByString[meetOrSlice];
}
set meetOrSlice(value) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, [
"Attempting to modify a read-only SVGPreserveAspectRatio",
"NoModificationAllowedError"
]);
}
const string = meetOrSliceStringsByIndex[value];
if (string === "unknown" || string === undefined) {
throw new TypeError("Invalid meet-or-slice value");
}
this._element.setAttributeNS(null, "preserveAspectRatio", `${this._parse().align} ${string}`);
}
}
exports.implementation = SVGPreserveAspectRatioImpl;

143
node_modules/jsdom/lib/jsdom/living/svg/SVGRect-impl.js generated vendored Normal file
View file

@ -0,0 +1,143 @@
"use strict";
const DOMException = require("../generated/DOMException");
class SVGRectImplRecord {
constructor() {
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
}
}
class SVGRectImplReflection {
constructor(privateData) {
this._reflectedElement = privateData.reflectedElement;
this._reflectedAttribute = privateData.reflectedAttribute;
this._parser = privateData.parser;
}
// https://svgwg.org/svg2-draft/types.html#TermReserialize
_reserialize({ x, y, width, height }) {
this._reflectedElement.setAttributeNS(null, this._reflectedAttribute, `${x} ${y} ${width} ${height}`);
}
get x() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).x;
}
set x(newX) {
const { y, width, height } = this;
this._reserialize({
x: newX,
y,
width,
height
});
}
get y() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).y;
}
set y(newY) {
const { x, width, height } = this;
this._reserialize({
x,
y: newY,
width,
height
});
}
get width() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).width;
}
set width(newWidth) {
const { x, y, height } = this;
this._reserialize({
x,
y,
width: newWidth,
height
});
}
get height() {
const attr = this._reflectedElement.getAttributeNS(null, this._reflectedAttribute);
return this._parser(attr).height;
}
set height(newHeight) {
const { x, y, width } = this;
this._reserialize({
x,
y,
width,
height: newHeight
});
}
}
class SVGRectImpl {
constructor(globalObject, args, { readOnly = false, ...privateData } = {}) {
this._globalObject = globalObject;
this._readOnly = readOnly;
if (privateData.reflectedElement) {
this._impl = new SVGRectImplReflection(privateData);
} else {
this._impl = new SVGRectImplRecord();
}
}
get x() {
return this._impl.x;
}
set x(newX) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.x = newX;
}
get y() {
return this._impl.y;
}
set y(newY) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.y = newY;
}
get width() {
return this._impl.width;
}
set width(newWidth) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.width = newWidth;
}
get height() {
return this._impl.height;
}
set height(newHeight) {
if (this._readOnly) {
throw DOMException.create(this._globalObject, ["This SVGRect is read-only", "NO_MODIFICATION_ALLOWED_ERR"]);
}
this._impl.height = newHeight;
}
}
exports.implementation = SVGRectImpl;

View file

@ -1,6 +1,5 @@
"use strict";
const DOMException = require("../generated/DOMException");
const { documentBaseURLSerialized, parseURLToResultingURLRecord } = require("../helpers/document-base-url.js");
const { serializeURL } = require("whatwg-url");
// https://html.spec.whatwg.org/#history-3
@ -71,12 +70,12 @@ exports.implementation = class HistoryImpl {
let newURL = this._document._URL;
if (url !== null && url.length > 0) {
newURL = parseURLToResultingURLRecord(url, this._document);
newURL = this._document.encodingParseAURL(url);
if (newURL === null) {
throw DOMException.create(this._globalObject, [
`Could not parse url argument "${url}" to ${historyHandling}State() against base URL ` +
`"${documentBaseURLSerialized(this._document)}".`,
`"${this._document.baseURLSerialized()}".`,
"SecurityError"
]);
}
@ -115,6 +114,7 @@ exports.implementation = class HistoryImpl {
// a GET request.
this._document._URL = newURL;
this._document._clearBaseURLCache();
// arguably it's a bit odd that the state and latestEntry do not belong to the SessionHistory
// but the spec gives them to "History" and "Document" respecively.

View file

@ -1,7 +1,6 @@
"use strict";
const whatwgURL = require("whatwg-url");
const DOMException = require("../generated/DOMException");
const { documentBaseURL, parseURLToResultingURLRecord } = require("../helpers/document-base-url");
const { navigate } = require("./navigation");
// Not implemented: use of entry settings object's API base URL in href setter, assign, and replace. Instead we just
@ -39,7 +38,7 @@ exports.implementation = class LocationImpl {
return whatwgURL.serializeURL(this._url);
}
set href(v) {
const newURL = whatwgURL.parseURL(v, { baseURL: documentBaseURL(this._relevantDocument) });
const newURL = whatwgURL.parseURL(v, { baseURL: this._relevantDocument.baseURL() });
if (newURL === null) {
throw new TypeError(`Could not parse "${v}" as a URL`);
}
@ -195,7 +194,7 @@ exports.implementation = class LocationImpl {
assign(url) {
// Should be entry settings object; oh well
const parsedURL = parseURLToResultingURLRecord(url, this._relevantDocument);
const parsedURL = this._relevantDocument.encodingParseAURL(url);
if (parsedURL === null) {
throw DOMException.create(this._globalObject, [
@ -209,7 +208,7 @@ exports.implementation = class LocationImpl {
replace(url) {
// Should be entry settings object; oh well
const parsedURL = parseURLToResultingURLRecord(url, this._relevantDocument);
const parsedURL = this._relevantDocument.encodingParseAURL(url);
if (parsedURL === null) {
throw DOMException.create(this._globalObject, [

View file

@ -9,7 +9,6 @@ const MIMEType = require("whatwg-mimetype");
const xhrUtils = require("./xhr-utils");
const DOMException = require("../generated/DOMException");
const { documentBaseURLSerialized } = require("../helpers/document-base-url");
const { asciiCaseInsensitiveMatch } = require("../helpers/strings");
const idlUtils = require("../generated/utils");
const Document = require("../generated/Document");
@ -25,6 +24,7 @@ const { setupForSimpleEventAccessors } = require("../helpers/create-event-access
const { parseJSONFromBytes } = require("../helpers/json");
const { fireAnEvent } = require("../helpers/events");
const { copyToArrayBufferInNewRealm } = require("../helpers/binary-data");
const { serializeEntryList, chunksToBuffer } = require("./multipart-form-data.js");
const { READY_STATES } = xhrUtils;
@ -33,6 +33,8 @@ const syncWorkerFile = require.resolve ? require.resolve("./xhr-sync-worker.js")
const tokenRegexp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
const fieldValueRegexp = /^[ \t]*(?:[\x21-\x7E\x80-\xFF](?:[ \t][\x21-\x7E\x80-\xFF])?)*[ \t]*$/;
const utf8Decoder = new TextDecoder();
const forbiddenRequestHeaders = new Set([
"accept-charset",
"accept-encoding",
@ -112,7 +114,6 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetImpl {
uri: "",
timeout: 0,
body: undefined,
formData: false,
preflight: false,
requestManager: _ownerDocument._requestManager,
strictSSL: window._resourceLoader._strictSSL,
@ -456,7 +457,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetImpl {
let urlObj;
try {
urlObj = new URL(uri, documentBaseURLSerialized(_ownerDocument));
urlObj = new URL(uri, _ownerDocument.baseURLSerialized());
} catch {
throw DOMException.create(this._globalObject, [
"The string did not match the expected pattern.",
@ -530,15 +531,14 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetImpl {
if (Document.isImpl(body)) {
encoding = "UTF-8";
mimeType = (body._parsingMode === "html" ? "text/html" : "application/xml") + ";charset=UTF-8";
flag.body = fragmentSerialization(body, { requireWellFormed: false });
flag.body = Buffer.from(fragmentSerialization(body, { requireWellFormed: false }));
} else {
if (typeof body === "string") {
encoding = "UTF-8";
}
const { buffer, formData, contentType } = extractBody(body);
const { buffer, contentType } = extractBody(body);
mimeType = contentType;
flag.body = buffer || formData;
flag.formData = Boolean(formData);
flag.body = buffer;
}
const existingContentType = xhrUtils.getRequestHeader(flag.requestHeaders, "content-type");
@ -969,9 +969,7 @@ function normalizeHeaderValue(value) {
function extractBody(bodyInit) {
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
// except we represent the body as a Node.js Buffer instead,
// or a special case for FormData since we want request to handle that. Probably it would be
// cleaner (and allow a future without request) if we did the form encoding ourself.
// except we represent the body as a Node.js Buffer instead.
if (Blob.isImpl(bodyInit)) {
return {
@ -989,28 +987,12 @@ function extractBody(bodyInit) {
contentType: null
};
} else if (FormData.isImpl(bodyInit)) {
const formData = [];
for (const entry of bodyInit._entries) {
let val;
if (Blob.isImpl(entry.value)) {
const blob = entry.value;
val = {
name: entry.name,
value: blob._buffer,
options: {
filename: blob.name,
contentType: blob.type,
knownLength: blob.size
}
};
} else {
val = entry;
}
const { boundary, outputChunks } = serializeEntryList(bodyInit._entries);
formData.push(val);
}
return { formData };
return {
buffer: chunksToBuffer(outputChunks),
contentType: "multipart/form-data; boundary=" + utf8Decoder.decode(boundary)
};
}
// Must be a string

View file

@ -0,0 +1,105 @@
"use strict";
const conversions = require("webidl-conversions");
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract (note: always UTF-8)
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart%2Fform-data-encoding-algorithm
// https://andreubotella.github.io/multipart-form-data/
const utf8Encoder = new TextEncoder();
const contentDispositionPrefix = utf8Encoder.encode(`Content-Disposition: form-data; name="`);
const filenamePrefix = utf8Encoder.encode(`; filename="`);
const contentType = utf8Encoder.encode(`Content-Type: `);
// https://andreubotella.github.io/multipart-form-data/#multipart-form-data-boundary
function generateBoundary() {
let boundary = "--------------------------";
for (let i = 0; i < 24; ++i) {
boundary += Math.floor(Math.random() * 10).toString(16);
}
return utf8Encoder.encode(boundary);
}
// https://andreubotella.github.io/multipart-form-data/#escape-a-multipart-form-data-name
function escapeName(name, isFilename = false) {
if (isFilename) {
name = conversions.USVString(name);
} else {
name = name.replace(/\r(?!\n)|(?<!\r)\n/g, "\r\n");
}
const encoded = utf8Encoder.encode(name);
const encodedWithSubs = [];
for (const originalByte of encoded) {
if (originalByte === 0x0A) {
encodedWithSubs.push(37, 48, 65); // `%0A`
} else if (originalByte === 0x0D) {
encodedWithSubs.push(37, 48, 68); // `%0D`
} else if (originalByte === 0x22) {
encodedWithSubs.push(37, 50, 50); // `%22`
} else {
encodedWithSubs.push(originalByte);
}
}
return new Uint8Array(encodedWithSubs);
}
// https://andreubotella.github.io/multipart-form-data/#multipart-form-data-chunk-serializer
exports.serializeEntryList = entries => {
const boundary = generateBoundary();
const outputChunks = [];
for (const entry of entries) {
const chunkBytes = [
45, 45, // `--`
...boundary,
0x0D, 0x0A
];
chunkBytes.push(...contentDispositionPrefix, ...escapeName(entry.name), 0x22 /* `"` */);
let { value } = entry;
if (typeof value === "string") {
chunkBytes.push(0x0D, 0x0A, 0x0D, 0x0A);
value = value.replace(/\r(?!\n)|(?<!\r)\n/g, "\r\n");
chunkBytes.push(...utf8Encoder.encode(value));
chunkBytes.push(0x0D, 0x0A);
outputChunks.push(new Uint8Array(chunkBytes));
} else {
// value is a FileImpl object
chunkBytes.push(...filenamePrefix, ...escapeName(value.name, true), 0x22, 0x0D, 0x0A);
const type = value.type !== "" ? value.type : "application/octet-stream";
chunkBytes.push(...contentType, ...utf8Encoder.encode(type));
chunkBytes.push(0x0D, 0x0A, 0x0D, 0x0A);
outputChunks.push(
new Uint8Array(chunkBytes),
// The spec returns the File object here but for our purposes the bytes (as a `Buffer`) are more convenient.
value._buffer,
new Uint8Array([0x0D, 0x0A])
);
}
}
outputChunks.push(
new Uint8Array([45, 45]), // `--`
boundary,
new Uint8Array([45, 45]), // `--`
new Uint8Array([0x0D, 0x0A])
);
return { boundary, outputChunks };
};
// Inspired by https://andreubotella.github.io/multipart-form-data/#create-a-multipart-form-data-readable-stream
// (But we don't stream in jsdom, at least for now.)
exports.chunksToBuffer = chunks => {
return Buffer.concat(chunks);
};

View file

@ -9,7 +9,6 @@ const ProgressEvent = require("../generated/ProgressEvent");
const agentFactory = require("../helpers/agent-factory");
const Request = require("../helpers/http-request");
const FormData = require("form-data");
const { fireAnEvent } = require("../helpers/events");
const headerListSeparatorRegexp = /,[ \t]*/;
@ -287,40 +286,17 @@ function createClient(xhr) {
function doRequest() {
try {
let requestBody = body;
requestHeaders["Accept-Encoding"] = "gzip, deflate";
let len = 0;
if (hasBody) {
if (flag.formData) {
// TODO: implement https://html.spec.whatwg.org/#multipart-form-data
// directly instead of using an external library
requestBody = new FormData();
for (const entry of body) {
requestBody.append(entry.name, entry.value, entry.options);
}
len = requestBody.getLengthSync();
requestHeaders["Content-Type"] = `multipart/form-data; boundary=${requestBody.getBoundary()}`;
} else {
if (typeof body === "string") {
len = Buffer.byteLength(body);
} else {
len = body.length;
}
requestBody = Buffer.isBuffer(requestBody) ? requestBody : Buffer.from(requestBody);
}
len = body.byteLength;
requestHeaders["Content-Length"] = len;
}
requestHeaders["Accept-Encoding"] = "gzip, deflate";
const requestClient = new Request(uri, options, { method: flag.method, headers: requestHeaders });
if (hasBody) {
if (flag.formData) {
requestBody.on("error", err => {
requestClient.emit("error", err);
requestClient.abort();
});
requestClient.pipeRequest(requestBody);
} else {
requestClient.write(requestBody);
}
requestClient.write(body);
}
return requestClient;
} catch (e) {

View file

@ -1,19 +0,0 @@
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1,358 +0,0 @@
# Form-Data [![NPM Module](https://img.shields.io/npm/v/form-data.svg)](https://www.npmjs.com/package/form-data) [![Join the chat at https://gitter.im/form-data/form-data](http://form-data.github.io/images/gitterbadge.svg)](https://gitter.im/form-data/form-data)
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
[![Linux Build](https://img.shields.io/travis/form-data/form-data/master.svg?label=linux:6.x-12.x)](https://travis-ci.org/form-data/form-data)
[![MacOS Build](https://img.shields.io/travis/form-data/form-data/master.svg?label=macos:6.x-12.x)](https://travis-ci.org/form-data/form-data)
[![Windows Build](https://img.shields.io/travis/form-data/form-data/master.svg?label=windows:6.x-12.x)](https://travis-ci.org/form-data/form-data)
[![Coverage Status](https://img.shields.io/coveralls/form-data/form-data/master.svg?label=code+coverage)](https://coveralls.io/github/form-data/form-data?branch=master)
[![Dependency Status](https://img.shields.io/david/form-data/form-data.svg)](https://david-dm.org/form-data/form-data)
## Install
```
npm install --save form-data
```
## Usage
In this example we are constructing a form with 3 fields that contain a string,
a buffer and a file stream.
``` javascript
var FormData = require('form-data');
var fs = require('fs');
var form = new FormData();
form.append('my_field', 'my value');
form.append('my_buffer', new Buffer(10));
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
```
Also you can use http-response stream:
``` javascript
var FormData = require('form-data');
var http = require('http');
var form = new FormData();
http.request('http://nodejs.org/images/logo.png', function(response) {
form.append('my_field', 'my value');
form.append('my_buffer', new Buffer(10));
form.append('my_logo', response);
});
```
Or @mikeal's [request](https://github.com/request/request) stream:
``` javascript
var FormData = require('form-data');
var request = require('request');
var form = new FormData();
form.append('my_field', 'my value');
form.append('my_buffer', new Buffer(10));
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
```
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
``` javascript
form.submit('http://example.org/', function(err, res) {
// res response object (http.IncomingMessage) //
res.resume();
});
```
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
### Custom options
You can provide custom options, such as `maxDataSize`:
``` javascript
var FormData = require('form-data');
var form = new FormData({ maxDataSize: 20971520 });
form.append('my_field', 'my value');
form.append('my_buffer', /* something big */);
```
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
### Alternative submission methods
You can use node's http client interface:
``` javascript
var http = require('http');
var request = http.request({
method: 'post',
host: 'example.org',
path: '/upload',
headers: form.getHeaders()
});
form.pipe(request);
request.on('response', function(res) {
console.log(res.statusCode);
});
```
Or if you would prefer the `'Content-Length'` header to be set for you:
``` javascript
form.submit('example.org/upload', function(err, res) {
console.log(res.statusCode);
});
```
To use custom headers and pre-known length in parts:
``` javascript
var CRLF = '\r\n';
var form = new FormData();
var options = {
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
knownLength: 1
};
form.append('my_buffer', buffer, options);
form.submit('http://example.com/', function(err, res) {
if (err) throw err;
console.log('Done');
});
```
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
``` javascript
someModule.stream(function(err, stdout, stderr) {
if (err) throw err;
var form = new FormData();
form.append('file', stdout, {
filename: 'unicycle.jpg', // ... or:
filepath: 'photos/toys/unicycle.jpg',
contentType: 'image/jpeg',
knownLength: 19806
});
form.submit('http://example.com/', function(err, res) {
if (err) throw err;
console.log('Done');
});
});
```
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
``` javascript
form.submit({
host: 'example.com',
path: '/probably.php?extra=params',
auth: 'username:password'
}, function(err, res) {
console.log(res.statusCode);
});
```
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
``` javascript
form.submit({
host: 'example.com',
path: '/surelynot.php',
headers: {'x-test-header': 'test-header-value'}
}, function(err, res) {
console.log(res.statusCode);
});
```
### Methods
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
- [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary)
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
```javascript
var form = new FormData();
form.append( 'my_string', 'my value' );
form.append( 'my_integer', 1 );
form.append( 'my_boolean', true );
form.append( 'my_buffer', new Buffer(10) );
form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) )
```
You may provide a string for options, or an object.
```javascript
// Set filename by providing a string for options
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
// provide an object.
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} );
```
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
This method adds the correct `content-type` header to the provided array of `userHeaders`.
#### _String_ getBoundary()
Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers
for example:
```javascript
--------------------------515890814546601021194782
```
#### _Void_ setBoundary(String _boundary_)
Set the boundary string, overriding the default behavior described above.
_Note: The boundary must be unique and may not appear in the data._
#### _Buffer_ getBuffer()
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
```javascript
var form = new FormData();
form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) );
form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') );
axios.post( 'https://example.com/path/to/api',
form.getBuffer(),
form.getHeaders()
)
```
**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
#### _Integer_ getLengthSync()
Same as `getLength` but synchronous.
_Note: getLengthSync __doesn't__ calculate streams length._
#### _Integer_ getLength( **function** _callback_ )
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
```javascript
this.getLength(function(err, length) {
if (err) {
this._error(err);
return;
}
// add content length
request.setHeader('Content-Length', length);
...
}.bind(this));
```
#### _Boolean_ hasKnownLength()
Checks if the length of added values is known.
#### _Request_ submit( _params_, **function** _callback_ )
Submit the form to a web application.
```javascript
var form = new FormData();
form.append( 'my_string', 'Hello World' );
form.submit( 'http://example.com/', function(err, res) {
// res response object (http.IncomingMessage) //
res.resume();
} );
```
#### _String_ toString()
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
### Integration with other libraries
#### Request
Form submission using [request](https://github.com/request/request):
```javascript
var formData = {
my_field: 'my_value',
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
};
request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});
```
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
#### node-fetch
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
```javascript
var form = new FormData();
form.append('a', 1);
fetch('http://example.com', { method: 'POST', body: form })
.then(function(res) {
return res.json();
}).then(function(json) {
console.log(json);
});
```
#### axios
In Node.js you can post a file using [axios](https://github.com/axios/axios):
```javascript
const form = new FormData();
const stream = fs.createReadStream(PATH_TO_FILE);
form.append('image', stream);
// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
const formHeaders = form.getHeaders();
axios.post('http://example.com', form, {
headers: {
...formHeaders,
},
})
.then(response => response)
.catch(error => error)
```
## Notes
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
- ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```).
- ```submit``` will not add `content-length` if form length is unknown or not calculable.
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
- Starting version `3.x` FormData has dropped support for `node@4.x`.
## License
Form-Data is released under the [MIT](License) license.

View file

@ -1,62 +0,0 @@
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
// Leon Yu <https://github.com/leonyu>
// BendingBender <https://github.com/BendingBender>
// Maple Miao <https://github.com/mapleeit>
/// <reference types="node" />
import * as stream from 'stream';
import * as http from 'http';
export = FormData;
// Extracted because @types/node doesn't export interfaces.
interface ReadableOptions {
highWaterMark?: number;
encoding?: string;
objectMode?: boolean;
read?(this: stream.Readable, size: number): void;
destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void;
autoDestroy?: boolean;
}
interface Options extends ReadableOptions {
writable?: boolean;
readable?: boolean;
dataSize?: number;
maxDataSize?: number;
pauseStreams?: boolean;
}
declare class FormData extends stream.Readable {
constructor(options?: Options);
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
submit(
params: string | FormData.SubmitOptions,
callback?: (error: Error | null, response: http.IncomingMessage) => void
): http.ClientRequest;
getBuffer(): Buffer;
setBoundary(boundary: string): void;
getBoundary(): string;
getLength(callback: (err: Error | null, length: number) => void): void;
getLengthSync(): number;
hasKnownLength(): boolean;
}
declare namespace FormData {
interface Headers {
[key: string]: any;
}
interface AppendOptions {
header?: string | Headers;
knownLength?: number;
filename?: string;
filepath?: string;
contentType?: string;
}
interface SubmitOptions extends http.RequestOptions {
protocol?: 'https:' | 'http:';
}
}

View file

@ -1,2 +0,0 @@
/* eslint-env browser */
module.exports = typeof self == 'object' ? self.FormData : window.FormData;

View file

@ -1,503 +0,0 @@
var CombinedStream = require('combined-stream');
var util = require('util');
var path = require('path');
var http = require('http');
var https = require('https');
var parseUrl = require('url').parse;
var fs = require('fs');
var Stream = require('stream').Stream;
var mime = require('mime-types');
var asynckit = require('asynckit');
var setToStringTag = require('es-set-tostringtag');
var populate = require('./populate.js');
// Public API
module.exports = FormData;
// make it a Stream
util.inherits(FormData, CombinedStream);
/**
* Create readable "multipart/form-data" streams.
* Can be used to submit forms
* and file uploads to other web applications.
*
* @constructor
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
*/
function FormData(options) {
if (!(this instanceof FormData)) {
return new FormData(options);
}
this._overheadLength = 0;
this._valueLength = 0;
this._valuesToMeasure = [];
CombinedStream.call(this);
options = options || {};
for (var option in options) {
this[option] = options[option];
}
}
FormData.LINE_BREAK = '\r\n';
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
FormData.prototype.append = function(field, value, options) {
options = options || {};
// allow filename as single option
if (typeof options == 'string') {
options = {filename: options};
}
var append = CombinedStream.prototype.append.bind(this);
// all that streamy business can't handle numbers
if (typeof value == 'number') {
value = '' + value;
}
// https://github.com/felixge/node-form-data/issues/38
if (Array.isArray(value)) {
// Please convert your array into string
// the way web server expects it
this._error(new Error('Arrays are not supported.'));
return;
}
var header = this._multiPartHeader(field, value, options);
var footer = this._multiPartFooter();
append(header);
append(value);
append(footer);
// pass along options.knownLength
this._trackLength(header, value, options);
};
FormData.prototype._trackLength = function(header, value, options) {
var valueLength = 0;
// used w/ getLengthSync(), when length is known.
// e.g. for streaming directly from a remote server,
// w/ a known file a size, and not wanting to wait for
// incoming file to finish to get its size.
if (options.knownLength != null) {
valueLength += +options.knownLength;
} else if (Buffer.isBuffer(value)) {
valueLength = value.length;
} else if (typeof value === 'string') {
valueLength = Buffer.byteLength(value);
}
this._valueLength += valueLength;
// @check why add CRLF? does this account for custom/multiple CRLFs?
this._overheadLength +=
Buffer.byteLength(header) +
FormData.LINE_BREAK.length;
// empty or either doesn't have path or not an http response or not a stream
if (!value || ( !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) && !(value instanceof Stream))) {
return;
}
// no need to bother with the length
if (!options.knownLength) {
this._valuesToMeasure.push(value);
}
};
FormData.prototype._lengthRetriever = function(value, callback) {
if (Object.prototype.hasOwnProperty.call(value, 'fd')) {
// take read range into a account
// `end` = Infinity > read file till the end
//
// TODO: Looks like there is bug in Node fs.createReadStream
// it doesn't respect `end` options without `start` options
// Fix it when node fixes it.
// https://github.com/joyent/node/issues/7819
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
// when end specified
// no need to calculate range
// inclusive, starts with 0
callback(null, value.end + 1 - (value.start ? value.start : 0));
// not that fast snoopy
} else {
// still need to fetch file size from fs
fs.stat(value.path, function(err, stat) {
var fileSize;
if (err) {
callback(err);
return;
}
// update final size based on the range options
fileSize = stat.size - (value.start ? value.start : 0);
callback(null, fileSize);
});
}
// or http response
} else if (Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
callback(null, +value.headers['content-length']);
// or request stream http://github.com/mikeal/request
} else if (Object.prototype.hasOwnProperty.call(value, 'httpModule')) {
// wait till response come back
value.on('response', function(response) {
value.pause();
callback(null, +response.headers['content-length']);
});
value.resume();
// something else
} else {
callback('Unknown stream');
}
};
FormData.prototype._multiPartHeader = function(field, value, options) {
// custom header specified (as string)?
// it becomes responsible for boundary
// (e.g. to handle extra CRLFs on .NET servers)
if (typeof options.header == 'string') {
return options.header;
}
var contentDisposition = this._getContentDisposition(value, options);
var contentType = this._getContentType(value, options);
var contents = '';
var headers = {
// add custom disposition as third element or keep it two elements if not
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
// if no content type. allow it to be empty array
'Content-Type': [].concat(contentType || [])
};
// allow custom headers.
if (typeof options.header == 'object') {
populate(headers, options.header);
}
var header;
for (var prop in headers) {
if (Object.prototype.hasOwnProperty.call(headers, prop)) {
header = headers[prop];
// skip nullish headers.
if (header == null) {
continue;
}
// convert all headers to arrays.
if (!Array.isArray(header)) {
header = [header];
}
// add non-empty headers.
if (header.length) {
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
}
}
}
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
};
FormData.prototype._getContentDisposition = function(value, options) {
var filename
, contentDisposition
;
if (typeof options.filepath === 'string') {
// custom filepath for relative paths
filename = path.normalize(options.filepath).replace(/\\/g, '/');
} else if (options.filename || value.name || value.path) {
// custom filename take precedence
// formidable and the browser add a name property
// fs- and request- streams have path property
filename = path.basename(options.filename || value.name || value.path);
} else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
// or try http response
filename = path.basename(value.client._httpMessage.path || '');
}
if (filename) {
contentDisposition = 'filename="' + filename + '"';
}
return contentDisposition;
};
FormData.prototype._getContentType = function(value, options) {
// use custom content-type above all
var contentType = options.contentType;
// or try `name` from formidable, browser
if (!contentType && value.name) {
contentType = mime.lookup(value.name);
}
// or try `path` from fs-, request- streams
if (!contentType && value.path) {
contentType = mime.lookup(value.path);
}
// or if it's http-reponse
if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
contentType = value.headers['content-type'];
}
// or guess it from the filepath or filename
if (!contentType && (options.filepath || options.filename)) {
contentType = mime.lookup(options.filepath || options.filename);
}
// fallback to the default content type if `value` is not simple value
if (!contentType && typeof value == 'object') {
contentType = FormData.DEFAULT_CONTENT_TYPE;
}
return contentType;
};
FormData.prototype._multiPartFooter = function() {
return function(next) {
var footer = FormData.LINE_BREAK;
var lastPart = (this._streams.length === 0);
if (lastPart) {
footer += this._lastBoundary();
}
next(footer);
}.bind(this);
};
FormData.prototype._lastBoundary = function() {
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
};
FormData.prototype.getHeaders = function(userHeaders) {
var header;
var formHeaders = {
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
};
for (header in userHeaders) {
if (Object.prototype.hasOwnProperty.call(userHeaders, header)) {
formHeaders[header.toLowerCase()] = userHeaders[header];
}
}
return formHeaders;
};
FormData.prototype.setBoundary = function(boundary) {
this._boundary = boundary;
};
FormData.prototype.getBoundary = function() {
if (!this._boundary) {
this._generateBoundary();
}
return this._boundary;
};
FormData.prototype.getBuffer = function() {
var dataBuffer = new Buffer.alloc(0);
var boundary = this.getBoundary();
// Create the form content. Add Line breaks to the end of data.
for (var i = 0, len = this._streams.length; i < len; i++) {
if (typeof this._streams[i] !== 'function') {
// Add content to the buffer.
if(Buffer.isBuffer(this._streams[i])) {
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
}else {
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
}
// Add break after content.
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
}
}
}
// Add the footer and return the Buffer object.
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
};
FormData.prototype._generateBoundary = function() {
// This generates a 50 character boundary similar to those used by Firefox.
// They are optimized for boyer-moore parsing.
var boundary = '--------------------------';
for (var i = 0; i < 24; i++) {
boundary += Math.floor(Math.random() * 10).toString(16);
}
this._boundary = boundary;
};
// Note: getLengthSync DOESN'T calculate streams length
// As workaround one can calculate file size manually
// and add it as knownLength option
FormData.prototype.getLengthSync = function() {
var knownLength = this._overheadLength + this._valueLength;
// Don't get confused, there are 3 "internal" streams for each keyval pair
// so it basically checks if there is any value added to the form
if (this._streams.length) {
knownLength += this._lastBoundary().length;
}
// https://github.com/form-data/form-data/issues/40
if (!this.hasKnownLength()) {
// Some async length retrievers are present
// therefore synchronous length calculation is false.
// Please use getLength(callback) to get proper length
this._error(new Error('Cannot calculate proper length in synchronous way.'));
}
return knownLength;
};
// Public API to check if length of added values is known
// https://github.com/form-data/form-data/issues/196
// https://github.com/form-data/form-data/issues/262
FormData.prototype.hasKnownLength = function() {
var hasKnownLength = true;
if (this._valuesToMeasure.length) {
hasKnownLength = false;
}
return hasKnownLength;
};
FormData.prototype.getLength = function(cb) {
var knownLength = this._overheadLength + this._valueLength;
if (this._streams.length) {
knownLength += this._lastBoundary().length;
}
if (!this._valuesToMeasure.length) {
process.nextTick(cb.bind(this, null, knownLength));
return;
}
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
if (err) {
cb(err);
return;
}
values.forEach(function(length) {
knownLength += length;
});
cb(null, knownLength);
});
};
FormData.prototype.submit = function(params, cb) {
var request
, options
, defaults = {method: 'post'}
;
// parse provided url if it's string
// or treat it as options object
if (typeof params == 'string') {
params = parseUrl(params);
options = populate({
port: params.port,
path: params.pathname,
host: params.hostname,
protocol: params.protocol
}, defaults);
// use custom params
} else {
options = populate(params, defaults);
// if no port provided use default one
if (!options.port) {
options.port = options.protocol == 'https:' ? 443 : 80;
}
}
// put that good code in getHeaders to some use
options.headers = this.getHeaders(params.headers);
// https if specified, fallback to http in any other case
if (options.protocol == 'https:') {
request = https.request(options);
} else {
request = http.request(options);
}
// get content length and fire away
this.getLength(function(err, length) {
if (err && err !== 'Unknown stream') {
this._error(err);
return;
}
// add content length
if (length) {
request.setHeader('Content-Length', length);
}
this.pipe(request);
if (cb) {
var onResponse;
var callback = function (error, responce) {
request.removeListener('error', callback);
request.removeListener('response', onResponse);
return cb.call(this, error, responce);
};
onResponse = callback.bind(this, null);
request.on('error', callback);
request.on('response', onResponse);
}
}.bind(this));
return request;
};
FormData.prototype._error = function(err) {
if (!this.error) {
this.error = err;
this.pause();
this.emit('error', err);
}
};
FormData.prototype.toString = function () {
return '[object FormData]';
};
setToStringTag(FormData, 'FormData');

View file

@ -1,10 +0,0 @@
// populates missing values
module.exports = function(dst, src) {
Object.keys(src).forEach(function(prop)
{
dst[prop] = dst[prop] || src[prop];
});
return dst;
};

View file

@ -1,74 +0,0 @@
{
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
"name": "form-data",
"description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
"version": "4.0.2",
"repository": {
"type": "git",
"url": "git://github.com/form-data/form-data.git"
},
"main": "./lib/form_data",
"browser": "./lib/browser",
"typings": "./index.d.ts",
"scripts": {
"pretest": "npm run lint",
"pretests-only": "rimraf coverage test/tmp",
"tests-only": "istanbul cover test/run.js",
"posttests-only": "istanbul report lcov text",
"test": "npm run tests-only",
"posttest": "npx npm@'>=10.2' audit --production",
"lint": "eslint --ext=js,mjs .",
"report": "istanbul report lcov text",
"ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8",
"ci-test": "npm run tests-only && npm run browser && npm run report",
"predebug": "rimraf coverage test/tmp",
"debug": "verbose=1 ./test/run.js",
"browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage",
"check": "istanbul check-coverage coverage/coverage*.json",
"files": "pkgfiles --sort=name",
"get-version": "node -e \"console.log(require('./package.json').version)\"",
"update-readme": "sed -i.bak 's/\\/master\\.svg/\\/v'$(npm --silent run get-version)'.svg/g' README.md",
"restore-readme": "mv README.md.bak README.md",
"prepublish": "in-publish && npm run update-readme || not-in-publish",
"postpublish": "npm run restore-readme"
},
"pre-commit": [
"lint",
"ci-test",
"check"
],
"engines": {
"node": ">= 6"
},
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"es-set-tostringtag": "^2.1.0",
"mime-types": "^2.1.12"
},
"devDependencies": {
"@types/combined-stream": "^1.0.6",
"@types/mime-types": "^2.1.4",
"@types/node": "^12.20.55",
"browserify": "^13.3.0",
"browserify-istanbul": "^2.0.0",
"coveralls": "^3.1.1",
"cross-spawn": "^6.0.6",
"eslint": "^6.8.0",
"fake": "^0.2.2",
"far": "^0.0.7",
"formidable": "^1.2.6",
"in-publish": "^2.0.1",
"is-node-modern": "^1.0.0",
"istanbul": "^0.4.5",
"obake": "^0.1.2",
"pkgfiles": "^2.3.2",
"pre-commit": "^1.2.2",
"puppeteer": "^1.20.0",
"request": "~2.87.0",
"rimraf": "^2.7.1",
"tape": "^5.9.0",
"typescript": "^3.9.10"
},
"license": "MIT"
}

View file

@ -132,7 +132,7 @@ function validateLabel(label, {
// be a lowercase letter (a-z), a digit (0-9), or a hyphen-minus (U+002D). (Note: This excludes uppercase ASCII
// A-Z which are mapped in UTS #46 and disallowed in IDNA2008.)"
if (useSTD3ASCIIRules && codePoint <= 0x7F) {
if (!/^[a-z][0-9]-$/u.test(ch)) {
if (!/^(?:[a-z]|[0-9]|-)$/u.test(ch)) {
return false;
}
}

View file

@ -1,6 +1,6 @@
{
"name": "tr46",
"version": "5.1.0",
"version": "5.1.1",
"engines": {
"node": ">=18"
},

14
node_modules/jsdom/package.json generated vendored
View file

@ -1,6 +1,6 @@
{
"name": "jsdom",
"version": "26.0.0",
"version": "26.1.0",
"description": "A JavaScript implementation of many web standards",
"keywords": [
"dom",
@ -25,8 +25,7 @@
"dependencies": {
"cssstyle": "^4.2.1",
"data-urls": "^5.0.0",
"decimal.js": "^10.4.3",
"form-data": "^4.0.1",
"decimal.js": "^10.5.0",
"html-encoding-sniffer": "^4.0.0",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.6",
@ -36,12 +35,12 @@
"rrweb-cssom": "^0.8.0",
"saxes": "^6.0.0",
"symbol-tree": "^3.2.4",
"tough-cookie": "^5.0.0",
"tough-cookie": "^5.1.1",
"w3c-xmlserializer": "^5.0.0",
"webidl-conversions": "^7.0.0",
"whatwg-encoding": "^3.1.1",
"whatwg-mimetype": "^4.0.0",
"whatwg-url": "^14.1.0",
"whatwg-url": "^14.1.1",
"ws": "^8.18.0",
"xml-name-validator": "^5.0.0"
},
@ -56,12 +55,12 @@
"devDependencies": {
"@domenic/eslint-config": "^4.0.1",
"benchmark": "^2.1.4",
"eslint": "^9.17.0",
"eslint": "^9.20.0",
"eslint-plugin-html": "^8.1.2",
"globals": "^15.14.0",
"js-yaml": "^4.1.0",
"minimatch": "^9.0.5",
"mocha": "^11.0.1",
"mocha": "^11.1.0",
"mocha-sugar-free": "^1.4.0",
"pngjs": "^7.0.0",
"server-destroy": "^1.0.1",
@ -86,6 +85,7 @@
"generate-js-globals": "node ./scripts/generate-js-globals.js"
},
"main": "./lib/api.js",
"type": "commonjs",
"engines": {
"node": ">=18"
}