mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 03:02:49 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
17
node_modules/jsdom/lib/README.md
generated
vendored
Normal file
17
node_modules/jsdom/lib/README.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Note: this codebase is in a transitional state
|
||||
|
||||
We're slowly moving from a historical model based on layered "levels" of specs, to the [living standard model](https://wiki.whatwg.org/wiki/FAQ#What_does_.22Living_Standard.22_mean.3F) actually implemented by browsers. As such, the code is kind of a mess.
|
||||
|
||||
**Summary**: new features go in `lib/jsdom/living` and follow the code style there; modifications to existing features will require some spelunking to find out what to modify in-place.
|
||||
|
||||
---
|
||||
|
||||
A lot of the main implementation is in `lib/jsdom/level1` and `lib/jsdom/level2`. (That includes things that didn't appear in the original DOM Level 1 and Level 2 specs, just because the code was located there and we had to patch it.) We're trying to avoid adding new code there, but patching old code is often still required.
|
||||
|
||||
New features generally go in the `lib/jsdom/living` folder, in nice small files, with a clear coding style enforced by ESLint and JSCS.
|
||||
|
||||
We're planning to fix this whole situation with a multi-stage process:
|
||||
|
||||
- First, consolidate any leftovers in `lib/jsdom/browser` and `lib/jsdom/level3`, as well as the more substantial body of code in `lib/jsdom/level2`, into `lib/jsdom/level1`. This will contain the "historical" portion of the jsdom codebase.
|
||||
- Then, embark on a major cleanup and refactoring effort, splitting out small pieces from `lib/jsdom/level1` and into `lib/jsdom/living`, cleaning up the code style and spec compliance as we go.
|
||||
- Finally, collapse the silly directory hierarchy into something less nested.
|
||||
403
node_modules/jsdom/lib/jsdom.js
generated
vendored
Normal file
403
node_modules/jsdom/lib/jsdom.js
generated
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
"use strict";
|
||||
/* eslint-disable no-unused-expressions */
|
||||
() => `jsdom 7.x onward only works on Node.js 4 or newer: https://github.com/tmpvar/jsdom#install`;
|
||||
/* eslint-enable no-unused-expressions */
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const CookieJar = require("tough-cookie").CookieJar;
|
||||
|
||||
const toFileUrl = require("./jsdom/utils").toFileUrl;
|
||||
const defineGetter = require("./jsdom/utils").defineGetter;
|
||||
const defineSetter = require("./jsdom/utils").defineSetter;
|
||||
const documentFeatures = require("./jsdom/browser/documentfeatures");
|
||||
const domToHtml = require("./jsdom/browser/domtohtml").domToHtml;
|
||||
const Window = require("./jsdom/browser/Window");
|
||||
const resourceLoader = require("./jsdom/browser/resource-loader");
|
||||
const VirtualConsole = require("./jsdom/virtual-console");
|
||||
const locationInfo = require("./jsdom/living/helpers/internal-constants").locationInfo;
|
||||
|
||||
require("./jsdom/living"); // Enable living standard features
|
||||
|
||||
/* eslint-disable no-restricted-modules */
|
||||
// TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package
|
||||
// This legacy usage is in the process of being purged.
|
||||
const URL = require("url");
|
||||
/* eslint-enable no-restricted-modules */
|
||||
|
||||
const canReadFilesFromFS = Boolean(fs.readFile); // in a browserify environment, this isn't present
|
||||
|
||||
exports.createVirtualConsole = function (options) {
|
||||
return new VirtualConsole(options);
|
||||
};
|
||||
|
||||
exports.getVirtualConsole = function (window) {
|
||||
return window._virtualConsole;
|
||||
};
|
||||
|
||||
exports.createCookieJar = function () {
|
||||
return new CookieJar(null, { looseMode: true });
|
||||
};
|
||||
|
||||
exports.nodeLocation = function (node) {
|
||||
return node[locationInfo];
|
||||
};
|
||||
|
||||
exports.reconfigureWindow = function (window, newProps) {
|
||||
if ("top" in newProps) {
|
||||
window._top = newProps.top;
|
||||
}
|
||||
};
|
||||
|
||||
exports.debugMode = false;
|
||||
|
||||
// Proxy feature functions to features module.
|
||||
for (const propName of ["availableDocumentFeatures", "defaultDocumentFeatures", "applyDocumentFeatures"]) {
|
||||
defineGetter(exports, propName, () => documentFeatures[propName]);
|
||||
defineSetter(exports, propName, val => documentFeatures[propName] = val);
|
||||
}
|
||||
|
||||
exports.jsdom = function (html, options) {
|
||||
if (options === undefined) {
|
||||
options = {};
|
||||
}
|
||||
if (options.parsingMode === undefined || options.parsingMode === "auto") {
|
||||
options.parsingMode = "html";
|
||||
}
|
||||
|
||||
if (options.parsingMode !== "html" && options.parsingMode !== "xml") {
|
||||
throw new RangeError(`Invalid parsingMode option ${JSON.stringify(options.parsingMode)}; must be either "html", ` +
|
||||
`"xml", "auto", or undefined`);
|
||||
}
|
||||
|
||||
setGlobalDefaultConfig(options);
|
||||
|
||||
// Back-compat hack: we have previously suggested nesting these under document, for jsdom.env at least.
|
||||
// So we need to support that.
|
||||
if (options.document) {
|
||||
if (options.document.cookie !== undefined) {
|
||||
options.cookie = options.document.cookie;
|
||||
}
|
||||
if (options.document.referrer !== undefined) {
|
||||
options.referrer = options.document.referrer;
|
||||
}
|
||||
}
|
||||
|
||||
// List options explicitly to be clear which are passed through
|
||||
const window = new Window({
|
||||
parsingMode: options.parsingMode,
|
||||
contentType: options.contentType,
|
||||
parser: options.parser,
|
||||
url: options.url,
|
||||
referrer: options.referrer,
|
||||
cookieJar: options.cookieJar,
|
||||
cookie: options.cookie,
|
||||
resourceLoader: options.resourceLoader,
|
||||
deferClose: options.deferClose,
|
||||
concurrentNodeIterators: options.concurrentNodeIterators,
|
||||
virtualConsole: options.virtualConsole,
|
||||
pool: options.pool,
|
||||
agentOptions: options.agentOptions,
|
||||
userAgent: options.userAgent
|
||||
});
|
||||
|
||||
documentFeatures.applyDocumentFeatures(window.document, options.features);
|
||||
|
||||
if (options.created) {
|
||||
options.created(null, window.document.defaultView);
|
||||
}
|
||||
|
||||
if (options.parsingMode === "html") {
|
||||
if (html === undefined || html === "") {
|
||||
html = "<html><head></head><body></body></html>";
|
||||
}
|
||||
|
||||
window.document.write(html);
|
||||
}
|
||||
if (options.parsingMode === "xml") {
|
||||
if (html !== undefined) {
|
||||
window.document._htmlToDom.appendHtmlToDocument(html, window.document);
|
||||
}
|
||||
}
|
||||
|
||||
if (window.document.close && !options.deferClose) {
|
||||
window.document.close();
|
||||
}
|
||||
|
||||
return window.document;
|
||||
};
|
||||
|
||||
exports.jQueryify = exports.jsdom.jQueryify = function (window, jqueryUrl, callback) {
|
||||
if (!window || !window.document) {
|
||||
return;
|
||||
}
|
||||
|
||||
const features = window.document.implementation._features;
|
||||
window.document.implementation._addFeature("FetchExternalResources", ["script"]);
|
||||
window.document.implementation._addFeature("ProcessExternalResources", ["script"]);
|
||||
window.document.implementation._addFeature("MutationEvents", ["2.0"]);
|
||||
|
||||
const scriptEl = window.document.createElement("script");
|
||||
scriptEl.className = "jsdom";
|
||||
scriptEl.src = jqueryUrl;
|
||||
scriptEl.onload = scriptEl.onerror = () => {
|
||||
window.document.implementation._features = features;
|
||||
|
||||
if (callback) {
|
||||
callback(window, window.jQuery);
|
||||
}
|
||||
};
|
||||
|
||||
window.document.body.appendChild(scriptEl);
|
||||
};
|
||||
|
||||
exports.env = exports.jsdom.env = function () {
|
||||
const config = getConfigFromArguments(arguments);
|
||||
let req = null;
|
||||
|
||||
if (config.file && canReadFilesFromFS) {
|
||||
req = resourceLoader.readFile(config.file, (err, text) => {
|
||||
if (err) {
|
||||
reportInitError(err, config);
|
||||
return;
|
||||
}
|
||||
|
||||
setParsingModeFromExtension(config, config.file);
|
||||
|
||||
config.html = text;
|
||||
processHTML(config);
|
||||
});
|
||||
} else if (config.html !== undefined) {
|
||||
processHTML(config);
|
||||
} else if (config.url) {
|
||||
req = handleUrl(config);
|
||||
} else if (config.somethingToAutodetect !== undefined) {
|
||||
const url = URL.parse(config.somethingToAutodetect);
|
||||
if (url.protocol && url.hostname) {
|
||||
config.url = config.somethingToAutodetect;
|
||||
req = handleUrl(config.somethingToAutodetect);
|
||||
} else if (canReadFilesFromFS) {
|
||||
req = resourceLoader.readFile(config.somethingToAutodetect, (err, text) => {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT" || err.code === "ENAMETOOLONG") {
|
||||
config.html = config.somethingToAutodetect;
|
||||
processHTML(config);
|
||||
} else {
|
||||
reportInitError(err, config);
|
||||
}
|
||||
} else {
|
||||
setParsingModeFromExtension(config, config.somethingToAutodetect);
|
||||
|
||||
config.html = text;
|
||||
config.url = toFileUrl(config.somethingToAutodetect);
|
||||
processHTML(config);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
config.html = config.somethingToAutodetect;
|
||||
processHTML(config);
|
||||
}
|
||||
}
|
||||
|
||||
function handleUrl() {
|
||||
const options = {
|
||||
encoding: config.encoding || "utf8",
|
||||
headers: config.headers || {},
|
||||
pool: config.pool,
|
||||
agentOptions: config.agentOptions
|
||||
};
|
||||
|
||||
if (config.proxy) {
|
||||
options.proxy = config.proxy;
|
||||
}
|
||||
|
||||
options.headers["User-Agent"] = config.userAgent;
|
||||
|
||||
config.cookieJar = config.cookieJar || exports.createCookieJar();
|
||||
|
||||
return resourceLoader.download(config.url, options, config.cookieJar, null, (err, responseText, res) => {
|
||||
if (err) {
|
||||
reportInitError(err, config);
|
||||
return;
|
||||
}
|
||||
|
||||
// The use of `res.request.uri.href` ensures that `window.location.href`
|
||||
// is updated when `request` follows redirects.
|
||||
config.html = responseText;
|
||||
config.url = res.request.uri.href;
|
||||
|
||||
const contentType = res.headers["content-type"];
|
||||
|
||||
if (config.parsingMode === "auto" && (
|
||||
contentType === "application/xml" ||
|
||||
contentType === "text/xml" ||
|
||||
contentType === "application/xhtml+xml")) {
|
||||
config.parsingMode = "xml";
|
||||
}
|
||||
|
||||
processHTML(config);
|
||||
});
|
||||
}
|
||||
return req;
|
||||
};
|
||||
|
||||
exports.serializeDocument = function (doc) {
|
||||
return domToHtml([doc]);
|
||||
};
|
||||
|
||||
function processHTML(config) {
|
||||
const window = exports.jsdom(config.html, config).defaultView;
|
||||
const features = JSON.parse(JSON.stringify(window.document.implementation._features));
|
||||
|
||||
let docsLoaded = 0;
|
||||
const totalDocs = config.scripts.length + config.src.length;
|
||||
|
||||
if (!window || !window.document) {
|
||||
reportInitError(new Error("JSDOM: a window object could not be created."), config);
|
||||
return;
|
||||
}
|
||||
|
||||
function scriptComplete() {
|
||||
docsLoaded++;
|
||||
|
||||
if (docsLoaded >= totalDocs) {
|
||||
window.document.implementation._features = features;
|
||||
|
||||
process.nextTick(() => {
|
||||
if (config.onload) {
|
||||
config.onload(window);
|
||||
}
|
||||
if (config.done) {
|
||||
config.done(null, window);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function handleScriptError() {
|
||||
// nextTick so that an exception within scriptComplete won't cause
|
||||
// another script onerror (which would be an infinite loop)
|
||||
process.nextTick(scriptComplete);
|
||||
}
|
||||
|
||||
if (config.scripts.length > 0 || config.src.length > 0) {
|
||||
window.document.implementation._addFeature("FetchExternalResources", ["script"]);
|
||||
window.document.implementation._addFeature("ProcessExternalResources", ["script"]);
|
||||
window.document.implementation._addFeature("MutationEvents", ["2.0"]);
|
||||
|
||||
for (const scriptSrc of config.scripts) {
|
||||
const script = window.document.createElement("script");
|
||||
script.className = "jsdom";
|
||||
script.onload = scriptComplete;
|
||||
script.onerror = handleScriptError;
|
||||
script.src = scriptSrc;
|
||||
|
||||
window.document.body.appendChild(script);
|
||||
}
|
||||
|
||||
for (const scriptText of config.src) {
|
||||
const script = window.document.createElement("script");
|
||||
script.onload = scriptComplete;
|
||||
script.onerror = handleScriptError;
|
||||
script.text = scriptText;
|
||||
|
||||
window.document.documentElement.appendChild(script);
|
||||
window.document.documentElement.removeChild(script);
|
||||
}
|
||||
} else if (window.document.readyState === "complete") {
|
||||
scriptComplete();
|
||||
} else {
|
||||
window.addEventListener("load", scriptComplete);
|
||||
}
|
||||
}
|
||||
|
||||
function setGlobalDefaultConfig(config) {
|
||||
config.pool = config.pool !== undefined ? config.pool : {
|
||||
maxSockets: 6
|
||||
};
|
||||
|
||||
config.agentOptions = config.agentOptions !== undefined ? config.agentOptions : {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 115 * 1000
|
||||
};
|
||||
|
||||
config.userAgent = config.userAgent || "Node.js (" + process.platform + "; U; rv:" + process.version + ")";
|
||||
}
|
||||
|
||||
function getConfigFromArguments(args) {
|
||||
const config = {};
|
||||
if (typeof args[0] === "object") {
|
||||
Object.assign(config, args[0]);
|
||||
} else {
|
||||
for (const arg of args) {
|
||||
switch (typeof arg) {
|
||||
case "string":
|
||||
config.somethingToAutodetect = arg;
|
||||
break;
|
||||
case "function":
|
||||
config.done = arg;
|
||||
break;
|
||||
case "object":
|
||||
if (Array.isArray(arg)) {
|
||||
config.scripts = arg;
|
||||
} else {
|
||||
Object.assign(config, arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.done && !config.created && !config.onload) {
|
||||
throw new Error("Must pass a \"created\", \"onload\", or \"done\" option, or a callback, to jsdom.env");
|
||||
}
|
||||
|
||||
if (config.somethingToAutodetect === undefined &&
|
||||
config.html === undefined && !config.file && !config.url) {
|
||||
throw new Error("Must pass a \"html\", \"file\", or \"url\" option, or a string, to jsdom.env");
|
||||
}
|
||||
|
||||
config.scripts = ensureArray(config.scripts);
|
||||
config.src = ensureArray(config.src);
|
||||
config.parsingMode = config.parsingMode || "auto";
|
||||
|
||||
config.features = config.features || {
|
||||
FetchExternalResources: false,
|
||||
ProcessExternalResources: false,
|
||||
SkipExternalResources: false
|
||||
};
|
||||
|
||||
if (!config.url && config.file) {
|
||||
config.url = toFileUrl(config.file);
|
||||
}
|
||||
|
||||
setGlobalDefaultConfig(config);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function reportInitError(err, config) {
|
||||
if (config.created) {
|
||||
config.created(err);
|
||||
}
|
||||
if (config.done) {
|
||||
config.done(err);
|
||||
}
|
||||
}
|
||||
|
||||
function ensureArray(value) {
|
||||
let array = value || [];
|
||||
if (typeof array === "string") {
|
||||
array = [array];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
function setParsingModeFromExtension(config, filename) {
|
||||
if (config.parsingMode === "auto") {
|
||||
const ext = path.extname(filename);
|
||||
if (ext === ".xhtml" || ext === ".xml") {
|
||||
config.parsingMode = "xml";
|
||||
}
|
||||
}
|
||||
}
|
||||
424
node_modules/jsdom/lib/jsdom/browser/Window.js
generated
vendored
Normal file
424
node_modules/jsdom/lib/jsdom/browser/Window.js
generated
vendored
Normal file
@@ -0,0 +1,424 @@
|
||||
"use strict";
|
||||
|
||||
const CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
|
||||
const notImplemented = require("./not-implemented");
|
||||
const History = require("./history");
|
||||
const VirtualConsole = require("../virtual-console");
|
||||
const define = require("../utils").define;
|
||||
const inherits = require("../utils").inheritFrom;
|
||||
const EventTarget = require("../living/generated/EventTarget");
|
||||
const namedPropertiesWindow = require("../living/named-properties-window");
|
||||
const cssom = require("cssom");
|
||||
const postMessage = require("../living/post-message");
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
const btoa = require("abab").btoa;
|
||||
const atob = require("abab").atob;
|
||||
const idlUtils = require("../living/generated/utils");
|
||||
const internalConstants = require("../living/helpers/internal-constants");
|
||||
const createFileReader = require("../living/file-reader");
|
||||
const createXMLHttpRequest = require("../living/xmlhttprequest");
|
||||
|
||||
// NB: the require() must be after assigning `module.export` because this require() is circular
|
||||
module.exports = Window;
|
||||
const dom = require("../living");
|
||||
|
||||
const cssSelectorSplitRE = /((?:[^,"']|"[^"]*"|'[^']*')+)/;
|
||||
|
||||
const defaultStyleSheet = cssom.parse(require("./default-stylesheet"));
|
||||
|
||||
dom.Window = Window;
|
||||
|
||||
// NOTE: per https://heycam.github.io/webidl/#Global, all properties on the Window object must be own-properties.
|
||||
// That is why we assign everything inside of the constructor, instead of using a shared prototype.
|
||||
// You can verify this in e.g. Firefox or Internet Explorer, which do a good job with Web IDL compliance.
|
||||
|
||||
function Window(options) {
|
||||
EventTarget.setup(this);
|
||||
|
||||
const window = this;
|
||||
|
||||
///// INTERFACES FROM THE DOM
|
||||
// TODO: consider a mode of some sort where these are not shared between all DOM instances
|
||||
// It'd be very memory-expensive in most cases, though.
|
||||
define(window, dom);
|
||||
|
||||
///// PRIVATE DATA PROPERTIES
|
||||
|
||||
// vm initialization is defered until script processing is activated (in level1/core)
|
||||
this._globalProxy = this;
|
||||
|
||||
this.__timers = [];
|
||||
|
||||
// List options explicitly to be clear which are passed through
|
||||
this._document = new dom.HTMLDocument({
|
||||
parsingMode: options.parsingMode,
|
||||
contentType: options.contentType,
|
||||
cookieJar: options.cookieJar,
|
||||
parser: options.parser,
|
||||
url: options.url,
|
||||
referrer: options.referrer,
|
||||
cookie: options.cookie,
|
||||
deferClose: options.deferClose,
|
||||
resourceLoader: options.resourceLoader,
|
||||
concurrentNodeIterators: options.concurrentNodeIterators,
|
||||
pool: options.pool,
|
||||
agentOptions: options.agentOptions,
|
||||
userAgent: options.userAgent,
|
||||
defaultView: this._globalProxy,
|
||||
global: this
|
||||
});
|
||||
|
||||
|
||||
// Set up the window as if it's a top level window.
|
||||
// If it's not, then references will be corrected by frame/iframe code.
|
||||
this._parent = this._top = this._globalProxy;
|
||||
|
||||
// This implements window.frames.length, since window.frames returns a
|
||||
// self reference to the window object. This value is incremented in the
|
||||
// HTMLFrameElement init function (see: level2/html.js).
|
||||
this._length = 0;
|
||||
|
||||
if (options.virtualConsole) {
|
||||
if (options.virtualConsole instanceof VirtualConsole) {
|
||||
this._virtualConsole = options.virtualConsole;
|
||||
} else {
|
||||
throw new TypeError(
|
||||
"options.virtualConsole must be a VirtualConsole (from createVirtualConsole)");
|
||||
}
|
||||
} else {
|
||||
this._virtualConsole = new VirtualConsole();
|
||||
}
|
||||
|
||||
///// GETTERS
|
||||
|
||||
define(this, {
|
||||
get length() {
|
||||
return window._length;
|
||||
},
|
||||
get window() {
|
||||
return window._globalProxy;
|
||||
},
|
||||
get frames() {
|
||||
return window._globalProxy;
|
||||
},
|
||||
get self() {
|
||||
return window._globalProxy;
|
||||
},
|
||||
get parent() {
|
||||
return window._parent;
|
||||
},
|
||||
get top() {
|
||||
return window._top;
|
||||
},
|
||||
get document() {
|
||||
return window._document;
|
||||
},
|
||||
get location() {
|
||||
return window._document._location;
|
||||
}
|
||||
});
|
||||
|
||||
namedPropertiesWindow.initializeWindow(this, dom.HTMLCollection);
|
||||
|
||||
///// METHODS for [ImplicitThis] hack
|
||||
// See https://lists.w3.org/Archives/Public/public-script-coord/2015JanMar/0109.html
|
||||
this.addEventListener = this.addEventListener.bind(this);
|
||||
this.removeEventListener = this.removeEventListener.bind(this);
|
||||
this.dispatchEvent = this.dispatchEvent.bind(this);
|
||||
|
||||
///// METHODS
|
||||
|
||||
this.setTimeout = function (fn, ms) {
|
||||
return startTimer(window, setTimeout, clearTimeout, fn, ms);
|
||||
};
|
||||
this.setInterval = function (fn, ms) {
|
||||
return startTimer(window, setInterval, clearInterval, fn, ms);
|
||||
};
|
||||
this.clearInterval = stopTimer.bind(this, window);
|
||||
this.clearTimeout = stopTimer.bind(this, window);
|
||||
this.__stopAllTimers = stopAllTimers.bind(this, window);
|
||||
|
||||
this.Image = function (width, height) {
|
||||
const element = window._document.createElement("img");
|
||||
element.width = width;
|
||||
element.height = height;
|
||||
return element;
|
||||
};
|
||||
|
||||
function wrapConsoleMethod(method) {
|
||||
return function () {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
window._virtualConsole.emit.apply(window._virtualConsole, [method].concat(args));
|
||||
};
|
||||
}
|
||||
|
||||
this.postMessage = postMessage;
|
||||
|
||||
this.atob = function (str) {
|
||||
const result = atob(str);
|
||||
if (result === null) {
|
||||
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
|
||||
"The string to be decoded contains invalid characters.");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
this.btoa = function (str) {
|
||||
const result = btoa(str);
|
||||
if (result === null) {
|
||||
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
|
||||
"The string to be encoded contains invalid characters.");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
this.FileReader = createFileReader(this);
|
||||
this.XMLHttpRequest = createXMLHttpRequest(this);
|
||||
|
||||
// TODO: necessary for Blob and FileReader due to different-globals weirdness; investigate how to avoid this.
|
||||
this.ArrayBuffer = ArrayBuffer;
|
||||
this.Int8Array = Int8Array;
|
||||
this.Uint8Array = Uint8Array;
|
||||
this.Uint8ClampedArray = Uint8ClampedArray;
|
||||
this.Int16Array = Int16Array;
|
||||
this.Uint16Array = Uint16Array;
|
||||
this.Int32Array = Int32Array;
|
||||
this.Uint32Array = Uint32Array;
|
||||
this.Float32Array = Float32Array;
|
||||
this.Float64Array = Float64Array;
|
||||
|
||||
this.stop = function () {
|
||||
if (this._document[internalConstants.requestManager]) {
|
||||
this._document[internalConstants.requestManager].close();
|
||||
}
|
||||
};
|
||||
|
||||
this.close = function () {
|
||||
// Recursively close child frame windows, then ourselves.
|
||||
const currentWindow = this;
|
||||
(function windowCleaner(windowToClean) {
|
||||
for (let i = 0; i < windowToClean.length; i++) {
|
||||
windowCleaner(windowToClean[i]);
|
||||
}
|
||||
|
||||
// We"re already in our own window.close().
|
||||
if (windowToClean !== currentWindow) {
|
||||
windowToClean.close();
|
||||
}
|
||||
}(this));
|
||||
|
||||
// Clear out all listeners. Any in-flight or upcoming events should not get delivered.
|
||||
idlUtils.implForWrapper(this)._eventListeners = Object.create(null);
|
||||
|
||||
if (this._document) {
|
||||
if (this._document.body) {
|
||||
this._document.body.innerHTML = "";
|
||||
}
|
||||
|
||||
if (this._document.close) {
|
||||
// It's especially important to clear out the listeners here because document.close() causes a "load" event to
|
||||
// fire.
|
||||
this._document._listeners = Object.create(null);
|
||||
this._document.close();
|
||||
}
|
||||
const doc = this._document;
|
||||
delete this._document;
|
||||
// Stops the connections after document deletion because the listeners will not be triggered once document deleted
|
||||
if (doc[internalConstants.requestManager]) {
|
||||
doc[internalConstants.requestManager].close();
|
||||
}
|
||||
}
|
||||
|
||||
stopAllTimers(currentWindow);
|
||||
};
|
||||
|
||||
this.getComputedStyle = function (node) {
|
||||
const s = node.style;
|
||||
const cs = new CSSStyleDeclaration();
|
||||
const forEach = Array.prototype.forEach;
|
||||
|
||||
function setPropertiesFromRule(rule) {
|
||||
if (!rule.selectorText) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectors = rule.selectorText.split(cssSelectorSplitRE);
|
||||
let matched = false;
|
||||
for (const selectorText of selectors) {
|
||||
if (selectorText !== "" && selectorText !== "," && !matched && matchesDontThrow(node, selectorText)) {
|
||||
matched = true;
|
||||
forEach.call(rule.style, property => {
|
||||
cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function readStylesFromStyleSheet(sheet) {
|
||||
forEach.call(sheet.cssRules, rule => {
|
||||
if (rule.media) {
|
||||
if (Array.prototype.indexOf.call(rule.media, "screen") !== -1) {
|
||||
forEach.call(rule.cssRules, setPropertiesFromRule);
|
||||
}
|
||||
} else {
|
||||
setPropertiesFromRule(rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
readStylesFromStyleSheet(defaultStyleSheet);
|
||||
forEach.call(node.ownerDocument.styleSheets, readStylesFromStyleSheet);
|
||||
|
||||
forEach.call(s, property => {
|
||||
cs.setProperty(property, s.getPropertyValue(property), s.getPropertyPriority(property));
|
||||
});
|
||||
|
||||
return cs;
|
||||
};
|
||||
|
||||
///// PUBLIC DATA PROPERTIES (TODO: should be getters)
|
||||
|
||||
this.history = new History(this);
|
||||
|
||||
this.console = {
|
||||
assert: wrapConsoleMethod("assert"),
|
||||
clear: wrapConsoleMethod("clear"),
|
||||
count: wrapConsoleMethod("count"),
|
||||
debug: wrapConsoleMethod("debug"),
|
||||
error: wrapConsoleMethod("error"),
|
||||
group: wrapConsoleMethod("group"),
|
||||
groupCollapse: wrapConsoleMethod("groupCollapse"),
|
||||
groupEnd: wrapConsoleMethod("groupEnd"),
|
||||
info: wrapConsoleMethod("info"),
|
||||
log: wrapConsoleMethod("log"),
|
||||
table: wrapConsoleMethod("table"),
|
||||
time: wrapConsoleMethod("time"),
|
||||
timeEnd: wrapConsoleMethod("timeEnd"),
|
||||
trace: wrapConsoleMethod("trace"),
|
||||
warn: wrapConsoleMethod("warn")
|
||||
};
|
||||
|
||||
function notImplementedMethod(name) {
|
||||
return function () {
|
||||
notImplemented(name, window);
|
||||
};
|
||||
}
|
||||
|
||||
define(this, {
|
||||
navigator: {
|
||||
get userAgent() {
|
||||
return options.userAgent;
|
||||
},
|
||||
get appName() {
|
||||
return "Node.js jsDom";
|
||||
},
|
||||
get platform() {
|
||||
return process.platform;
|
||||
},
|
||||
get appVersion() {
|
||||
return process.version;
|
||||
},
|
||||
noUI: true,
|
||||
get cookieEnabled() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
name: "nodejs",
|
||||
innerWidth: 1024,
|
||||
innerHeight: 768,
|
||||
outerWidth: 1024,
|
||||
outerHeight: 768,
|
||||
pageXOffset: 0,
|
||||
pageYOffset: 0,
|
||||
screenX: 0,
|
||||
screenY: 0,
|
||||
screenLeft: 0,
|
||||
screenTop: 0,
|
||||
scrollX: 0,
|
||||
scrollY: 0,
|
||||
scrollTop: 0,
|
||||
scrollLeft: 0,
|
||||
screen: {
|
||||
width: 0,
|
||||
height: 0
|
||||
},
|
||||
|
||||
alert: notImplementedMethod("window.alert"),
|
||||
blur: notImplementedMethod("window.blur"),
|
||||
confirm: notImplementedMethod("window.confirm"),
|
||||
createPopup: notImplementedMethod("window.createPopup"),
|
||||
focus: notImplementedMethod("window.focus"),
|
||||
moveBy: notImplementedMethod("window.moveBy"),
|
||||
moveTo: notImplementedMethod("window.moveTo"),
|
||||
open: notImplementedMethod("window.open"),
|
||||
print: notImplementedMethod("window.print"),
|
||||
prompt: notImplementedMethod("window.prompt"),
|
||||
resizeBy: notImplementedMethod("window.resizeBy"),
|
||||
resizeTo: notImplementedMethod("window.resizeTo"),
|
||||
scroll: notImplementedMethod("window.scroll"),
|
||||
scrollBy: notImplementedMethod("window.scrollBy"),
|
||||
scrollTo: notImplementedMethod("window.scrollTo"),
|
||||
|
||||
toString: () => {
|
||||
return "[object Window]";
|
||||
}
|
||||
});
|
||||
|
||||
///// INITIALIZATION
|
||||
|
||||
process.nextTick(() => {
|
||||
if (!window.document) {
|
||||
return; // window might've been closed already
|
||||
}
|
||||
|
||||
if (window.document.readyState === "complete") {
|
||||
const ev = window.document.createEvent("HTMLEvents");
|
||||
ev.initEvent("load", false, false);
|
||||
window.dispatchEvent(ev);
|
||||
} else {
|
||||
window.document.addEventListener("load", () => {
|
||||
const ev = window.document.createEvent("HTMLEvents");
|
||||
ev.initEvent("load", false, false);
|
||||
window.dispatchEvent(ev);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inherits(EventTarget.interface, Window, EventTarget.interface.prototype);
|
||||
|
||||
function matchesDontThrow(el, selector) {
|
||||
try {
|
||||
return el.matches(selector);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function startTimer(window, startFn, stopFn, callback, ms) {
|
||||
const res = startFn(callback, ms);
|
||||
window.__timers.push([res, stopFn]);
|
||||
return res;
|
||||
}
|
||||
|
||||
function stopTimer(window, id) {
|
||||
if (typeof id === "undefined") {
|
||||
return;
|
||||
}
|
||||
for (const i in window.__timers) {
|
||||
if (window.__timers[i][0] === id) {
|
||||
window.__timers[i][1].call(window, id);
|
||||
window.__timers.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllTimers(window) {
|
||||
for (const t of window.__timers) {
|
||||
t[1].call(window, t[0]);
|
||||
}
|
||||
window.__timers = [];
|
||||
}
|
||||
|
||||
1129
node_modules/jsdom/lib/jsdom/browser/default-stylesheet.js
generated
vendored
Normal file
1129
node_modules/jsdom/lib/jsdom/browser/default-stylesheet.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
65
node_modules/jsdom/lib/jsdom/browser/documentAdapter.js
generated
vendored
Normal file
65
node_modules/jsdom/lib/jsdom/browser/documentAdapter.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
|
||||
// Tree traversing
|
||||
exports.getFirstChild = function (node) {
|
||||
return node.childNodes[0];
|
||||
};
|
||||
|
||||
exports.getChildNodes = function (node) {
|
||||
// parse5 treats template elements specially, assuming you return an array whose single item is the document fragment
|
||||
return node._templateContents ? [node._templateContents] : node.childNodes;
|
||||
};
|
||||
|
||||
exports.getParentNode = function (node) {
|
||||
return node.parentNode;
|
||||
};
|
||||
|
||||
exports.getAttrList = function (node) {
|
||||
return node.attributes;
|
||||
};
|
||||
|
||||
// Node data
|
||||
exports.getTagName = function (element) {
|
||||
return element.tagName.toLowerCase();
|
||||
};
|
||||
|
||||
exports.getNamespaceURI = function (element) {
|
||||
return element.namespaceURI || "http://www.w3.org/1999/xhtml";
|
||||
};
|
||||
|
||||
exports.getTextNodeContent = function (textNode) {
|
||||
return textNode.nodeValue;
|
||||
};
|
||||
|
||||
exports.getCommentNodeContent = function (commentNode) {
|
||||
return commentNode.nodeValue;
|
||||
};
|
||||
|
||||
exports.getDocumentTypeNodeName = function (doctypeNode) {
|
||||
return doctypeNode.name;
|
||||
};
|
||||
|
||||
exports.getDocumentTypeNodePublicId = function (doctypeNode) {
|
||||
return doctypeNode.publicId || null;
|
||||
};
|
||||
|
||||
exports.getDocumentTypeNodeSystemId = function (doctypeNode) {
|
||||
return doctypeNode.systemId || null;
|
||||
};
|
||||
|
||||
// Node types
|
||||
exports.isTextNode = function (node) {
|
||||
return node.nodeName === "#text";
|
||||
};
|
||||
|
||||
exports.isCommentNode = function (node) {
|
||||
return node.nodeName === "#comment";
|
||||
};
|
||||
|
||||
exports.isDocumentTypeNode = function (node) {
|
||||
return node.nodeType === 10;
|
||||
};
|
||||
|
||||
exports.isElementNode = function (node) {
|
||||
return Boolean(node.tagName);
|
||||
};
|
||||
48
node_modules/jsdom/lib/jsdom/browser/documentfeatures.js
generated
vendored
Normal file
48
node_modules/jsdom/lib/jsdom/browser/documentfeatures.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
exports.availableDocumentFeatures = [
|
||||
"FetchExternalResources",
|
||||
"ProcessExternalResources",
|
||||
"MutationEvents",
|
||||
"SkipExternalResources"
|
||||
];
|
||||
|
||||
exports.defaultDocumentFeatures = {
|
||||
FetchExternalResources: ["script", "link"], // omitted by default: "frame"
|
||||
ProcessExternalResources: ["script"], // omitted by default: "frame", "iframe"
|
||||
MutationEvents: "2.0",
|
||||
SkipExternalResources: false
|
||||
};
|
||||
|
||||
exports.applyDocumentFeatures = function (doc, features) {
|
||||
features = features || {};
|
||||
|
||||
for (let i = 0; i < exports.availableDocumentFeatures.length; ++i) {
|
||||
const featureName = exports.availableDocumentFeatures[i];
|
||||
let featureSource;
|
||||
|
||||
if (features[featureName] !== undefined) {
|
||||
featureSource = features[featureName];
|
||||
// We have to check the lowercase version also because the Document feature
|
||||
// methods convert everything to lowercase.
|
||||
} else if (typeof features[featureName.toLowerCase()] !== "undefined") {
|
||||
featureSource = features[featureName.toLowerCase()];
|
||||
} else if (exports.defaultDocumentFeatures[featureName]) {
|
||||
featureSource = exports.defaultDocumentFeatures[featureName];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
doc.implementation._removeFeature(featureName);
|
||||
|
||||
if (featureSource !== undefined) {
|
||||
if (Array.isArray(featureSource)) {
|
||||
for (let j = 0; j < featureSource.length; ++j) {
|
||||
doc.implementation._addFeature(featureName, featureSource[j]);
|
||||
}
|
||||
} else {
|
||||
doc.implementation._addFeature(featureName, featureSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
18
node_modules/jsdom/lib/jsdom/browser/domtohtml.js
generated
vendored
Normal file
18
node_modules/jsdom/lib/jsdom/browser/domtohtml.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
const parse5 = require("parse5");
|
||||
const documentAdapter = require("./documentAdapter");
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
const serializer = new parse5.TreeSerializer(documentAdapter);
|
||||
|
||||
exports.domToHtml = function (iterable) {
|
||||
let ret = "";
|
||||
for (const node of iterable) {
|
||||
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
|
||||
ret += serializer.serialize(node);
|
||||
} else {
|
||||
ret += serializer.serialize({ childNodes: [node] });
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
92
node_modules/jsdom/lib/jsdom/browser/history.js
generated
vendored
Normal file
92
node_modules/jsdom/lib/jsdom/browser/history.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
const whatwgURL = require("whatwg-url-compat");
|
||||
const resolveHref = require("../utils").resolveHref;
|
||||
|
||||
function StateEntry(data, title, url) {
|
||||
this.data = data;
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
module.exports = History;
|
||||
|
||||
function History(window) {
|
||||
this._states = [new StateEntry(null, "", window._document._URL)];
|
||||
this._index = 0;
|
||||
this._window = window;
|
||||
this._location = window._document._location;
|
||||
}
|
||||
|
||||
History.prototype = {
|
||||
constructor: History,
|
||||
|
||||
get length() {
|
||||
return this._states.length;
|
||||
},
|
||||
|
||||
get state() {
|
||||
const state = this._states[this._index];
|
||||
return state ? state.data : null;
|
||||
},
|
||||
|
||||
back() {
|
||||
this.go(-1);
|
||||
},
|
||||
|
||||
forward() {
|
||||
this.go(1);
|
||||
},
|
||||
|
||||
go(delta) {
|
||||
if (typeof delta === "undefined" || delta === 0) {
|
||||
this._location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
const newIndex = this._index + delta;
|
||||
|
||||
if (newIndex < 0 || newIndex >= this.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._index = newIndex;
|
||||
|
||||
const state = this._states[newIndex];
|
||||
|
||||
this._applyState(state);
|
||||
this._signalPopstate(state);
|
||||
},
|
||||
|
||||
pushState(data, title, url) {
|
||||
const state = new StateEntry(data, title, url);
|
||||
if (this._index + 1 !== this._states.length) {
|
||||
this._states = this._states.slice(0, this._index + 1);
|
||||
}
|
||||
this._states.push(state);
|
||||
this._applyState(state);
|
||||
this._index++;
|
||||
},
|
||||
|
||||
replaceState(data, title, url) {
|
||||
const state = new StateEntry(data, title, url);
|
||||
this._states[this._index] = state;
|
||||
this._applyState(state);
|
||||
},
|
||||
|
||||
_applyState(state) {
|
||||
whatwgURL.setTheInput(this._location, resolveHref(this._location.href, state.url));
|
||||
},
|
||||
|
||||
_signalPopstate(state) {
|
||||
if (this._window.document) {
|
||||
const ev = this._window.document.createEvent("HTMLEvents");
|
||||
ev.initEvent("popstate", false, false);
|
||||
ev.state = state.data;
|
||||
process.nextTick(() => this._window.dispatchEvent(ev));
|
||||
}
|
||||
},
|
||||
|
||||
toString() {
|
||||
return "[object History]";
|
||||
}
|
||||
};
|
||||
299
node_modules/jsdom/lib/jsdom/browser/htmltodom.js
generated
vendored
Normal file
299
node_modules/jsdom/lib/jsdom/browser/htmltodom.js
generated
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
"use strict";
|
||||
|
||||
const parse5 = require("parse5");
|
||||
const sax = require("sax");
|
||||
const attributes = require("../living/attributes");
|
||||
const createDocumentTypeInternal = require("../living/document-type").create;
|
||||
const locationInfo = require("../living/helpers/internal-constants").locationInfo;
|
||||
|
||||
class HtmlToDom {
|
||||
constructor(core, parser, parsingMode) {
|
||||
if (!parser) {
|
||||
if (parsingMode === "xml") {
|
||||
parser = sax;
|
||||
} else {
|
||||
parser = parse5;
|
||||
}
|
||||
}
|
||||
|
||||
this.core = core;
|
||||
this.parser = parser;
|
||||
this.parsingMode = parsingMode;
|
||||
|
||||
if (parser.DefaultHandler) {
|
||||
this.parserType = "htmlparser2";
|
||||
} else if (parser.Parser && parser.TreeAdapters) {
|
||||
this.parserType = "parse5v1";
|
||||
} else if (parser.moduleName === "HTML5") {
|
||||
this.parserType = "html5";
|
||||
} else if (parser.parser) {
|
||||
this.parserType = "sax";
|
||||
}
|
||||
}
|
||||
|
||||
appendHtmlToElement(html, element) {
|
||||
if (typeof html !== "string") {
|
||||
html = String(html);
|
||||
}
|
||||
|
||||
return this["_parseWith" + this.parserType](html, true, element);
|
||||
}
|
||||
|
||||
appendHtmlToDocument(html, element) {
|
||||
if (typeof html !== "string") {
|
||||
html = String(html);
|
||||
}
|
||||
|
||||
return this["_parseWith" + this.parserType](html, false, element);
|
||||
}
|
||||
|
||||
_parseWithhtmlparser2(html, fragment, element) {
|
||||
const handler = new this.parser.DefaultHandler();
|
||||
// Check if document is XML
|
||||
const isXML = this.parsingMode === "xml";
|
||||
const parserInstance = new this.parser.Parser(handler, {
|
||||
xmlMode: isXML,
|
||||
lowerCaseTags: !isXML,
|
||||
lowerCaseAttributeNames: !isXML,
|
||||
decodeEntities: true
|
||||
});
|
||||
|
||||
parserInstance.includeLocation = false;
|
||||
parserInstance.parseComplete(html);
|
||||
|
||||
const parsed = handler.dom;
|
||||
for (let i = 0; i < parsed.length; i++) {
|
||||
setChild(this.core, element, parsed[i]);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
_parseWithparse5v1(html, fragment, element) {
|
||||
if (this.parsingMode === "xml") {
|
||||
throw new Error("Can't parse XML with parse5, please use htmlparser2 instead.");
|
||||
}
|
||||
|
||||
const htmlparser2Adapter = this.parser.TreeAdapters.htmlparser2;
|
||||
let dom;
|
||||
if (fragment) {
|
||||
const instance = new this.parser.Parser(htmlparser2Adapter);
|
||||
const parentElement = htmlparser2Adapter.createElement(element.tagName.toLowerCase(), element.namespaceURI, []);
|
||||
dom = instance.parseFragment(html, parentElement);
|
||||
} else {
|
||||
const instance = new this.parser.Parser(htmlparser2Adapter, { locationInfo: true });
|
||||
dom = instance.parse(html);
|
||||
}
|
||||
|
||||
const parsed = dom.children;
|
||||
for (let i = 0; i < parsed.length; i++) {
|
||||
setChild(this.core, element, parsed[i]);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
_parseWithhtml5(html, fragment, element) {
|
||||
if (element.nodeType === 9) {
|
||||
new this.parser.Parser({ document: element }).parse(html);
|
||||
} else {
|
||||
const p = new this.parser.Parser({ document: element.ownerDocument });
|
||||
p.parse_fragment(html, element);
|
||||
}
|
||||
}
|
||||
|
||||
_parseWithsax(html, fragment, element) {
|
||||
const SaxParser = this.parser.parser;
|
||||
const parser = new SaxParser(false, { xmlns: true });
|
||||
parser.looseCase = "toString";
|
||||
const openStack = [element];
|
||||
parser.ontext = text => {
|
||||
setChild(this.core, openStack[openStack.length - 1], {
|
||||
type: "text",
|
||||
data: text
|
||||
});
|
||||
};
|
||||
parser.onopentag = arg => {
|
||||
const attrValues = {};
|
||||
const attrPrefixes = {};
|
||||
const attrNamespaces = {};
|
||||
Object.keys(arg.attributes).forEach(key => {
|
||||
const localName = arg.attributes[key].local;
|
||||
attrValues[localName] = arg.attributes[key].value;
|
||||
attrPrefixes[localName] = arg.attributes[key].prefix || null;
|
||||
attrNamespaces[localName] = arg.attributes[key].uri || null;
|
||||
});
|
||||
|
||||
if (arg.local === "script" && arg.uri === "http://www.w3.org/1999/xhtml") {
|
||||
openStack.push({
|
||||
type: "tag",
|
||||
name: arg.local,
|
||||
prefix: arg.prefix,
|
||||
namespace: arg.uri,
|
||||
attribs: attrValues,
|
||||
"x-attribsPrefix": attrPrefixes,
|
||||
"x-attribsNamespace": attrNamespaces
|
||||
});
|
||||
} else {
|
||||
const elem = setChild(this.core, openStack[openStack.length - 1], {
|
||||
type: "tag",
|
||||
name: arg.local,
|
||||
prefix: arg.prefix,
|
||||
namespace: arg.uri,
|
||||
attribs: attrValues,
|
||||
"x-attribsPrefix": attrPrefixes,
|
||||
"x-attribsNamespace": attrNamespaces
|
||||
});
|
||||
openStack.push(elem);
|
||||
}
|
||||
};
|
||||
parser.onclosetag = () => {
|
||||
const elem = openStack.pop();
|
||||
if (elem.constructor.name === "Object") { // we have an empty script tag
|
||||
setChild(this.core, openStack[openStack.length - 1], elem);
|
||||
}
|
||||
};
|
||||
parser.onscript = scriptText => {
|
||||
const tag = openStack.pop();
|
||||
tag.children = [{ type: "text", data: scriptText }];
|
||||
const elem = setChild(this.core, openStack[openStack.length - 1], tag);
|
||||
openStack.push(elem);
|
||||
};
|
||||
parser.oncomment = comment => {
|
||||
setChild(this.core, openStack[openStack.length - 1], {
|
||||
type: "comment",
|
||||
data: comment
|
||||
});
|
||||
};
|
||||
parser.onprocessinginstruction = pi => {
|
||||
setChild(this.core, openStack[openStack.length - 1], {
|
||||
type: "directive",
|
||||
name: "?" + pi.name,
|
||||
data: "?" + pi.name + " " + pi.body + "?"
|
||||
});
|
||||
};
|
||||
parser.ondoctype = dt => {
|
||||
setChild(this.core, openStack[openStack.length - 1], {
|
||||
type: "directive",
|
||||
name: "!doctype",
|
||||
data: "!doctype " + dt
|
||||
});
|
||||
};
|
||||
parser.write(html).close();
|
||||
}
|
||||
}
|
||||
|
||||
// utility function for forgiving parser
|
||||
function setChild(core, parent, node) {
|
||||
const currentDocument = parent._ownerDocument || parent;
|
||||
|
||||
let newNode;
|
||||
let isTemplateContents = false;
|
||||
switch (node.type) {
|
||||
case "tag":
|
||||
case "script":
|
||||
case "style":
|
||||
newNode = currentDocument._createElementWithCorrectElementInterface(node.name, node.namespace);
|
||||
newNode._localName = node.name;
|
||||
newNode._prefix = node.prefix || null;
|
||||
newNode._namespaceURI = node.namespace || null;
|
||||
break;
|
||||
|
||||
case "root":
|
||||
// If we are in <template> then add all children to the parent's _templateContents; skip this virtual root node.
|
||||
if (parent.tagName === "TEMPLATE" && parent._namespaceURI === "http://www.w3.org/1999/xhtml") {
|
||||
newNode = parent._templateContents;
|
||||
isTemplateContents = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "text":
|
||||
// HTML entities should already be decoded by the parser, so no need to decode them
|
||||
newNode = currentDocument.createTextNode(node.data);
|
||||
break;
|
||||
|
||||
case "comment":
|
||||
newNode = currentDocument.createComment(node.data);
|
||||
break;
|
||||
|
||||
case "directive":
|
||||
if (node.name[0] === "?" && node.name.toLowerCase() !== "?xml") {
|
||||
const data = node.data.slice(node.name.length + 1, -1);
|
||||
newNode = currentDocument.createProcessingInstruction(node.name.substring(1), data);
|
||||
} else if (node.name.toLowerCase() === "!doctype") {
|
||||
if (node["x-name"] !== undefined) { // parse5 supports doctypes directly
|
||||
newNode = createDocumentTypeInternal(core, currentDocument,
|
||||
node["x-name"] || "",
|
||||
node["x-publicId"] || "",
|
||||
node["x-systemId"] || "");
|
||||
} else {
|
||||
newNode = parseDocType(core, currentDocument, "<" + node.data + ">");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!newNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
newNode[locationInfo] = node.__location;
|
||||
|
||||
if (node.attribs) {
|
||||
for (let localName in node.attribs) {
|
||||
const value = node.attribs[localName];
|
||||
let prefix = node["x-attribsPrefix"] && node["x-attribsPrefix"][localName] || null;
|
||||
const namespace = node["x-attribsNamespace"] && node["x-attribsNamespace"][localName] || null;
|
||||
if (prefix === "xmlns" && localName === "") {
|
||||
// intended weirdness in node-sax, see https://github.com/isaacs/sax-js/issues/165
|
||||
localName = prefix;
|
||||
prefix = null;
|
||||
}
|
||||
attributes.setAttributeValue(newNode, localName, value, prefix, namespace);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.children) {
|
||||
for (let c = 0; c < node.children.length; c++) {
|
||||
setChild(core, newNode, node.children[c]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTemplateContents) {
|
||||
if (parent._templateContents) {
|
||||
// Setting innerHTML on a <template>
|
||||
parent._templateContents.appendChild(newNode);
|
||||
} else {
|
||||
parent.appendChild(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
return newNode;
|
||||
}
|
||||
|
||||
const HTML5_DOCTYPE = /<!doctype html>/i;
|
||||
const PUBLIC_DOCTYPE = /<!doctype\s+([^\s]+)\s+public\s+"([^"]+)"\s+"([^"]+)"/i;
|
||||
const SYSTEM_DOCTYPE = /<!doctype\s+([^\s]+)\s+system\s+"([^"]+)"/i;
|
||||
|
||||
function parseDocType(core, doc, html) {
|
||||
if (HTML5_DOCTYPE.test(html)) {
|
||||
return createDocumentTypeInternal(core, doc, "html", "", "");
|
||||
}
|
||||
|
||||
const publicPieces = PUBLIC_DOCTYPE.exec(html);
|
||||
if (publicPieces) {
|
||||
return createDocumentTypeInternal(core, doc, publicPieces[1], publicPieces[2], publicPieces[3]);
|
||||
}
|
||||
|
||||
const systemPieces = SYSTEM_DOCTYPE.exec(html);
|
||||
if (systemPieces) {
|
||||
return createDocumentTypeInternal(core, doc, systemPieces[1], "", systemPieces[2]);
|
||||
}
|
||||
|
||||
// Shouldn't get here (the parser shouldn't let us know about invalid doctypes), but our logic likely isn't
|
||||
// real-world perfect, so let's fallback.
|
||||
return createDocumentTypeInternal(core, doc, "html", "", "");
|
||||
}
|
||||
|
||||
|
||||
exports.HtmlToDom = HtmlToDom;
|
||||
67
node_modules/jsdom/lib/jsdom/browser/location.js
generated
vendored
Normal file
67
node_modules/jsdom/lib/jsdom/browser/location.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
const whatwgURL = require("whatwg-url-compat");
|
||||
const documentBaseURL = require("../living/helpers/document-base-url").documentBaseURL;
|
||||
const notImplemented = require("./not-implemented");
|
||||
const URL = whatwgURL.createURLConstructor();
|
||||
|
||||
module.exports = Location;
|
||||
|
||||
const document = Symbol("relevant document");
|
||||
const oldParsedURL = Symbol("old parsed URL");
|
||||
|
||||
function Location(urlString, relevantDocument) {
|
||||
this[document] = relevantDocument;
|
||||
whatwgURL.setTheInput(this, urlString);
|
||||
|
||||
try {
|
||||
this[oldParsedURL] = new URL(urlString);
|
||||
} catch (e) {
|
||||
this[oldParsedURL] = {};
|
||||
}
|
||||
}
|
||||
|
||||
whatwgURL.mixinURLUtils(
|
||||
Location.prototype,
|
||||
function getTheBase() {
|
||||
return documentBaseURL(this[document]);
|
||||
},
|
||||
function updateSteps() {
|
||||
if (this[oldParsedURL].protocol !== this.protocol ||
|
||||
this[oldParsedURL].username !== this.username ||
|
||||
this[oldParsedURL].password !== this.password ||
|
||||
this[oldParsedURL].hostname !== this.hostname ||
|
||||
this[oldParsedURL].port !== this.port ||
|
||||
this[oldParsedURL].pathname !== this.pathname ||
|
||||
this[oldParsedURL].search !== this.search) {
|
||||
notImplemented("navigation via the location interface", this[document]._defaultView);
|
||||
} else if (this[oldParsedURL].hash !== this.hash) {
|
||||
const window = this[document].defaultView;
|
||||
const ev = new window.HashChangeEvent("hashchange", {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
oldURL: this[oldParsedURL].href,
|
||||
newURL: this.href
|
||||
});
|
||||
|
||||
window.setTimeout(() => {
|
||||
window.dispatchEvent(ev);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
this[oldParsedURL] = new URL(this.href);
|
||||
this[document]._URL = this.href;
|
||||
}
|
||||
);
|
||||
|
||||
Location.prototype.assign = function () {
|
||||
notImplemented("location.assign", this[document]._defaultView);
|
||||
};
|
||||
|
||||
Location.prototype.replace = function (url) {
|
||||
// This is nowhere near spec compliant, but has worked so far.
|
||||
whatwgURL.setTheInput(this, url);
|
||||
};
|
||||
|
||||
Location.prototype.reload = function () {
|
||||
notImplemented("location.reload", this[document]._defaultView);
|
||||
};
|
||||
10
node_modules/jsdom/lib/jsdom/browser/not-implemented.js
generated
vendored
Normal file
10
node_modules/jsdom/lib/jsdom/browser/not-implemented.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function (nameForErrorMessage, window) {
|
||||
if (!window) {
|
||||
// Do nothing for window-less documents.
|
||||
return;
|
||||
}
|
||||
|
||||
window._virtualConsole.emit("jsdomError", new Error(`Not implemented: ${nameForErrorMessage}`));
|
||||
};
|
||||
220
node_modules/jsdom/lib/jsdom/browser/resource-loader.js
generated
vendored
Normal file
220
node_modules/jsdom/lib/jsdom/browser/resource-loader.js
generated
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
"use strict";
|
||||
|
||||
const resolveHref = require("../utils").resolveHref;
|
||||
const parseDataUrl = require("../utils").parseDataUrl;
|
||||
const fs = require("fs");
|
||||
const request = require("request");
|
||||
const documentBaseURL = require("../living/helpers/document-base-url").documentBaseURL;
|
||||
const internalConstants = require("../living/helpers/internal-constants");
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
/* eslint-disable no-restricted-modules */
|
||||
// TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package
|
||||
// This legacy usage is in the process of being purged.
|
||||
const URL = require("url");
|
||||
/* eslint-enable no-restricted-modules */
|
||||
|
||||
const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]";
|
||||
|
||||
function createResourceLoadHandler(element, resourceUrl, document, loadCallback) {
|
||||
return function (err, data) {
|
||||
const ev = document.createEvent("HTMLEvents");
|
||||
|
||||
if (!err) {
|
||||
try {
|
||||
loadCallback.call(element, data, resourceUrl);
|
||||
ev.initEvent("load", false, false);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
ev.initEvent("error", false, false);
|
||||
ev.error = err;
|
||||
|
||||
const error = new Error(`Could not load ${element.localName}: "${resourceUrl}"`);
|
||||
error.detail = err;
|
||||
document._defaultView._virtualConsole.emit("jsdomError", error);
|
||||
}
|
||||
|
||||
element.dispatchEvent(ev);
|
||||
};
|
||||
}
|
||||
|
||||
exports.readFile = function (filePath, callback) {
|
||||
const readableStream = fs.createReadStream(filePath, { encoding: "utf8" });
|
||||
|
||||
let data = "";
|
||||
|
||||
readableStream.on("error", callback);
|
||||
|
||||
readableStream.on("data", chunk => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
readableStream.on("end", () => {
|
||||
callback(null, data);
|
||||
});
|
||||
|
||||
return {
|
||||
abort() {
|
||||
readableStream.destroy();
|
||||
callback(new Error("request canceled by user"));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// NOTE: request wraps tough-cookie cookie jar
|
||||
// (see: https://github.com/request/request/blob/master/lib/cookies.js).
|
||||
// Therefore, to pass our cookie jar to the request, we need to create
|
||||
// request's wrapper and monkey patch it with our jar.
|
||||
function wrapCookieJarForRequest(cookieJar) {
|
||||
const jarWrapper = request.jar();
|
||||
jarWrapper._jar = cookieJar;
|
||||
return jarWrapper;
|
||||
}
|
||||
|
||||
function fetch(element, urlObj, cookieJar, referrer, pool, agentOptions, userAgent, callback) {
|
||||
let req = null;
|
||||
if (urlObj.protocol === "data:") {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
const buffer = parseDataUrl(urlObj.href).buffer;
|
||||
callback(null, buffer.toString());
|
||||
} catch (err) {
|
||||
callback(err, null);
|
||||
}
|
||||
});
|
||||
} else if (urlObj.hostname) {
|
||||
const requestOptions = {
|
||||
pool,
|
||||
agentOptions,
|
||||
headers: {
|
||||
"User-Agent": userAgent
|
||||
}
|
||||
};
|
||||
if (element[internalConstants.accept]) {
|
||||
requestOptions.headers.Accept = element[internalConstants.accept];
|
||||
}
|
||||
req = exports.download(urlObj, requestOptions, cookieJar, referrer, callback);
|
||||
} else {
|
||||
const filePath = urlObj.pathname
|
||||
.replace(/^file:\/\//, "")
|
||||
.replace(/^\/([a-z]):\//i, "$1:/")
|
||||
.replace(/%20/g, " ");
|
||||
req = exports.readFile(filePath, callback);
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
exports.enqueue = function (element, resourceUrl, callback) {
|
||||
const document = element.nodeType === NODE_TYPE.DOCUMENT_NODE ? element : element._ownerDocument;
|
||||
|
||||
if (document._queue) {
|
||||
const loadHandler = createResourceLoadHandler(element, resourceUrl || document.URL, document, callback);
|
||||
return document._queue.push(loadHandler);
|
||||
}
|
||||
|
||||
return function () { };
|
||||
};
|
||||
|
||||
exports.resolveResourceUrl = function (document, url) {
|
||||
// if getAttribute returns null, there is no href
|
||||
// lets resolve to an empty string (nulls are not expected farther up)
|
||||
if (url === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const baseUrl = documentBaseURL(document);
|
||||
return resolveHref(baseUrl, url);
|
||||
};
|
||||
|
||||
|
||||
function objGetter(obj, prop) {
|
||||
const lprop = prop.toLowerCase();
|
||||
for (const p in obj) {
|
||||
if (obj.hasOwnProperty(p) && lprop === p.toLowerCase()) {
|
||||
return obj[p];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
exports.download = function (url, options, cookieJar, referrer, callback) {
|
||||
options = options || {};
|
||||
options.gzip = true;
|
||||
options.jar = wrapCookieJarForRequest(cookieJar);
|
||||
options.headers = options.headers || {};
|
||||
if (referrer && !IS_BROWSER) {
|
||||
options.headers.referer = referrer;
|
||||
}
|
||||
if (!objGetter(options.headers, "Accept")) {
|
||||
options.headers.Accept = "*/*";
|
||||
}
|
||||
if (!objGetter(options.headers, "Accept-Language")) {
|
||||
options.headers["Accept-Language"] = "en";
|
||||
}
|
||||
|
||||
const req = request(url, options, (error, response, data) => callback(error, data, response));
|
||||
return {
|
||||
abort() {
|
||||
req.abort();
|
||||
callback(new Error("request canceled by user"));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.load = function (element, url, callback) {
|
||||
const document = element._ownerDocument;
|
||||
const documentImpl = document.implementation;
|
||||
|
||||
if (!documentImpl._hasFeature("FetchExternalResources", element.tagName.toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if getAttribute returns null, there is no href
|
||||
// lets resolve to an empty string (nulls are not expected farther up)
|
||||
const resourceUrl = exports.resolveResourceUrl(document, url);
|
||||
|
||||
if (documentImpl._hasFeature("SkipExternalResources", resourceUrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const urlObj = URL.parse(resourceUrl);
|
||||
const baseUrl = documentBaseURL(document);
|
||||
const cookieJar = document._cookieJar;
|
||||
const enqueued = exports.enqueue(element, resourceUrl, callback);
|
||||
const customLoader = document._customResourceLoader;
|
||||
const requestManager = document[internalConstants.requestManager];
|
||||
const pool = document[internalConstants.pool];
|
||||
const agentOptions = document[internalConstants.agentOptions];
|
||||
const userAgent = document._defaultView.navigator.userAgent;
|
||||
let req = null;
|
||||
function wrappedEnqueued() {
|
||||
if (req && requestManager) {
|
||||
requestManager.remove(req);
|
||||
}
|
||||
// do not trigger if the window is closed
|
||||
if (element._ownerDocument && element._ownerDocument.defaultView.document) {
|
||||
enqueued.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
if (typeof customLoader === "function") {
|
||||
req = customLoader({
|
||||
element,
|
||||
url: urlObj,
|
||||
cookie: cookieJar.getCookieStringSync(urlObj, { http: true }),
|
||||
baseUrl,
|
||||
defaultFetch(fetchCallback) {
|
||||
return fetch(element, urlObj, cookieJar, baseUrl, pool, agentOptions, userAgent, fetchCallback);
|
||||
}
|
||||
},
|
||||
wrappedEnqueued);
|
||||
} else {
|
||||
req = fetch(element, urlObj, cookieJar, baseUrl, pool, agentOptions, userAgent, wrappedEnqueued);
|
||||
}
|
||||
if (req && requestManager) {
|
||||
requestManager.add(req);
|
||||
}
|
||||
};
|
||||
988
node_modules/jsdom/lib/jsdom/level1/core.js
generated
vendored
Normal file
988
node_modules/jsdom/lib/jsdom/level1/core.js
generated
vendored
Normal file
@@ -0,0 +1,988 @@
|
||||
"use strict";
|
||||
/*
|
||||
ServerJS Javascript DOM Level 1
|
||||
*/
|
||||
var inheritFrom = require("../utils").inheritFrom;
|
||||
var domToHtml = require("../browser/domtohtml").domToHtml;
|
||||
var defineGetter = require("../utils").defineGetter;
|
||||
var memoizeQuery = require("../utils").memoizeQuery;
|
||||
var validateName = require('../living/helpers/validate-names').name;
|
||||
var HtmlToDom = require("../browser/htmltodom").HtmlToDom;
|
||||
var Location = require("../browser/location");
|
||||
var vm = require("vm");
|
||||
var CookieJar = require('tough-cookie').CookieJar;
|
||||
var EventTarget = require("../living/generated/EventTarget");
|
||||
var attributes = require("../living/attributes");
|
||||
var mapper = require("../utils").mapper;
|
||||
var clone = require("../living/node").clone;
|
||||
var namedPropertiesWindow = require("../living/named-properties-window");
|
||||
var Window = require('../browser/Window');
|
||||
var proxiedWindowEventHandlers = require("../living/helpers/proxied-window-event-handlers");
|
||||
const URL = require("../utils").URL;
|
||||
const domSymbolTree = require("../living/helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
const resetDOMTokenList = require("../living/dom-token-list").reset;
|
||||
const createLiveNodeList = require("../living/node-list").createLive;
|
||||
const updateNodeList = require("../living/node-list").update;
|
||||
const updateHTMLCollection = require("../living/html-collection").update;
|
||||
|
||||
// utility functions
|
||||
var attachId = function(id,elm,doc) {
|
||||
if (id && elm && doc) {
|
||||
if (!doc._ids[id]) {
|
||||
doc._ids[id] = [];
|
||||
}
|
||||
doc._ids[id].push(elm);
|
||||
}
|
||||
};
|
||||
var detachId = function(id,elm,doc) {
|
||||
var elms, i;
|
||||
if (id && elm && doc) {
|
||||
if (doc._ids && doc._ids[id]) {
|
||||
elms = doc._ids[id];
|
||||
for (i=0;i<elms.length;i++) {
|
||||
if (elms[i] === elm) {
|
||||
elms.splice(i,1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (elms.length === 0) {
|
||||
delete doc._ids[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function setInnerHTML(document, node, html) {
|
||||
// Clear the children first:
|
||||
if (node._templateContents) {
|
||||
clearChildNodes(node._templateContents);
|
||||
} else {
|
||||
clearChildNodes(node);
|
||||
}
|
||||
|
||||
if (html !== "") {
|
||||
if (node.nodeName === "#document") {
|
||||
document._htmlToDom.appendHtmlToDocument(html, node);
|
||||
} else {
|
||||
document._htmlToDom.appendHtmlToElement(html, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearChildNodes(node) {
|
||||
for (let child = null; child = domSymbolTree.firstChild(node);) {
|
||||
node.removeChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
var core = exports;
|
||||
|
||||
core.DOMException = require("../web-idl/DOMException");
|
||||
core.NamedNodeMap = require("../living/attributes").NamedNodeMap;
|
||||
|
||||
core.DOMImplementation = function DOMImplementation(document, /* Object */ features) {
|
||||
throw new TypeError("Illegal constructor");
|
||||
};
|
||||
|
||||
core.DOMImplementation.prototype = {
|
||||
// All of these are legacy, left because jsdom uses them internally :(. jsdom confused the idea of browser features
|
||||
// and jsdom features
|
||||
_removeFeature : function(feature, version) {
|
||||
feature = feature.toLowerCase();
|
||||
if (this._features[feature]) {
|
||||
if (version) {
|
||||
var j = 0,
|
||||
versions = this._features[feature],
|
||||
l = versions.length;
|
||||
|
||||
for (j; j<l; j++) {
|
||||
if (versions[j] === version) {
|
||||
versions.splice(j,1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
delete this._features[feature];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_addFeature: function(feature, version) {
|
||||
feature = feature.toLowerCase();
|
||||
|
||||
if (version) {
|
||||
|
||||
if (!this._features[feature]) {
|
||||
this._features[feature] = [];
|
||||
}
|
||||
|
||||
if (version instanceof Array) {
|
||||
Array.prototype.push.apply(this._features[feature], version);
|
||||
} else {
|
||||
this._features[feature].push(version);
|
||||
}
|
||||
|
||||
if (feature === "processexternalresources" &&
|
||||
(version === "script" || (version.indexOf && version.indexOf("script") !== -1)) &&
|
||||
!vm.isContext(this._ownerDocument._global)) {
|
||||
vm.createContext(this._ownerDocument._global);
|
||||
this._ownerDocument._defaultView._globalProxy = vm.runInContext("this", this._ownerDocument._global);
|
||||
this._ownerDocument._defaultView = this._ownerDocument._defaultView._globalProxy;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// The real hasFeature is in living/dom-implementation.js, and returns true always.
|
||||
// This one is used internally
|
||||
_hasFeature: function(/* string */ feature, /* string */ version) {
|
||||
feature = (feature) ? feature.toLowerCase() : '';
|
||||
var versions = (this._features[feature]) ?
|
||||
this._features[feature] :
|
||||
false;
|
||||
|
||||
if (!version && versions.length && versions.length > 0) {
|
||||
return true;
|
||||
} else if (typeof versions === 'string') {
|
||||
return versions === version;
|
||||
} else if (versions.indexOf && versions.length > 0) {
|
||||
for (var i = 0; i < versions.length; i++) {
|
||||
var found = versions[i] instanceof RegExp ?
|
||||
versions[i].test(version) :
|
||||
versions[i] === version;
|
||||
if (found) { return true; }
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
core.Node = function Node(ownerDocument) {
|
||||
EventTarget.setup(this);
|
||||
|
||||
domSymbolTree.initialize(this);
|
||||
this._childNodesList = null;
|
||||
this._ownerDocument = ownerDocument;
|
||||
this._childrenList = null;
|
||||
this._version = 0;
|
||||
this._memoizedQueries = {};
|
||||
this._readonly = false;
|
||||
};
|
||||
|
||||
core.Node.ELEMENT_NODE = NODE_TYPE.ELEMENT_NODE;
|
||||
core.Node.ATTRIBUTE_NODE = NODE_TYPE.ATTRIBUTE_NODE;
|
||||
core.Node.TEXT_NODE = NODE_TYPE.TEXT_NODE;
|
||||
core.Node.CDATA_SECTION_NODE = NODE_TYPE.CDATA_SECTION_NODE;
|
||||
core.Node.ENTITY_REFERENCE_NODE = NODE_TYPE.ENTITY_REFERENCE_NODE;
|
||||
core.Node.ENTITY_NODE = NODE_TYPE.ENTITY_NODE;
|
||||
core.Node.PROCESSING_INSTRUCTION_NODE = NODE_TYPE.PROCESSING_INSTRUCTION_NODE;
|
||||
core.Node.COMMENT_NODE = NODE_TYPE.COMMENT_NODE;
|
||||
core.Node.DOCUMENT_NODE = NODE_TYPE.DOCUMENT_NODE;
|
||||
core.Node.DOCUMENT_TYPE_NODE = NODE_TYPE.DOCUMENT_TYPE_NODE;
|
||||
core.Node.DOCUMENT_FRAGMENT_NODE = NODE_TYPE.DOCUMENT_FRAGMENT_NODE;
|
||||
core.Node.NOTATION_NODE = NODE_TYPE.NOTATION_NODE;
|
||||
|
||||
core.Node.prototype = {
|
||||
ELEMENT_NODE : NODE_TYPE.ELEMENT_NODE,
|
||||
ATTRIBUTE_NODE : NODE_TYPE.ATTRIBUTE_NODE,
|
||||
TEXT_NODE : NODE_TYPE.TEXT_NODE,
|
||||
CDATA_SECTION_NODE : NODE_TYPE.CDATA_SECTION_NODE,
|
||||
ENTITY_REFERENCE_NODE : NODE_TYPE.ENTITY_REFERENCE_NODE,
|
||||
ENTITY_NODE : NODE_TYPE.ENTITY_NODE,
|
||||
PROCESSING_INSTRUCTION_NODE : NODE_TYPE.PROCESSING_INSTRUCTION_NODE,
|
||||
COMMENT_NODE : NODE_TYPE.COMMENT_NODE,
|
||||
DOCUMENT_NODE : NODE_TYPE.DOCUMENT_NODE,
|
||||
DOCUMENT_TYPE_NODE : NODE_TYPE.DOCUMENT_TYPE_NODE,
|
||||
DOCUMENT_FRAGMENT_NODE : NODE_TYPE.DOCUMENT_FRAGMENT_NODE,
|
||||
NOTATION_NODE : NODE_TYPE.NOTATION_NODE,
|
||||
|
||||
get nodeValue() {
|
||||
if (this.nodeType === NODE_TYPE.TEXT_NODE ||
|
||||
this.nodeType === NODE_TYPE.COMMENT_NODE ||
|
||||
this.nodeType === NODE_TYPE.PROCESSING_INSTRUCTION_NODE) {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
set nodeValue(value) {
|
||||
if (this.nodeType === NODE_TYPE.TEXT_NODE ||
|
||||
this.nodeType === NODE_TYPE.COMMENT_NODE ||
|
||||
this.nodeType === NODE_TYPE.PROCESSING_INSTRUCTION_NODE) {
|
||||
this.replaceData(0, this.length, value);
|
||||
}
|
||||
},
|
||||
get parentNode() {
|
||||
return domSymbolTree.parent(this);
|
||||
},
|
||||
|
||||
get nodeName() {
|
||||
switch (this.nodeType) {
|
||||
case NODE_TYPE.ELEMENT_NODE:
|
||||
return this.tagName;
|
||||
case NODE_TYPE.TEXT_NODE:
|
||||
return "#text";
|
||||
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
|
||||
return this.target;
|
||||
case NODE_TYPE.COMMENT_NODE:
|
||||
return "#comment";
|
||||
case NODE_TYPE.DOCUMENT_NODE:
|
||||
return "#document";
|
||||
case NODE_TYPE.DOCUMENT_TYPE_NODE:
|
||||
return this.name;
|
||||
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
|
||||
return "#document-fragment";
|
||||
}
|
||||
},
|
||||
set nodeName(unused) { throw new core.DOMException();},
|
||||
get firstChild() {
|
||||
return domSymbolTree.firstChild(this);
|
||||
},
|
||||
get ownerDocument() {
|
||||
// TODO: when we move nodeType to Node.prototype and add an internal _nodeType, consult that instead.
|
||||
return this.nodeType === NODE_TYPE.DOCUMENT_NODE ? null : this._ownerDocument;
|
||||
},
|
||||
get readonly() { return this._readonly;},
|
||||
|
||||
get lastChild() {
|
||||
return domSymbolTree.lastChild(this);
|
||||
},
|
||||
|
||||
get childNodes() {
|
||||
if (!this._childNodesList) {
|
||||
var self = this;
|
||||
this._childNodesList = createLiveNodeList(this, function() {
|
||||
return domSymbolTree.childrenToArray(self);
|
||||
});
|
||||
} else {
|
||||
updateNodeList(this._childNodesList);
|
||||
}
|
||||
|
||||
return this._childNodesList;
|
||||
},
|
||||
set childNodes(unused) { throw new core.DOMException();},
|
||||
|
||||
get nextSibling() {
|
||||
return domSymbolTree.nextSibling(this);
|
||||
},
|
||||
set nextSibling(unused) { throw new core.DOMException();},
|
||||
|
||||
get previousSibling() {
|
||||
return domSymbolTree.previousSibling(this);
|
||||
},
|
||||
set previousSibling(unused) { throw new core.DOMException();},
|
||||
|
||||
/* returns Node */
|
||||
insertBefore : function(/* Node */ newChild, /* Node*/ refChild) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Node.prototype.insertBefore");
|
||||
}
|
||||
if (refChild === undefined) {
|
||||
refChild = null;
|
||||
}
|
||||
|
||||
// TODO branding
|
||||
if (!newChild || !("nodeType" in newChild)) {
|
||||
throw new TypeError("First argument to Node.prototype.insertBefore must be a Node");
|
||||
}
|
||||
if (refChild !== null && !("nodeType" in refChild)) {
|
||||
throw new TypeError("Second argument to Node.prototype.insertBefore must be a Node or null or undefined");
|
||||
}
|
||||
|
||||
if (this._readonly === true) {
|
||||
throw new core.DOMException(core.DOMException.NO_MODIFICATION_ALLOWED_ERR, 'Attempting to modify a read-only node');
|
||||
}
|
||||
|
||||
// DocumentType must be implicitly adopted
|
||||
if (newChild.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE) newChild._ownerDocument = this._ownerDocument;
|
||||
|
||||
// TODO - if (!newChild) then?
|
||||
if (!(this instanceof core.Document) && newChild._ownerDocument !== this._ownerDocument) {
|
||||
throw new core.DOMException(core.DOMException.WRONG_DOCUMENT_ERR);
|
||||
}
|
||||
|
||||
if (newChild.nodeType && newChild.nodeType === NODE_TYPE.ATTRIBUTE_NODE) {
|
||||
throw new core.DOMException(core.DOMException.HIERARCHY_REQUEST_ERR);
|
||||
}
|
||||
|
||||
// search for parents matching the newChild
|
||||
for (const ancestor of domSymbolTree.ancestorsIterator(this)) {
|
||||
if (ancestor === newChild) {
|
||||
throw new core.DOMException(core.DOMException.HIERARCHY_REQUEST_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// fragments are merged into the element (except parser-created fragments in <template>)
|
||||
if (newChild.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE) {
|
||||
|
||||
let grandChild;
|
||||
while ((grandChild = domSymbolTree.firstChild(newChild))) {
|
||||
newChild.removeChild(grandChild);
|
||||
this.insertBefore(grandChild, refChild);
|
||||
}
|
||||
|
||||
} else if (newChild === refChild) {
|
||||
return newChild;
|
||||
} else {
|
||||
const oldParent = domSymbolTree.parent(newChild);
|
||||
// if the newChild is already in the tree elsewhere, remove it first
|
||||
if (oldParent) {
|
||||
oldParent.removeChild(newChild);
|
||||
}
|
||||
|
||||
if (refChild == null) {
|
||||
domSymbolTree.appendChild(this, newChild);
|
||||
} else {
|
||||
if (domSymbolTree.parent(refChild) !== this) {
|
||||
throw new core.DOMException(core.DOMException.NOT_FOUND_ERR);
|
||||
}
|
||||
|
||||
domSymbolTree.insertBefore(refChild, newChild);
|
||||
}
|
||||
|
||||
this._modified();
|
||||
|
||||
if (this._attached && newChild._attach) {
|
||||
newChild._attach();
|
||||
}
|
||||
|
||||
this._descendantAdded(this, newChild);
|
||||
}
|
||||
|
||||
return newChild;
|
||||
}, // raises(DOMException);
|
||||
|
||||
_modified: function() {
|
||||
this._version++;
|
||||
if (this._ownerDocument) {
|
||||
this._ownerDocument._version++;
|
||||
}
|
||||
|
||||
if (this._childrenList) {
|
||||
updateHTMLCollection(this._childrenList);
|
||||
}
|
||||
if (this._childNodesList) {
|
||||
updateNodeList(this._childNodesList);
|
||||
}
|
||||
this._clearMemoizedQueries();
|
||||
},
|
||||
|
||||
_clearMemoizedQueries: function() {
|
||||
this._memoizedQueries = {};
|
||||
const myParent = domSymbolTree.parent(this);
|
||||
if (myParent) {
|
||||
myParent._clearMemoizedQueries();
|
||||
}
|
||||
},
|
||||
|
||||
_descendantRemoved: function(parent, child) {
|
||||
const myParent = domSymbolTree.parent(this);
|
||||
if (myParent) {
|
||||
myParent._descendantRemoved(parent, child);
|
||||
}
|
||||
},
|
||||
|
||||
_descendantAdded: function(parent, child) {
|
||||
const myParent = domSymbolTree.parent(this);
|
||||
if (myParent) {
|
||||
myParent._descendantAdded(parent, child);
|
||||
}
|
||||
},
|
||||
|
||||
_attrModified: function(name, value, oldValue) {
|
||||
this._modified();
|
||||
namedPropertiesWindow.elementAttributeModified(this, name, value, oldValue);
|
||||
|
||||
if (name == 'id' && this._attached) {
|
||||
var doc = this._ownerDocument;
|
||||
detachId(oldValue,this,doc);
|
||||
attachId(value,this,doc);
|
||||
}
|
||||
|
||||
// TODO event handlers:
|
||||
// The correct way to do this is lazy, and a bit more complicated; see
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-content-attributes
|
||||
// It would only be possible if we had proper getters/setters for every event handler, which we don't right now.
|
||||
if (name.length > 2 && name[0] === 'o' && name[1] === 'n') {
|
||||
if (value) {
|
||||
var w = this._ownerDocument._global;
|
||||
var self = proxiedWindowEventHandlers.has(name) && this._localName === 'body' ? w : this;
|
||||
var vmOptions = { filename: this._ownerDocument._URL, displayErrors: false };
|
||||
|
||||
// The handler code probably refers to functions declared globally on the window, so we need to run it in
|
||||
// that context. In fact, it's worse; see
|
||||
// https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/bindings/core/v8/V8LazyEventListener.cpp
|
||||
// plus the spec, which show how multiple nested scopes are technically required. We won't implement that
|
||||
// until someone asks for it, though.
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm
|
||||
|
||||
if (name === "onerror" && self === w) {
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler
|
||||
// step 10
|
||||
|
||||
self[name] = function (event, source, lineno, colno, error) {
|
||||
w.__tempEventHandlerThis = this;
|
||||
w.__tempEventHandlerEvent = event;
|
||||
w.__tempEventHandlerSource = source;
|
||||
w.__tempEventHandlerLineno = lineno;
|
||||
w.__tempEventHandlerColno = colno;
|
||||
w.__tempEventHandlerError = error;
|
||||
|
||||
try {
|
||||
return vm.runInContext(`
|
||||
(function (event, source, lineno, colno, error) {
|
||||
${value}
|
||||
}).call(__tempEventHandlerThis, __tempEventHandlerEvent, __tempEventHandlerSource,
|
||||
__tempEventHandlerLineno, __tempEventHandlerColno, __tempEventHandlerError)`, w, vmOptions);
|
||||
} finally {
|
||||
delete w.__tempEventHandlerThis;
|
||||
delete w.__tempEventHandlerEvent;
|
||||
delete w.__tempEventHandlerSource;
|
||||
delete w.__tempEventHandlerLineno;
|
||||
delete w.__tempEventHandlerColno;
|
||||
delete w.__tempEventHandlerError;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
self[name] = function (event) {
|
||||
w.__tempEventHandlerThis = this;
|
||||
w.__tempEventHandlerEvent = event;
|
||||
|
||||
try {
|
||||
return vm.runInContext(`
|
||||
(function (event) {
|
||||
${value}
|
||||
}).call(__tempEventHandlerThis, __tempEventHandlerEvent)`, w, vmOptions);
|
||||
} finally {
|
||||
delete w.__tempEventHandlerThis;
|
||||
delete w.__tempEventHandlerEvent;
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
this[name] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO remove MutationEvents completely at some point
|
||||
if (value !== oldValue && this._ownerDocument &&
|
||||
this._ownerDocument.implementation._hasFeature('MutationEvents')) {
|
||||
var ev = this._ownerDocument.createEvent("MutationEvents");
|
||||
|
||||
var attrChange = core.MutationEvent.MODIFICATION;
|
||||
if (value === null) {
|
||||
attrChange = core.MutationEvent.REMOVAL;
|
||||
}
|
||||
if (oldValue === null) {
|
||||
attrChange = core.MutationEvent.ADDITION;
|
||||
}
|
||||
|
||||
ev.initMutationEvent("DOMAttrModified", true, false, this, oldValue, value, name, attrChange);
|
||||
this.dispatchEvent(ev);
|
||||
}
|
||||
|
||||
// update classList
|
||||
if (name === "class" && value !== this.classList.toString()) {
|
||||
resetDOMTokenList(this.classList, value);
|
||||
}
|
||||
},
|
||||
|
||||
replaceChild(node, child) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Node.prototype.replaceChild");
|
||||
}
|
||||
// TODO branding
|
||||
if (!node || !("nodeType" in node)) {
|
||||
throw new TypeError("First argument to Node.prototype.replaceChild must be a Node");
|
||||
}
|
||||
if (!child || !("nodeType" in child)) {
|
||||
throw new TypeError("Second argument to Node.prototype.replaceChild must be a Node");
|
||||
}
|
||||
|
||||
this.insertBefore(node, child);
|
||||
return this.removeChild(child);
|
||||
},
|
||||
|
||||
/* returns void */
|
||||
_attach : function() {
|
||||
this._attached = true;
|
||||
namedPropertiesWindow.nodeAttachedToDocument(this);
|
||||
|
||||
if (this.id) {
|
||||
attachId(this.id,this,this._ownerDocument);
|
||||
}
|
||||
|
||||
for (const child of domSymbolTree.childrenIterator(this)) {
|
||||
if (child._attach) {
|
||||
child._attach();
|
||||
}
|
||||
}
|
||||
},
|
||||
/* returns void */
|
||||
_detach : function() {
|
||||
this._attached = false;
|
||||
|
||||
namedPropertiesWindow.nodeDetachedFromDocument(this);
|
||||
|
||||
if (this.id) {
|
||||
detachId(this.id,this,this._ownerDocument);
|
||||
}
|
||||
|
||||
for (const child of domSymbolTree.childrenIterator(this)) {
|
||||
if (child._detach) {
|
||||
child._detach();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* returns Node */
|
||||
removeChild : function(/* Node */ oldChild){
|
||||
if (this._readonly === true) {
|
||||
throw new core.DOMException(core.DOMException.NO_MODIFICATION_ALLOWED_ERR);
|
||||
}
|
||||
|
||||
if (!oldChild || domSymbolTree.parent(oldChild) !== this) {
|
||||
throw new core.DOMException(core.DOMException.NOT_FOUND_ERR);
|
||||
}
|
||||
|
||||
var oldPreviousSibling = oldChild.previousSibling;
|
||||
domSymbolTree.remove(oldChild);
|
||||
this._modified();
|
||||
oldChild._detach();
|
||||
this._descendantRemoved(this, oldChild);
|
||||
if (this._ownerDocument) {
|
||||
this._ownerDocument._runRemovingSteps(oldChild, this, oldPreviousSibling);
|
||||
}
|
||||
return oldChild;
|
||||
}, // raises(DOMException);
|
||||
|
||||
/* returns Node */
|
||||
appendChild : function(/* Node */ newChild) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Node.prototype.appendChild");
|
||||
}
|
||||
// TODO branding
|
||||
if (!("nodeType" in newChild)) {
|
||||
throw new TypeError("First argument to Node.prototype.appendChild must be a Node");
|
||||
}
|
||||
|
||||
return this.insertBefore(newChild, null);
|
||||
}, // raises(DOMException);
|
||||
|
||||
/* returns boolean */
|
||||
hasChildNodes : function() {
|
||||
return domSymbolTree.hasChildren(this);
|
||||
},
|
||||
|
||||
/* returns void */
|
||||
normalize: function() {
|
||||
for (const child of domSymbolTree.childrenIterator(this)) {
|
||||
if (child.normalize) {
|
||||
child.normalize();
|
||||
}
|
||||
|
||||
// Level2/core clean off empty nodes
|
||||
if (child.nodeValue === "") {
|
||||
this.removeChild(child);
|
||||
continue;
|
||||
}
|
||||
|
||||
const prevChild = domSymbolTree.previousSibling(child);
|
||||
|
||||
if (prevChild &&
|
||||
prevChild.nodeType === NODE_TYPE.TEXT_NODE &&
|
||||
child.nodeType === NODE_TYPE.TEXT_NODE) {
|
||||
// merge text nodes
|
||||
prevChild.appendData(child.nodeValue);
|
||||
this.removeChild(child);
|
||||
}
|
||||
}
|
||||
},
|
||||
toString: function() {
|
||||
var id = '';
|
||||
if (this.id) {
|
||||
id = '#' + this.id;
|
||||
}
|
||||
if (this.className) {
|
||||
var classes = this.className.split(/\s+/);
|
||||
for (var i = 0, len = classes.length; i < len; i++) {
|
||||
id += '.' + classes[i];
|
||||
}
|
||||
}
|
||||
return '[ ' + this.tagName + id + ' ]';
|
||||
}
|
||||
};
|
||||
|
||||
core.Element = function Element(document, localName) {
|
||||
core.Node.call(this, document);
|
||||
this._namespaceURI = null;
|
||||
this._prefix = null;
|
||||
this._localName = localName;
|
||||
this._attributes = attributes.createNamedNodeMap(this);
|
||||
};
|
||||
|
||||
inheritFrom(core.Node, core.Element, {
|
||||
get namespaceURI() {
|
||||
return this._namespaceURI;
|
||||
},
|
||||
get prefix() {
|
||||
return this._prefix;
|
||||
},
|
||||
get localName() {
|
||||
return this._localName;
|
||||
},
|
||||
get tagName() {
|
||||
var qualifiedName = this._prefix !== null ? this._prefix + ":" + this._localName : this._localName;
|
||||
if (this.namespaceURI === "http://www.w3.org/1999/xhtml" && this._ownerDocument._parsingMode === "html") {
|
||||
qualifiedName = qualifiedName.toUpperCase();
|
||||
}
|
||||
return qualifiedName;
|
||||
},
|
||||
|
||||
get id() {
|
||||
var idAttr = this.getAttribute("id");
|
||||
if (idAttr === null) {
|
||||
return "";
|
||||
}
|
||||
return idAttr;
|
||||
},
|
||||
|
||||
nodeType : NODE_TYPE.ELEMENT_NODE,
|
||||
get attributes() {
|
||||
return this._attributes;
|
||||
},
|
||||
|
||||
get sourceIndex() {
|
||||
/*
|
||||
* According to QuirksMode:
|
||||
* Get the sourceIndex of element x. This is also the index number for
|
||||
* the element in the document.getElementsByTagName('*') array.
|
||||
* http://www.quirksmode.org/dom/w3c_core.html#t77
|
||||
*/
|
||||
var items = this.ownerDocument.getElementsByTagName('*'),
|
||||
len = items.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (items[i] === this) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get outerHTML() {
|
||||
return domToHtml([this]);
|
||||
},
|
||||
|
||||
set outerHTML(html) {
|
||||
if (html === null) {
|
||||
html = "";
|
||||
}
|
||||
|
||||
var parent = domSymbolTree.parent(this);
|
||||
var document = this._ownerDocument;
|
||||
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
var contextElement;
|
||||
if (parent.nodeType === NODE_TYPE.DOCUMENT_NODE) {
|
||||
throw new core.DOMException(core.DOMException.NO_MODIFICATION_ALLOWED_ERR,
|
||||
"Modifications are not allowed for this document");
|
||||
} else if (parent.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE) {
|
||||
contextElement = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
|
||||
} else if (parent.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
contextElement = clone(core, parent, undefined, false);
|
||||
} else {
|
||||
throw new TypeError("This should never happen");
|
||||
}
|
||||
|
||||
document._htmlToDom.appendHtmlToElement(html, contextElement);
|
||||
|
||||
while (contextElement.firstChild) {
|
||||
parent.insertBefore(contextElement.firstChild, this);
|
||||
}
|
||||
|
||||
parent.removeChild(this);
|
||||
},
|
||||
|
||||
get innerHTML() {
|
||||
var tagName = this.tagName;
|
||||
if (tagName === 'SCRIPT' || tagName === 'STYLE') {
|
||||
var type = this.getAttribute('type');
|
||||
if (!type || /^text\//i.test(type) || /\/javascript$/i.test(type)) {
|
||||
return domToHtml(domSymbolTree.childrenIterator(this));
|
||||
}
|
||||
}
|
||||
|
||||
// In case of <template> we should pass its "template contents" fragment as a serialization root if we have one
|
||||
if (this._templateContents) {
|
||||
return domToHtml(domSymbolTree.childrenIterator(this._templateContents));
|
||||
}
|
||||
|
||||
return domToHtml(domSymbolTree.childrenIterator(this));
|
||||
},
|
||||
|
||||
set innerHTML(html) {
|
||||
if (html === null) {
|
||||
html = "";
|
||||
}
|
||||
|
||||
setInnerHTML(this.ownerDocument, this, html);
|
||||
},
|
||||
|
||||
scrollTop: 0,
|
||||
scrollLeft: 0,
|
||||
|
||||
/* returns NodeList */
|
||||
getElementsByTagName: memoizeQuery(function(/* string */ name) {
|
||||
name = name.toLowerCase();
|
||||
|
||||
function filterByTagName(child) {
|
||||
if (child.nodeName && child.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
return name === "*" || (child.nodeName.toLowerCase() === name);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return createLiveNodeList(this._ownerDocument || this, mapper(this, filterByTagName, true));
|
||||
}),
|
||||
});
|
||||
|
||||
core.DocumentFragment = function DocumentFragment(document) {
|
||||
core.Node.call(this, document);
|
||||
};
|
||||
inheritFrom(core.Node, core.DocumentFragment, {
|
||||
nodeType : NODE_TYPE.DOCUMENT_FRAGMENT_NODE
|
||||
});
|
||||
|
||||
core.Document = function Document(options) {
|
||||
if (!options || !options.parsingMode || (options.parsingMode !== "html" && options.parsingMode !== "xml")) {
|
||||
throw new Error("options must exist and contain a parsingMode of html or xml");
|
||||
}
|
||||
|
||||
core.Node.call(this, this);
|
||||
this._parsingMode = options.parsingMode;
|
||||
this._htmlToDom = new HtmlToDom(core, options.parser, options.parsingMode);
|
||||
|
||||
this._implementation = Object.create(core.DOMImplementation.prototype);
|
||||
this._implementation._ownerDocument = this;
|
||||
this._implementation._features = {};
|
||||
|
||||
this._defaultView = options.defaultView || null;
|
||||
this._global = options.global;
|
||||
this._documentElement = null;
|
||||
this._ids = Object.create(null);
|
||||
this._attached = true;
|
||||
this._readonly = false;
|
||||
this._currentScript = null;
|
||||
this._cookieJar = options.cookieJar === undefined ? new CookieJar(null, { looseMode: true }) : options.cookieJar;
|
||||
|
||||
this._contentType = options.contentType;
|
||||
if (this._contentType === undefined) {
|
||||
this._contentType = this._parsingMode === "xml" ? "application/xml" : "text/html";
|
||||
}
|
||||
|
||||
this._URL = options.url === undefined ? "about:blank" : new URL(options.url).href;
|
||||
this._location = new Location(this._URL, this);
|
||||
|
||||
if (options.cookie) {
|
||||
var cookies = Array.isArray(options.cookie) ? options.cookie: [options.cookie];
|
||||
var document = this;
|
||||
|
||||
cookies.forEach(function(cookieStr) {
|
||||
document._cookieJar.setCookieSync(cookieStr, document._URL, { ignoreError : true });
|
||||
});
|
||||
}
|
||||
|
||||
this._activeNodeIterators = [];
|
||||
this._activeNodeIteratorsMax = options.concurrentNodeIterators === undefined ?
|
||||
10 :
|
||||
Number(options.concurrentNodeIterators);
|
||||
|
||||
if (isNaN(this._activeNodeIteratorsMax)) {
|
||||
throw new TypeError("The 'concurrentNodeIterators' option must be a Number");
|
||||
}
|
||||
|
||||
if (this._activeNodeIteratorsMax < 0) {
|
||||
throw new RangeError("The 'concurrentNodeIterators' option must be a non negative Number");
|
||||
}
|
||||
};
|
||||
|
||||
core.Document._removingSteps = [];
|
||||
|
||||
var tagRegEx = /[^\w:\d_\.-]+/i;
|
||||
var entRegEx = /[^\w\d_\-&;]+/;
|
||||
var invalidAttrRegEx = /[\s"'>/=\u0000-\u001A]/;
|
||||
|
||||
inheritFrom(core.Node, core.Document, {
|
||||
nodeType : NODE_TYPE.DOCUMENT_NODE,
|
||||
_elementBuilders : { },
|
||||
_defaultElementBuilder: function(document, tagName) {
|
||||
return new core.Element(document, tagName);
|
||||
},
|
||||
get contentType() { return this._contentType;},
|
||||
get compatMode() { return (this._parsingMode === "xml" || this.doctype) ? "CSS1Compat" : "BackCompat"; },
|
||||
get charset() { return "UTF-8"; },
|
||||
get characterSet() { return "UTF-8"; },
|
||||
get inputEncoding() { return "UTF-8"; },
|
||||
get doctype() {
|
||||
for (const childNode of domSymbolTree.childrenIterator(this)) {
|
||||
if (childNode.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE) {
|
||||
return childNode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
get URL() {
|
||||
return this._URL;
|
||||
},
|
||||
get documentURI() {
|
||||
return this._URL;
|
||||
},
|
||||
get location() {
|
||||
return this._defaultView ? this._location : null;
|
||||
},
|
||||
get documentElement() {
|
||||
if (this._documentElement) {
|
||||
return this._documentElement;
|
||||
}
|
||||
|
||||
for (const childNode of domSymbolTree.childrenIterator(this)) {
|
||||
if (childNode.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
this._documentElement = childNode;
|
||||
return childNode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
get implementation() { return this._implementation;},
|
||||
set implementation(implementation) { this._implementation = implementation;},
|
||||
get readonly() { return this._readonly;},
|
||||
|
||||
get defaultView() {
|
||||
return this._defaultView;
|
||||
},
|
||||
|
||||
get currentScript() {
|
||||
return this._currentScript;
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return '[object HTMLDocument]';
|
||||
},
|
||||
|
||||
_createElementWithCorrectElementInterface: function (name, namespace) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-interface
|
||||
// TODO: eventually we should re-write the element-builder system to be namespace aware, but for now it is not.
|
||||
return (this._elementBuilders[name.toLowerCase()] || this._defaultElementBuilder)(this, name, namespace);
|
||||
},
|
||||
|
||||
appendChild : function(/* Node */ arg) {
|
||||
if (this.documentElement && arg.nodeType == NODE_TYPE.ELEMENT_NODE) {
|
||||
throw new core.DOMException(core.DOMException.HIERARCHY_REQUEST_ERR);
|
||||
}
|
||||
return core.Node.prototype.appendChild.call(this, arg);
|
||||
},
|
||||
|
||||
removeChild : function(/* Node */ arg) {
|
||||
var ret = core.Node.prototype.removeChild.call(this, arg);
|
||||
if (arg == this._documentElement) {
|
||||
this._documentElement = null;// force a recalculation
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
_descendantRemoved: function(parent, child) {
|
||||
if (child.tagName === 'STYLE') {
|
||||
var index = this.styleSheets.indexOf(child.sheet);
|
||||
if (index > -1) {
|
||||
this.styleSheets.splice(index, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* returns NodeList */
|
||||
getElementsByTagName: memoizeQuery(function(/* string */ name) {
|
||||
function filterByTagName(child) {
|
||||
if (child.nodeName && child.nodeType === NODE_TYPE.ELEMENT_NODE)
|
||||
{
|
||||
if (name === "*") {
|
||||
return true;
|
||||
|
||||
// case insensitivity for html
|
||||
} else if (child._ownerDocument && child._ownerDocument._doctype &&
|
||||
//child._ownerDocument._doctype.name === "html" &&
|
||||
child.nodeName.toLowerCase() === name.toLowerCase())
|
||||
{
|
||||
return true;
|
||||
} else if (child.nodeName.toLowerCase() === name.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return createLiveNodeList(this.documentElement || this, mapper(this, filterByTagName, true));
|
||||
}),
|
||||
|
||||
write: function () {
|
||||
var text = "";
|
||||
for (var i = 0; i < arguments.length; ++i) {
|
||||
text += String(arguments[i]);
|
||||
}
|
||||
|
||||
if (this._parsingMode === "xml") {
|
||||
throw new core.DOMException(core.DOMException.INVALID_STATE_ERR, "Cannot use document.write on XML documents");
|
||||
}
|
||||
|
||||
if (this._writeAfterElement) {
|
||||
// If called from an script element directly (during the first tick),
|
||||
// the new elements are inserted right after that element.
|
||||
var tempDiv = this.createElement('div');
|
||||
setInnerHTML(this, tempDiv, text);
|
||||
|
||||
var child = tempDiv.firstChild;
|
||||
var previous = this._writeAfterElement;
|
||||
var parent = this._writeAfterElement.parentNode;
|
||||
|
||||
while (child) {
|
||||
var node = child;
|
||||
child = child.nextSibling;
|
||||
parent.insertBefore(node, previous.nextSibling);
|
||||
previous = node;
|
||||
}
|
||||
} else if (this.readyState === "loading") {
|
||||
// During page loading, document.write appends to the current element
|
||||
// Find the last child that has been added to the document.
|
||||
var node = this;
|
||||
while (node.lastChild && node.lastChild.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
node = node.lastChild;
|
||||
}
|
||||
setInnerHTML(this, node, text);
|
||||
} else if (text) {
|
||||
setInnerHTML(this, this, text);
|
||||
}
|
||||
},
|
||||
|
||||
writeln: function () {
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length; ++i) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
args.push("\n");
|
||||
this.write.apply(this, args);
|
||||
},
|
||||
|
||||
_runRemovingSteps: function(oldNode, oldParent, oldPreviousSibling) {
|
||||
var listeners = core.Document._removingSteps;
|
||||
for (var i = 0; i < listeners.length; ++i) {
|
||||
listeners[i](this, oldNode, oldParent, oldPreviousSibling);
|
||||
}
|
||||
}
|
||||
});
|
||||
39
node_modules/jsdom/lib/jsdom/level2/core.js
generated
vendored
Normal file
39
node_modules/jsdom/lib/jsdom/level2/core.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var core = require("../level1/core");
|
||||
var memoizeQuery = require('../utils').memoizeQuery;
|
||||
var validateAndExtract = require('../living/helpers/validate-names').validateAndExtract;
|
||||
var mapper = require("../utils").mapper;
|
||||
const createLiveNodeList = require("../living/node-list").createLive;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
core.Element.prototype.getElementsByTagNameNS = memoizeQuery(function(/* String */ namespaceURI,
|
||||
/* String */ localName)
|
||||
{
|
||||
function filterByTagName(child) {
|
||||
var localMatch = child.localName === localName,
|
||||
nsMatch = child.namespaceURI === namespaceURI;
|
||||
|
||||
if ((localMatch || localName === "*") &&
|
||||
(nsMatch || namespaceURI === "*"))
|
||||
{
|
||||
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return createLiveNodeList(this.ownerDocument || this, mapper(this, filterByTagName));
|
||||
});
|
||||
|
||||
core.Document.prototype.getElementsByTagNameNS = function(/* String */ namespaceURI,
|
||||
/* String */ localName)
|
||||
{
|
||||
return core.Element.prototype.getElementsByTagNameNS.call(this,
|
||||
namespaceURI,
|
||||
localName);
|
||||
};
|
||||
|
||||
core.Document.prototype.getElementById = function(id) {
|
||||
// return the first element
|
||||
return (this._ids && this._ids[id] && this._ids[id].length > 0 ? this._ids[id][0] : null);
|
||||
};
|
||||
157
node_modules/jsdom/lib/jsdom/level2/events.js
generated
vendored
Normal file
157
node_modules/jsdom/lib/jsdom/level2/events.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
/* DOM Level2 Events implemented as described here:
|
||||
*
|
||||
* http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html
|
||||
*
|
||||
*/
|
||||
var core = require("../level1/core"),
|
||||
utils = require("../utils"),
|
||||
defineGetter = utils.defineGetter,
|
||||
defineSetter = utils.defineSetter,
|
||||
inheritFrom = utils.inheritFrom;
|
||||
|
||||
// The dependencies here are a bit screwy; when we get a chance to move all events to living, things will get simpler.
|
||||
const Event = require("../living/generated/Event");
|
||||
const CustomEvent = require("../living/generated/CustomEvent");
|
||||
const MessageEvent = require("../living/generated/MessageEvent");
|
||||
const ErrorEvent = require("../living/generated/ErrorEvent");
|
||||
const HashChangeEvent = require("../living/generated/HashChangeEvent");
|
||||
const UIEvent = require("../living/generated/UIEvent");
|
||||
const MouseEvent = require("../living/generated/MouseEvent");
|
||||
const KeyboardEvent = require("../living/generated/KeyboardEvent");
|
||||
const TouchEvent = require("../living/generated/TouchEvent");
|
||||
const MutationEvent = require("../living/generated/MutationEvent");
|
||||
const ProgressEvent = require("../living/generated/ProgressEvent");
|
||||
const domSymbolTree = require("../living/helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
core.Event = Event.interface;
|
||||
core.CustomEvent = CustomEvent.interface;
|
||||
core.MessageEvent = MessageEvent.interface;
|
||||
core.ErrorEvent = ErrorEvent.interface;
|
||||
core.HashChangeEvent = HashChangeEvent.interface;
|
||||
core.UIEvent = UIEvent.interface;
|
||||
core.MouseEvent = MouseEvent.interface;
|
||||
core.KeyboardEvent = KeyboardEvent.interface;
|
||||
core.TouchEvent = TouchEvent.interface;
|
||||
core.MutationEvent = MutationEvent.interface;
|
||||
core.ProgressEvent = ProgressEvent.interface;
|
||||
|
||||
core.EventTarget = require('../living/generated/EventTarget').interface;
|
||||
|
||||
// Reinherit class heirarchy with EventTarget at its root
|
||||
inheritFrom(core.EventTarget, core.Node, core.Node.prototype);
|
||||
|
||||
// Node
|
||||
inheritFrom(core.Node, core.Document, core.Document.prototype);
|
||||
inheritFrom(core.Node, core.DocumentFragment, core.DocumentFragment.prototype);
|
||||
inheritFrom(core.Node, core.Element, core.Element.prototype);
|
||||
|
||||
|
||||
function getDocument(el) {
|
||||
return el.nodeType == NODE_TYPE.DOCUMENT_NODE ? el : el._ownerDocument;
|
||||
}
|
||||
|
||||
function mutationEventsEnabled(el) {
|
||||
return el.nodeType != NODE_TYPE.ATTRIBUTE_NODE &&
|
||||
getDocument(el).implementation._hasFeature('MutationEvents');
|
||||
}
|
||||
|
||||
var insertBefore_super = core.Node.prototype.insertBefore;
|
||||
core.Node.prototype.insertBefore = function(newChild, refChild) {
|
||||
var ret = insertBefore_super.apply(this, arguments);
|
||||
if (mutationEventsEnabled(this)) {
|
||||
var doc = getDocument(this),
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
|
||||
ev.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
|
||||
newChild.dispatchEvent(ev);
|
||||
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
ev.initMutationEvent("DOMSubtreeModified", true, false, this, null, null, null, null);
|
||||
this.dispatchEvent(ev);
|
||||
|
||||
if (this.nodeType == NODE_TYPE.DOCUMENT_NODE || this._attachedToDocument) {
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
ev.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
|
||||
|
||||
for (const el of domSymbolTree.treeIterator(newChild)) {
|
||||
if (el.nodeType == NODE_TYPE.ELEMENT_NODE) {
|
||||
el.dispatchEvent(ev);
|
||||
el._attachedToDocument = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
var removeChild_super = core.Node.prototype.removeChild;
|
||||
core.Node.prototype.removeChild = function (oldChild) {
|
||||
if (mutationEventsEnabled(this)) {
|
||||
var doc = getDocument(this),
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
|
||||
ev.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
|
||||
oldChild.dispatchEvent(ev);
|
||||
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
ev.initMutationEvent("DOMSubtreeModified", true, false, this, null, null, null, null);
|
||||
this.dispatchEvent(ev);
|
||||
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
ev.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
|
||||
for (const el of domSymbolTree.treeIterator(oldChild)) {
|
||||
if (el.nodeType == NODE_TYPE.ELEMENT_NODE) {
|
||||
el.dispatchEvent(ev);
|
||||
el._attachedToDocument = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removeChild_super.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
var _attrModified_super = core.Node.prototype._attrModified;
|
||||
core.Node.prototype._attrModified = function (name, value, oldValue) {
|
||||
var ret = _attrModified_super.apply(this, arguments);
|
||||
if (mutationEventsEnabled(this) && value !== oldValue) {
|
||||
var doc = getDocument(this),
|
||||
ev = doc.createEvent("MutationEvents");
|
||||
|
||||
ev.initMutationEvent("DOMSubtreeModified", true, false, this, null, null, null, null);
|
||||
this.dispatchEvent(ev);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
var interfaceTable = {
|
||||
event: Event,
|
||||
events: Event,
|
||||
htmlevents: Event,
|
||||
mouseevent: MouseEvent,
|
||||
mouseevents: MouseEvent,
|
||||
uievent: UIEvent,
|
||||
uievents: UIEvent,
|
||||
messageevent: MessageEvent,
|
||||
|
||||
customevent: CustomEvent,
|
||||
keyboardevent: KeyboardEvent,
|
||||
keyevents: KeyboardEvent,
|
||||
touchevent: TouchEvent,
|
||||
|
||||
// old, not part of spec anymore
|
||||
mutationevents: MutationEvent
|
||||
};
|
||||
|
||||
core.Document.prototype.createEvent = function (type) {
|
||||
var typeLower = type.toLowerCase();
|
||||
var Event = interfaceTable[typeLower] || null;
|
||||
|
||||
if (!Event) {
|
||||
throw new core.DOMException(core.DOMException.NOT_SUPPORTED_ERR,
|
||||
"The provided event type (\"" + type + "\") is invalid");
|
||||
}
|
||||
|
||||
return Event.create([""]);
|
||||
};
|
||||
2545
node_modules/jsdom/lib/jsdom/level2/html.js
generated
vendored
Normal file
2545
node_modules/jsdom/lib/jsdom/level2/html.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
node_modules/jsdom/lib/jsdom/level2/languages/javascript.js
generated
vendored
Normal file
20
node_modules/jsdom/lib/jsdom/level2/languages/javascript.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
const vm = require("vm");
|
||||
const reportException = require("../../living/helpers/runtime-script-errors");
|
||||
|
||||
exports.javascript = function (element, code, filename) {
|
||||
const document = element.ownerDocument;
|
||||
const window = document && document._global;
|
||||
|
||||
if (window) {
|
||||
window.document._currentScript = element;
|
||||
|
||||
try {
|
||||
vm.runInContext(code, window, { filename, displayErrors: false });
|
||||
} catch (e) {
|
||||
reportException(window, e, filename);
|
||||
} finally {
|
||||
window.document._currentScript = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
198
node_modules/jsdom/lib/jsdom/level2/style.js
generated
vendored
Normal file
198
node_modules/jsdom/lib/jsdom/level2/style.js
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
"use strict";
|
||||
var resourceLoader = require('../browser/resource-loader'),
|
||||
core = require("../level1/core"),
|
||||
utils = require("../utils"),
|
||||
defineGetter = utils.defineGetter,
|
||||
inheritFrom = utils.inheritFrom,
|
||||
cssom = require("cssom"),
|
||||
cssstyle = require("cssstyle"),
|
||||
resolveHref = require("../utils").resolveHref,
|
||||
assert = require('assert');
|
||||
|
||||
const domSymbolTree = require("../living/helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
// What works now:
|
||||
// - Accessing the rules defined in individual stylesheets
|
||||
// - Modifications to style content attribute are reflected in style property
|
||||
// - Modifications to style property are reflected in style content attribute
|
||||
// TODO
|
||||
// - Modifications to style element's textContent are reflected in sheet property.
|
||||
// - Modifications to style element's sheet property are reflected in textContent.
|
||||
// - Modifications to link.href property are reflected in sheet property.
|
||||
// - Less-used features of link: disabled
|
||||
// - Less-used features of style: disabled, scoped, title
|
||||
// - CSSOM-View
|
||||
// - getComputedStyle(): requires default stylesheet, cascading, inheritance,
|
||||
// filtering by @media (screen? print?), layout for widths/heights
|
||||
// - Load events are not in the specs, but apparently some browsers
|
||||
// implement something. Should onload only fire after all @imports have been
|
||||
// loaded, or only the primary sheet?
|
||||
|
||||
core.StyleSheet = cssom.StyleSheet;
|
||||
core.MediaList = cssom.MediaList;
|
||||
core.CSSStyleSheet = cssom.CSSStyleSheet;
|
||||
core.CSSRule = cssom.CSSRule;
|
||||
core.CSSStyleRule = cssom.CSSStyleRule;
|
||||
core.CSSMediaRule = cssom.CSSMediaRule;
|
||||
core.CSSImportRule = cssom.CSSImportRule;
|
||||
core.CSSStyleDeclaration = cssstyle.CSSStyleDeclaration;
|
||||
|
||||
// Relavant specs
|
||||
// http://www.w3.org/TR/DOM-Level-2-Style (2000)
|
||||
// http://www.w3.org/TR/cssom-view/ (2008)
|
||||
// http://dev.w3.org/csswg/cssom/ (2010) Meant to replace DOM Level 2 Style
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML5, of course
|
||||
// http://dev.w3.org/csswg/css-style-attr/ not sure what's new here
|
||||
|
||||
// Objects that aren't in cssom library but should be:
|
||||
// CSSRuleList (cssom just uses array)
|
||||
// CSSFontFaceRule
|
||||
// CSSPageRule
|
||||
|
||||
// These rules don't really make sense to implement, so CSSOM draft makes them
|
||||
// obsolete.
|
||||
// CSSCharsetRule
|
||||
// CSSUnknownRule
|
||||
|
||||
// These objects are considered obsolete by CSSOM draft, although modern
|
||||
// browsers implement them.
|
||||
// CSSValue
|
||||
// CSSPrimitiveValue
|
||||
// CSSValueList
|
||||
// RGBColor
|
||||
// Rect
|
||||
// Counter
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#stylesheetlist
|
||||
function StyleSheetList() {}
|
||||
|
||||
StyleSheetList.prototype.__proto__ = Array.prototype;
|
||||
|
||||
StyleSheetList.prototype.item = function item(i) {
|
||||
return this[i];
|
||||
};
|
||||
|
||||
core.StyleSheetList = StyleSheetList;
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
|
||||
defineGetter(core.Document.prototype, 'styleSheets', function () {
|
||||
if (!this._styleSheets) {
|
||||
this._styleSheets = new StyleSheetList();
|
||||
}
|
||||
|
||||
// TODO: each style and link element should register its sheet on creation
|
||||
// and remove it on removal.
|
||||
return this._styleSheets;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @this {core.HTMLLinkElement|core.HTMLStyleElement}
|
||||
* @param {string} url
|
||||
* @param {cssom.CSSStyleSheet} sheet
|
||||
* @see http://dev.w3.org/csswg/cssom/#requirements-on-user-agents-implementing0
|
||||
*/
|
||||
function fetchStylesheet(url, sheet) {
|
||||
resourceLoader.load(this, url, function(data) {
|
||||
// TODO: abort if the content-type is not text/css, and the document is
|
||||
// in strict mode
|
||||
url = sheet.href = resourceLoader.resolveResourceUrl(this.ownerDocument, url);
|
||||
evaluateStylesheet.call(this, data, sheet, url);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @this {core.HTMLLinkElement|core.HTMLStyleElement}
|
||||
* @param {string} data
|
||||
* @param {cssom.CSSStyleSheet} sheet
|
||||
* @param {string} baseUrl
|
||||
*/
|
||||
function evaluateStylesheet(data, sheet, baseUrl) {
|
||||
// this is the element
|
||||
var newStyleSheet = cssom.parse(data);
|
||||
var spliceArgs = newStyleSheet.cssRules;
|
||||
spliceArgs.unshift(0, sheet.cssRules.length);
|
||||
Array.prototype.splice.apply(sheet.cssRules, spliceArgs);
|
||||
scanForImportRules.call(this, sheet.cssRules, baseUrl);
|
||||
this.ownerDocument.styleSheets.push(sheet);
|
||||
}
|
||||
/**
|
||||
* @this {core.HTMLLinkElement|core.HTMLStyleElement}
|
||||
* @param {cssom.CSSStyleSheet} sheet
|
||||
* @param {string} baseUrl
|
||||
*/
|
||||
function scanForImportRules(cssRules, baseUrl) {
|
||||
if (!cssRules) return;
|
||||
for (var i = 0; i < cssRules.length; ++i) {
|
||||
if (cssRules[i].cssRules) {
|
||||
// @media rule: keep searching inside it.
|
||||
scanForImportRules.call(this, cssRules[i].cssRules, baseUrl);
|
||||
} else if (cssRules[i].href) {
|
||||
// @import rule: fetch the resource and evaluate it.
|
||||
// See http://dev.w3.org/csswg/cssom/#css-import-rule
|
||||
// If loading of the style sheet fails its cssRules list is simply
|
||||
// empty. I.e. an @import rule always has an associated style sheet.
|
||||
fetchStylesheet.call(this, resolveHref(baseUrl, cssRules[i].href), this.sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(undefined, core.HTMLLinkElement._init);
|
||||
core.HTMLLinkElement._init = function() {
|
||||
this.addEventListener('DOMNodeInsertedIntoDocument', function() {
|
||||
if (!/(?:[ \t\n\r\f]|^)stylesheet(?:[ \t\n\r\f]|$)/i.test(this.rel)) {
|
||||
// rel is a space-separated list of tokens, and the original rel types
|
||||
// are case-insensitive.
|
||||
return;
|
||||
}
|
||||
if (this.href) {
|
||||
fetchStylesheet.call(this, this.href, this.sheet);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
assert.equal(undefined, core.HTMLStyleElement._init);
|
||||
core.HTMLStyleElement._init = function() {
|
||||
//console.log('init style')
|
||||
this.addEventListener('DOMNodeInsertedIntoDocument', function() {
|
||||
//console.log('style inserted')
|
||||
//console.log('sheet: ', this.sheet);
|
||||
if (this.type && this.type !== 'text/css') {
|
||||
//console.log('bad type: ' + this.type)
|
||||
return;
|
||||
}
|
||||
|
||||
let content = '';
|
||||
for (const child of domSymbolTree.childrenIterator(this)) {
|
||||
if (child.nodeType === NODE_TYPE.TEXT_NODE) {
|
||||
content += child.nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
evaluateStylesheet.call(this, content, this.sheet, this._ownerDocument.URL);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#htmllinkelement:
|
||||
// HTMLLinkElement implements LinkStyle
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#htmlstyleelement:
|
||||
// HTMLStyleElement implements LinkStyle
|
||||
|
||||
// from http://dev.w3.org/csswg/cssom/#the-linkstyle-interface
|
||||
|
||||
// A future refactoring would be to place _cssStyleSheet on all HTMLLinkElement and HTMLStyleElement instances, in
|
||||
// their constructor, initially set to null. Then, successful loading of the stylesheet object would set it to
|
||||
// non-null. The getter would just always return the current value. This would make it more correctly be null before
|
||||
// loading, and on load failure, and would allow access to _cssStyleSheet instead of the public .sheet API.
|
||||
|
||||
function getOrCreateSheet() {
|
||||
if (!this._cssStyleSheet) {
|
||||
this._cssStyleSheet = new cssom.CSSStyleSheet();
|
||||
}
|
||||
return this._cssStyleSheet;
|
||||
}
|
||||
|
||||
defineGetter(core.HTMLLinkElement.prototype, 'sheet', getOrCreateSheet);
|
||||
defineGetter(core.HTMLStyleElement.prototype, 'sheet', getOrCreateSheet);
|
||||
534
node_modules/jsdom/lib/jsdom/level3/core.js
generated
vendored
Normal file
534
node_modules/jsdom/lib/jsdom/level3/core.js
generated
vendored
Normal file
@@ -0,0 +1,534 @@
|
||||
"use strict";
|
||||
var core = require("../level1/core"),
|
||||
defineGetter = require('../utils').defineGetter,
|
||||
defineSetter = require('../utils').defineSetter,
|
||||
HtmlToDom = require('../browser/htmltodom').HtmlToDom;
|
||||
|
||||
const domSymbolTree = require("../living/helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
/*
|
||||
valuetype DOMString sequence<unsigned short>;
|
||||
typedef unsigned long long DOMTimeStamp;
|
||||
typedef any DOMUserData;
|
||||
typedef Object DOMObject;
|
||||
|
||||
*/
|
||||
/*
|
||||
// Introduced in DOM Level 3:
|
||||
interface NameList {
|
||||
DOMString getName(in unsigned long index);
|
||||
DOMString getNamespaceURI(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
boolean contains(in DOMString str);
|
||||
boolean containsNS(in DOMString namespaceURI,
|
||||
in DOMString name);
|
||||
};
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
interface DOMImplementationList {
|
||||
DOMImplementation item(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
};
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
interface DOMImplementationSource {
|
||||
DOMImplementation getDOMImplementation(in DOMString features);
|
||||
DOMImplementationList getDOMImplementationList(in DOMString features);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
core.DOMImplementation.prototype.getFeature = function(feature, version) {
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
interface Node {
|
||||
// Modified in DOM Level 3:
|
||||
Node insertBefore(in Node newChild,
|
||||
in Node refChild)
|
||||
raises(DOMException);
|
||||
// Modified in DOM Level 3:
|
||||
Node replaceChild(in Node newChild,
|
||||
in Node oldChild)
|
||||
raises(DOMException);
|
||||
// Modified in DOM Level 3:
|
||||
Node removeChild(in Node oldChild)
|
||||
raises(DOMException);
|
||||
// Modified in DOM Level 3:
|
||||
Node appendChild(in Node newChild)
|
||||
raises(DOMException);
|
||||
boolean hasChildNodes();
|
||||
Node cloneNode(in boolean deep);
|
||||
// Modified in DOM Level 3:
|
||||
void normalize();
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString baseURI;
|
||||
*/
|
||||
|
||||
// Compare Document Position
|
||||
var DOCUMENT_POSITION_DISCONNECTED = core.Node.DOCUMENT_POSITION_DISCONNECTED =
|
||||
core.Node.prototype.DOCUMENT_POSITION_DISCONNECTED = 0x01;
|
||||
|
||||
var DOCUMENT_POSITION_PRECEDING = core.Node.DOCUMENT_POSITION_PRECEDING =
|
||||
core.Node.prototype.DOCUMENT_POSITION_PRECEDING = 0x02;
|
||||
|
||||
var DOCUMENT_POSITION_FOLLOWING = core.Node.DOCUMENT_POSITION_FOLLOWING =
|
||||
core.Node.prototype.DOCUMENT_POSITION_FOLLOWING = 0x04;
|
||||
|
||||
var DOCUMENT_POSITION_CONTAINS = core.Node.DOCUMENT_POSITION_CONTAINS =
|
||||
core.Node.prototype.DOCUMENT_POSITION_CONTAINS = 0x08;
|
||||
|
||||
var DOCUMENT_POSITION_CONTAINED_BY = core.Node.DOCUMENT_POSITION_CONTAINED_BY =
|
||||
core.Node.prototype.DOCUMENT_POSITION_CONTAINED_BY = 0x10;
|
||||
|
||||
var DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = core.Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC =
|
||||
core.Node.prototype.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
|
||||
|
||||
// @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent
|
||||
defineGetter(core.Node.prototype, 'textContent', function() {
|
||||
let text;
|
||||
switch (this.nodeType) {
|
||||
case NODE_TYPE.COMMENT_NODE:
|
||||
case NODE_TYPE.CDATA_SECTION_NODE:
|
||||
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
|
||||
case NODE_TYPE.TEXT_NODE:
|
||||
return this.nodeValue;
|
||||
|
||||
case NODE_TYPE.ATTRIBUTE_NODE:
|
||||
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
|
||||
case NODE_TYPE.ELEMENT_NODE:
|
||||
text = '';
|
||||
for (const child of domSymbolTree.treeIterator(this)) {
|
||||
if (child.nodeType === NODE_TYPE.TEXT_NODE) {
|
||||
text += child.nodeValue;
|
||||
}
|
||||
}
|
||||
return text;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
defineSetter(core.Node.prototype, 'textContent', function(txt) {
|
||||
switch (this.nodeType) {
|
||||
case NODE_TYPE.COMMENT_NODE:
|
||||
case NODE_TYPE.CDATA_SECTION_NODE:
|
||||
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
|
||||
case NODE_TYPE.TEXT_NODE:
|
||||
return this.nodeValue = String(txt);
|
||||
}
|
||||
|
||||
for (let child = null; child = domSymbolTree.firstChild(this);) {
|
||||
this.removeChild(child);
|
||||
}
|
||||
|
||||
if (txt !== "" && txt != null) {
|
||||
this.appendChild(this._ownerDocument.createTextNode(txt));
|
||||
}
|
||||
return txt;
|
||||
});
|
||||
|
||||
/*
|
||||
// Introduced in DOM Level 3:
|
||||
DOMString lookupPrefix(in DOMString namespaceURI);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isDefaultNamespace(in DOMString namespaceURI);
|
||||
// Introduced in DOM Level 3:
|
||||
DOMString lookupNamespaceURI(in DOMString prefix);
|
||||
// Introduced in DOM Level 3:
|
||||
DOMObject getFeature(in DOMString feature,
|
||||
in DOMString version);
|
||||
*/
|
||||
// Introduced in DOM Level 3:
|
||||
core.Node.prototype.setUserData = function(key, data, handler) {
|
||||
var r = this[key] || null;
|
||||
this[key] = data;
|
||||
return(r);
|
||||
};
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
core.Node.prototype.getUserData = function(key) {
|
||||
var r = this[key] || null;
|
||||
return(r);
|
||||
};
|
||||
/*
|
||||
interface NodeList {
|
||||
Node item(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
};
|
||||
|
||||
interface NamedNodeMap {
|
||||
Node getNamedItem(in DOMString name);
|
||||
Node setNamedItem(in Node arg)
|
||||
raises(DOMException);
|
||||
Node removeNamedItem(in DOMString name)
|
||||
raises(DOMException);
|
||||
Node item(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
// Introduced in DOM Level 2:
|
||||
Node getNamedItemNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Node setNamedItemNS(in Node arg)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Node removeNamedItemNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
};
|
||||
|
||||
interface CharacterData : Node {
|
||||
attribute DOMString data;
|
||||
// raises(DOMException) on setting
|
||||
// raises(DOMException) on retrieval
|
||||
|
||||
readonly attribute unsigned long length;
|
||||
DOMString substringData(in unsigned long offset,
|
||||
in unsigned long count)
|
||||
raises(DOMException);
|
||||
void appendData(in DOMString arg)
|
||||
raises(DOMException);
|
||||
void insertData(in unsigned long offset,
|
||||
in DOMString arg)
|
||||
raises(DOMException);
|
||||
void deleteData(in unsigned long offset,
|
||||
in unsigned long count)
|
||||
raises(DOMException);
|
||||
void replaceData(in unsigned long offset,
|
||||
in unsigned long count,
|
||||
in DOMString arg)
|
||||
raises(DOMException);
|
||||
};
|
||||
|
||||
interface Attr : Node {
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute boolean specified;
|
||||
attribute DOMString value;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
// Introduced in DOM Level 2:
|
||||
readonly attribute Element ownerElement;
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute TypeInfo schemaTypeInfo;
|
||||
|
||||
*/
|
||||
// Introduced in DOM Level 3:
|
||||
/*
|
||||
};
|
||||
|
||||
interface Element : Node {
|
||||
readonly attribute DOMString tagName;
|
||||
DOMString getAttribute(in DOMString name);
|
||||
void setAttribute(in DOMString name,
|
||||
in DOMString value)
|
||||
raises(DOMException);
|
||||
void removeAttribute(in DOMString name)
|
||||
raises(DOMException);
|
||||
Attr getAttributeNode(in DOMString name);
|
||||
Attr setAttributeNode(in Attr newAttr)
|
||||
raises(DOMException);
|
||||
Attr removeAttributeNode(in Attr oldAttr)
|
||||
raises(DOMException);
|
||||
NodeList getElementsByTagName(in DOMString name);
|
||||
// Introduced in DOM Level 2:
|
||||
DOMString getAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
void setAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString qualifiedName,
|
||||
in DOMString value)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
void removeAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Attr getAttributeNodeNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Attr setAttributeNodeNS(in Attr newAttr)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
NodeList getElementsByTagNameNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
boolean hasAttribute(in DOMString name);
|
||||
// Introduced in DOM Level 2:
|
||||
boolean hasAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString localName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute TypeInfo schemaTypeInfo;
|
||||
// Introduced in DOM Level 3:
|
||||
void setIdAttribute(in DOMString name,
|
||||
in boolean isId)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
void setIdAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString localName,
|
||||
in boolean isId)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
void setIdAttributeNode(in Attr idAttr,
|
||||
in boolean isId)
|
||||
raises(DOMException);
|
||||
};
|
||||
|
||||
interface Text : CharacterData {
|
||||
Text splitText(in unsigned long offset)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute boolean isElementContentWhitespace;
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString wholeText;
|
||||
// Introduced in DOM Level 3:
|
||||
Text replaceWholeText(in DOMString content)
|
||||
raises(DOMException);
|
||||
};
|
||||
|
||||
interface Comment : CharacterData {
|
||||
};
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
interface TypeInfo {
|
||||
readonly attribute DOMString typeName;
|
||||
readonly attribute DOMString typeNamespace;
|
||||
|
||||
// DerivationMethods
|
||||
const unsigned long DERIVATION_RESTRICTION = 0x00000001;
|
||||
const unsigned long DERIVATION_EXTENSION = 0x00000002;
|
||||
const unsigned long DERIVATION_UNION = 0x00000004;
|
||||
const unsigned long DERIVATION_LIST = 0x00000008;
|
||||
|
||||
boolean isDerivedFrom(in DOMString typeNamespaceArg,
|
||||
in DOMString typeNameArg,
|
||||
in unsigned long derivationMethod);
|
||||
};
|
||||
*/
|
||||
// Introduced in DOM Level 3:
|
||||
core.UserDataHandler = function() {};
|
||||
core.UserDataHandler.prototype.NODE_CLONED = 1;
|
||||
core.UserDataHandler.prototype.NODE_IMPORTED = 2;
|
||||
core.UserDataHandler.prototype.NODE_DELETED = 3;
|
||||
core.UserDataHandler.prototype.NODE_RENAMED = 4;
|
||||
core.UserDataHandler.prototype.NODE_ADOPTED = 5;
|
||||
core.UserDataHandler.prototype.handle = function(operation, key, data, src, dst) {};
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
core.DOMError = function(severity, message, type, relatedException, relatedData, location) {
|
||||
this._severity = severity;
|
||||
this._message = message;
|
||||
this._type = type;
|
||||
this._relatedException = relatedException;
|
||||
this._relatedData = relatedData;
|
||||
this._location = location;
|
||||
};
|
||||
core.DOMError.prototype = {};
|
||||
core.DOMError.prototype.SEVERITY_WARNING = 1;
|
||||
core.DOMError.prototype.SEVERITY_ERROR = 2;
|
||||
core.DOMError.prototype.SEVERITY_FATAL_ERROR = 3;
|
||||
defineGetter(core.DOMError.prototype, 'severity', function() {
|
||||
return this._severity;
|
||||
});
|
||||
defineGetter(core.DOMError.prototype, 'message', function() {
|
||||
return this._message;
|
||||
});
|
||||
defineGetter(core.DOMError.prototype, 'type', function() {
|
||||
return this._type;
|
||||
});
|
||||
defineGetter(core.DOMError.prototype, 'relatedException', function() {
|
||||
return this._relatedException;
|
||||
});
|
||||
defineGetter(core.DOMError.prototype, 'relatedData', function() {
|
||||
return this._relatedData;
|
||||
});
|
||||
defineGetter(core.DOMError.prototype, 'location', function() {
|
||||
return this._location;
|
||||
});
|
||||
|
||||
/*
|
||||
// Introduced in DOM Level 3:
|
||||
interface DOMErrorHandler {
|
||||
boolean handleError(in DOMError error);
|
||||
};
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
interface DOMLocator {
|
||||
readonly attribute long lineNumber;
|
||||
readonly attribute long columnNumber;
|
||||
readonly attribute long byteOffset;
|
||||
readonly attribute long utf16Offset;
|
||||
readonly attribute Node relatedNode;
|
||||
readonly attribute DOMString uri;
|
||||
};
|
||||
*/
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
core.DOMConfiguration = function(){
|
||||
var possibleParameterNames = {
|
||||
'canonical-form': [false, true], // extra rules for true
|
||||
'cdata-sections': [true, false],
|
||||
'check-character-normalization': [false, true],
|
||||
'comments': [true, false],
|
||||
'datatype-normalization': [false, true],
|
||||
'element-content-whitespace': [true, false],
|
||||
'entities': [true, false],
|
||||
// 'error-handler': [],
|
||||
'infoset': [undefined, true, false], // extra rules for true
|
||||
'namespaces': [true, false],
|
||||
'namespace-declarations': [true, false], // only checked if namespaces is true
|
||||
'normalize-characters': [false, true],
|
||||
// 'schema-location': [],
|
||||
// 'schema-type': [],
|
||||
'split-cdata-sections': [true, false],
|
||||
'validate': [false, true],
|
||||
'validate-if-schema': [false, true],
|
||||
'well-formed': [true, false]
|
||||
}
|
||||
};
|
||||
|
||||
core.DOMConfiguration.prototype = {
|
||||
setParameter: function(name, value) {},
|
||||
getParameter: function(name) {},
|
||||
canSetParameter: function(name, value) {},
|
||||
parameterNames: function() {}
|
||||
};
|
||||
|
||||
//core.Document.prototype._domConfig = new core.DOMConfiguration();
|
||||
defineGetter(core.Document.prototype, 'domConfig', function() {
|
||||
return this._domConfig || new core.DOMConfiguration();;
|
||||
});
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
core.DOMStringList = function() {};
|
||||
|
||||
core.DOMStringList.prototype = {
|
||||
item: function() {},
|
||||
length: function() {},
|
||||
contains: function() {}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
interface CDATASection : Text {
|
||||
};
|
||||
|
||||
interface DocumentType : Node {
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute NamedNodeMap entities;
|
||||
readonly attribute NamedNodeMap notations;
|
||||
// Introduced in DOM Level 2:
|
||||
readonly attribute DOMString publicId;
|
||||
// Introduced in DOM Level 2:
|
||||
readonly attribute DOMString systemId;
|
||||
// Introduced in DOM Level 2:
|
||||
readonly attribute DOMString internalSubset;
|
||||
};
|
||||
|
||||
interface Notation : Node {
|
||||
readonly attribute DOMString publicId;
|
||||
readonly attribute DOMString systemId;
|
||||
};
|
||||
|
||||
interface Entity : Node {
|
||||
readonly attribute DOMString publicId;
|
||||
readonly attribute DOMString systemId;
|
||||
readonly attribute DOMString notationName;
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString inputEncoding;
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString xmlEncoding;
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString xmlVersion;
|
||||
};
|
||||
|
||||
interface EntityReference : Node {
|
||||
};
|
||||
|
||||
interface ProcessingInstruction : Node {
|
||||
readonly attribute DOMString target;
|
||||
attribute DOMString data;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
};
|
||||
|
||||
interface DocumentFragment : Node {
|
||||
};
|
||||
|
||||
interface Document : Node {
|
||||
// Modified in DOM Level 3:
|
||||
readonly attribute DocumentType doctype;
|
||||
readonly attribute DOMImplementation implementation;
|
||||
readonly attribute Element documentElement;
|
||||
Element createElement(in DOMString tagName)
|
||||
raises(DOMException);
|
||||
DocumentFragment createDocumentFragment();
|
||||
Text createTextNode(in DOMString data);
|
||||
Comment createComment(in DOMString data);
|
||||
CDATASection createCDATASection(in DOMString data)
|
||||
raises(DOMException);
|
||||
ProcessingInstruction createProcessingInstruction(in DOMString target,
|
||||
in DOMString data)
|
||||
raises(DOMException);
|
||||
Attr createAttribute(in DOMString name)
|
||||
raises(DOMException);
|
||||
EntityReference createEntityReference(in DOMString name)
|
||||
raises(DOMException);
|
||||
NodeList getElementsByTagName(in DOMString tagname);
|
||||
// Introduced in DOM Level 2:
|
||||
Node importNode(in Node importedNode,
|
||||
in boolean deep)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Element createElementNS(in DOMString namespaceURI,
|
||||
in DOMString qualifiedName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
Attr createAttributeNS(in DOMString namespaceURI,
|
||||
in DOMString qualifiedName)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 2:
|
||||
NodeList getElementsByTagNameNS(in DOMString namespaceURI,
|
||||
in DOMString localName);
|
||||
// Introduced in DOM Level 2:
|
||||
Element getElementById(in DOMString elementId);
|
||||
*/
|
||||
/*
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString xmlEncoding;
|
||||
// Introduced in DOM Level 3:
|
||||
attribute boolean xmlStandalone;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
attribute DOMString xmlVersion;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
attribute boolean strictErrorChecking;
|
||||
// Introduced in DOM Level 3:
|
||||
attribute DOMString documentURI;
|
||||
// Introduced in DOM Level 3:
|
||||
Node adoptNode(in Node source)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMConfiguration domConfig;
|
||||
// Introduced in DOM Level 3:
|
||||
void normalizeDocument();
|
||||
// Introduced in DOM Level 3:
|
||||
Node renameNode(in Node n,
|
||||
in DOMString namespaceURI,
|
||||
in DOMString qualifiedName)
|
||||
raises(DOMException);
|
||||
};
|
||||
};
|
||||
|
||||
#endif // _DOM_IDL_
|
||||
*/
|
||||
211
node_modules/jsdom/lib/jsdom/level3/ls.js
generated
vendored
Normal file
211
node_modules/jsdom/lib/jsdom/level3/ls.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
// w3c Load/Save functionality: http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/
|
||||
|
||||
var core = require('../level1/core');
|
||||
var createFrom = require('../utils').createFrom;
|
||||
|
||||
var ls = {};
|
||||
|
||||
// TODO: what is this?
|
||||
//typedef dom::DOMConfiguration DOMConfiguration;
|
||||
|
||||
ls.LSException = function LSException(code) {
|
||||
this.code = code;
|
||||
};
|
||||
|
||||
ls.LSException.prototype = {
|
||||
// LSExceptionCode
|
||||
PARSE_ERR : 81,
|
||||
SERIALIZE_ERR : 82
|
||||
};
|
||||
|
||||
ls.DOMImplementationLS = function DOMImplementationLS() {
|
||||
|
||||
};
|
||||
|
||||
var DOMImplementationExtension = {
|
||||
|
||||
// DOMImplementationLSMode
|
||||
MODE_SYNCHRONOUS : 1,
|
||||
MODE_ASYNCHRONOUS : 2,
|
||||
|
||||
// raises(dom::DOMException);
|
||||
createLSParser : function(/* int */ mode, /* string */ schemaType) {
|
||||
return new ls.LSParser(mode, schemaType);
|
||||
},
|
||||
|
||||
createLSSerializer : function() {
|
||||
return new ls.LSSerializer();
|
||||
},
|
||||
|
||||
createLSInput : function() {
|
||||
return new ls.LSInput();
|
||||
},
|
||||
|
||||
createLSOutput : function() {
|
||||
return new ls.LSOutput();
|
||||
}
|
||||
};
|
||||
|
||||
Object.keys(DOMImplementationExtension).forEach(function(k, v) {
|
||||
core.DOMImplementation.prototype[k] = DOMImplementationExtension[k];
|
||||
});
|
||||
|
||||
ls.DOMImplementationLS.prototype = DOMImplementationExtension;
|
||||
|
||||
core.Document.getFeature = function() {
|
||||
return DOMImplementationExtension;
|
||||
};
|
||||
|
||||
ls.LSParser = function LSParser() {
|
||||
this._domConfig = new core.DOMConfiguration();
|
||||
};
|
||||
ls.LSParser.prototype = {
|
||||
get domConfig() { return this._domConfig; },
|
||||
get filter() { return this._filter || null; },
|
||||
set filter(value) { this._filter = value; },
|
||||
get async() { return this._async; },
|
||||
get busy() { return this._busy; },
|
||||
|
||||
// raises(dom::DOMException, LSException);
|
||||
parse : function (/* LSInput */ input) {
|
||||
var doc = new core.Document();
|
||||
doc._inputEncoding = 'UTF-16';
|
||||
return doc;
|
||||
},
|
||||
|
||||
// raises(dom::DOMException, LSException);
|
||||
parseURI : function(/* string */ uri) {
|
||||
return new core.Document();
|
||||
},
|
||||
|
||||
// ACTION_TYPES
|
||||
ACTION_APPEND_AS_CHILDREN : 1,
|
||||
ACTION_REPLACE_CHILDREN : 2,
|
||||
ACTION_INSERT_BEFORE : 3,
|
||||
ACTION_INSERT_AFTER : 4,
|
||||
ACTION_REPLACE : 5,
|
||||
|
||||
// @returns Node
|
||||
// @raises DOMException, LSException
|
||||
parseWithContext : function(/* LSInput */ input, /* Node */ contextArg, /* int */ action) {
|
||||
return new core.Node();
|
||||
},
|
||||
|
||||
abort : function() {
|
||||
// TODO: implement
|
||||
}
|
||||
};
|
||||
|
||||
ls.LSInput = function LSInput() {};
|
||||
ls.LSInput.prototype = {
|
||||
get characterStream() { return this._characterStream || null; },
|
||||
set characterStream(value) { this._characterStream = value; },
|
||||
get byteStream() { return this._byteStream || null; },
|
||||
set byteStream(value) { this._byteStream = value; },
|
||||
get stringData() { return this._stringData || null; },
|
||||
set stringData(value) { this._stringData = value; },
|
||||
get systemId() { return this._systemId || null; },
|
||||
set systemId(value) { this._systemId = value; },
|
||||
get publicId() { return this._publicId || null; },
|
||||
set publicId(value) { this._publicId = value; },
|
||||
get baseURI() { return this._baseURI || null; },
|
||||
set baseURI(value) { this._baseURI = value; },
|
||||
get encoding() { return this._encoding || null; },
|
||||
set encoding(value) { this._encoding = value; },
|
||||
get certifiedText() { return this._certifiedText || null; },
|
||||
set certifiedText(value) { this._certifiedText = value; },
|
||||
};
|
||||
|
||||
ls.LSResourceResolver = function LSResourceResolver() {};
|
||||
|
||||
// @returns LSInput
|
||||
ls.LSResourceResolver.prototype.resolveResource = function(type, namespaceURI, publicId, systemId, baseURI) {
|
||||
return new ls.LSInput();
|
||||
};
|
||||
|
||||
ls.LSParserFilter = function LSParserFilter() {};
|
||||
ls.LSParserFilter.prototype = {
|
||||
|
||||
// Constants returned by startElement and acceptNode
|
||||
FILTER_ACCEPT : 1,
|
||||
FILTER_REJECT : 2,
|
||||
FILTER_SKIP : 3,
|
||||
FILTER_INTERRUPT : 4,
|
||||
|
||||
get whatToShow() { return this._whatToShow; },
|
||||
|
||||
// @returns int
|
||||
startElement : function(/* Element */ elementArg) {
|
||||
return 0;
|
||||
},
|
||||
|
||||
// @returns int
|
||||
acceptNode : function(/* Node */ nodeArg) {
|
||||
return nodeArg;
|
||||
}
|
||||
};
|
||||
|
||||
ls.LSSerializer = function LSSerializer() {
|
||||
this._domConfig = new core.DOMConfiguration();
|
||||
};
|
||||
ls.LSSerializer.prototype = {
|
||||
get domConfig() { return this._domConfig; },
|
||||
get newLine() { return this._newLine || null; },
|
||||
set newLine(value) { this._newLine = value; },
|
||||
get filter() { return this._filter || null; },
|
||||
set filter(value) { this._filter = value; },
|
||||
|
||||
// @returns boolean
|
||||
// @raises LSException
|
||||
write : function(/* Node */ nodeArg, /* LSOutput */ destination) {
|
||||
return true;
|
||||
},
|
||||
|
||||
// @returns boolean
|
||||
// @raises LSException
|
||||
writeToURI : function(/* Node */ nodeArg, /* string */ uri) {
|
||||
return true;
|
||||
},
|
||||
|
||||
// @returns string
|
||||
// @raises DOMException, LSException
|
||||
writeToString : function(/* Node */ nodeArg) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
ls.LSOutput = function LSOutput() {};
|
||||
ls.LSOutput.prototype = {
|
||||
get characterStream() { return this._characterStream || null; },
|
||||
set characterStream(value) { this._characterStream = value; },
|
||||
get byteStream() { return this._byteStream || null; },
|
||||
set byteStream(value) { this._byteStream = value; },
|
||||
get systemId() { return this._systemId || null; },
|
||||
set systemId(value) { this._systemId = value; },
|
||||
get encoding() { return this._encoding || null; },
|
||||
set encoding(value) { this._encoding = value; },
|
||||
};
|
||||
|
||||
ls.LSProgressEvent = function LSProgressEvent() {};
|
||||
ls.LSProgressEvent.prototype = createFrom(core.Event, {
|
||||
constructor: ls.LSProgressEvent,
|
||||
get input() { return this._input; },
|
||||
get position() { return this._position; },
|
||||
get totalSize() { return this._totalSize; },
|
||||
});
|
||||
|
||||
ls.LSLoadEvent = function LSLoadEvent() {};
|
||||
ls.LSLoadEvent.prototype = createFrom(core.Event, {
|
||||
get newDocument() { return this._newDocument; },
|
||||
get input() { return this._input; },
|
||||
});
|
||||
|
||||
|
||||
// TODO: do traversal
|
||||
ls.LSSerializerFilter = function LSSerializerFilter() {};
|
||||
ls.LSSerializerFilter.prototype = {
|
||||
get whatToShow() { return this._whatToShow; },
|
||||
};
|
||||
|
||||
// ls.LSSerializerFilter.prototype.__proto__ = level2.traversal.NodeFiler;
|
||||
|
||||
1877
node_modules/jsdom/lib/jsdom/level3/xpath.js
generated
vendored
Normal file
1877
node_modules/jsdom/lib/jsdom/level3/xpath.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
419
node_modules/jsdom/lib/jsdom/living/attributes.js
generated
vendored
Normal file
419
node_modules/jsdom/lib/jsdom/living/attributes.js
generated
vendored
Normal file
@@ -0,0 +1,419 @@
|
||||
"use strict";
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const idlUtils = require("./generated/utils");
|
||||
const attrGenerated = require("./generated/Attr");
|
||||
const changeAttributeImpl = require("./attributes/Attr-impl").changeAttributeImpl;
|
||||
const getAttrImplQualifiedName = require("./attributes/Attr-impl").getAttrImplQualifiedName;
|
||||
|
||||
// https://dom.spec.whatwg.org/#namednodemap
|
||||
|
||||
const INTERNAL = Symbol("NamedNodeMap internal");
|
||||
|
||||
// TODO: use NamedPropertyTracker when https://github.com/tmpvar/jsdom/pull/1116 lands?
|
||||
|
||||
// Don't emulate named getters for these properties.
|
||||
// Compiled later after NamedNodeMap is all set up.
|
||||
const reservedNames = new Set();
|
||||
|
||||
function NamedNodeMap() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
defineGetter(NamedNodeMap.prototype, "length", function () {
|
||||
return this[INTERNAL].attributeList.length;
|
||||
});
|
||||
|
||||
NamedNodeMap.prototype.item = function (index) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.item");
|
||||
}
|
||||
|
||||
// Don't bother with full unsigned long long conversion. When we have better WebIDL support generally, revisit.
|
||||
index = Number(index);
|
||||
|
||||
return this[index] || null;
|
||||
};
|
||||
|
||||
NamedNodeMap.prototype.getNamedItem = function (name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItem");
|
||||
}
|
||||
name = String(name);
|
||||
|
||||
return exports.getAttributeByName(this[INTERNAL].element, name);
|
||||
};
|
||||
|
||||
NamedNodeMap.prototype.getNamedItemNS = function (namespace, localName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItemNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
return exports.getAttributeByNameNS(this[INTERNAL].element, namespace, localName);
|
||||
};
|
||||
|
||||
NamedNodeMap.prototype.setNamedItem = function (attr) {
|
||||
if (!attrGenerated.is(attr)) {
|
||||
throw new TypeError("First argument to NamedNodeMap.prototype.setNamedItem must be an Attr");
|
||||
}
|
||||
|
||||
return exports.setAttribute(this[INTERNAL].element, attr);
|
||||
};
|
||||
|
||||
NamedNodeMap.prototype.setNamedItemNS = function (attr) {
|
||||
if (!attrGenerated.is(attr)) {
|
||||
throw new TypeError("First argument to NamedNodeMap.prototype.setNamedItemNS must be an Attr");
|
||||
}
|
||||
|
||||
return exports.setAttribute(this[INTERNAL].element, attr);
|
||||
};
|
||||
|
||||
NamedNodeMap.prototype.removeNamedItem = function (name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItem");
|
||||
}
|
||||
name = String(name);
|
||||
|
||||
const attr = exports.removeAttributeByName(this[INTERNAL].element, name);
|
||||
|
||||
if (attr === null) {
|
||||
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
|
||||
}
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
NamedNodeMap.prototype.removeNamedItemNS = function (namespace, localName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.removeNamedItemNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
const attr = exports.removeAttributeByNameNS(this[INTERNAL].element, namespace, localName);
|
||||
|
||||
if (attr === null) {
|
||||
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
|
||||
}
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
exports.NamedNodeMap = NamedNodeMap;
|
||||
|
||||
{
|
||||
let prototype = NamedNodeMap.prototype;
|
||||
while (prototype) {
|
||||
for (const name of Object.getOwnPropertyNames(prototype)) {
|
||||
reservedNames.add(name);
|
||||
}
|
||||
prototype = Object.getPrototypeOf(prototype);
|
||||
}
|
||||
}
|
||||
|
||||
exports.createNamedNodeMap = function (element) {
|
||||
const nnm = Object.create(NamedNodeMap.prototype);
|
||||
nnm[INTERNAL] = {
|
||||
element,
|
||||
attributeList: [],
|
||||
attributesByNameMap: new Map()
|
||||
};
|
||||
return nnm;
|
||||
};
|
||||
|
||||
// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a
|
||||
// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations.
|
||||
|
||||
exports.hasAttribute = function (element, A) {
|
||||
const attributesNNM = element._attributes;
|
||||
const attributeList = attributesNNM[INTERNAL].attributeList;
|
||||
|
||||
return attributeList.indexOf(A) !== -1;
|
||||
};
|
||||
|
||||
exports.hasAttributeByName = function (element, name) {
|
||||
const attributesNNM = element._attributes;
|
||||
const attributesByNameMap = attributesNNM[INTERNAL].attributesByNameMap;
|
||||
|
||||
return attributesByNameMap.has(name);
|
||||
};
|
||||
|
||||
exports.hasAttributeByNameNS = function (element, namespace, localName) {
|
||||
const attributesNNM = element._attributes;
|
||||
const attributeList = attributesNNM[INTERNAL].attributeList;
|
||||
|
||||
return attributeList.some(attribute => {
|
||||
const impl = idlUtils.implForWrapper(attribute);
|
||||
return impl && impl._localName === localName && impl._namespace === namespace;
|
||||
});
|
||||
};
|
||||
|
||||
exports.changeAttribute = function (element, attribute, value) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change
|
||||
|
||||
// The partitioning here works around a particularly bad circular require problem. See
|
||||
// https://github.com/tmpvar/jsdom/pull/1247#issuecomment-149060470
|
||||
changeAttributeImpl(element, idlUtils.implForWrapper(attribute), value);
|
||||
};
|
||||
|
||||
exports.appendAttribute = function (element, attribute) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-append
|
||||
|
||||
const impl = idlUtils.implForWrapper(attribute);
|
||||
const attributesNNM = element._attributes;
|
||||
const attributeList = attributesNNM[INTERNAL].attributeList;
|
||||
|
||||
// TODO mutation observer stuff
|
||||
|
||||
attributeList.push(attribute);
|
||||
impl._element = element;
|
||||
|
||||
// Sync target indexed properties
|
||||
attributesNNM[attributeList.length - 1] = attribute;
|
||||
|
||||
// Sync target named properties
|
||||
const name = getAttrImplQualifiedName(impl);
|
||||
if (!reservedNames.has(name)) {
|
||||
attributesNNM[name] = attribute;
|
||||
}
|
||||
|
||||
// Sync name cache
|
||||
const cache = attributesNNM[INTERNAL].attributesByNameMap;
|
||||
let entry = cache.get(name);
|
||||
if (!entry) {
|
||||
entry = [];
|
||||
cache.set(name, entry);
|
||||
}
|
||||
entry.push(attribute);
|
||||
|
||||
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added."
|
||||
element._attrModified(name, impl._value, null);
|
||||
};
|
||||
|
||||
exports.removeAttribute = function (element, attribute) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-remove
|
||||
|
||||
const attributesNNM = element._attributes;
|
||||
const attributeList = attributesNNM[INTERNAL].attributeList;
|
||||
|
||||
// TODO mutation observer stuff
|
||||
|
||||
for (let i = 0; i < attributeList.length; ++i) {
|
||||
if (attributeList[i] === attribute) {
|
||||
const impl = idlUtils.implForWrapper(attribute);
|
||||
|
||||
attributeList.splice(i, 1);
|
||||
impl._element = null;
|
||||
|
||||
// Sync target indexed properties
|
||||
for (let j = i; j < attributeList.length; ++j) {
|
||||
attributesNNM[j] = attributeList[j];
|
||||
}
|
||||
delete attributesNNM[attributeList.length];
|
||||
|
||||
// Sync target named properties
|
||||
const name = getAttrImplQualifiedName(impl);
|
||||
if (!reservedNames.has(name)) {
|
||||
delete attributesNNM[name];
|
||||
}
|
||||
|
||||
// Sync name cache
|
||||
const cache = attributesNNM[INTERNAL].attributesByNameMap;
|
||||
const entry = cache.get(name);
|
||||
entry.splice(entry.indexOf(attribute), 1);
|
||||
if (entry.length === 0) {
|
||||
cache.delete(name);
|
||||
}
|
||||
|
||||
// Run jsdom hooks; roughly correspond to spec's "An attribute is removed."
|
||||
element._attrModified(name, null, impl._value);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.getAttributeByName = function (element, name) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
|
||||
if (element._namespaceURI === "http://www.w3.org/1999/xhtml" &&
|
||||
element._ownerDocument._parsingMode === "html") {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
const cache = element._attributes[INTERNAL].attributesByNameMap;
|
||||
const entry = cache.get(name);
|
||||
if (!entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return entry[0];
|
||||
};
|
||||
|
||||
exports.getAttributeValue = function (element, name) {
|
||||
const attr = exports.getAttributeByName(element, name);
|
||||
|
||||
if (!attr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return idlUtils.implForWrapper(attr)._value;
|
||||
};
|
||||
|
||||
exports.getAttributeByNameNS = function (element, namespace, localName) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
|
||||
|
||||
if (namespace === "") {
|
||||
namespace = null;
|
||||
}
|
||||
|
||||
const attributeList = element._attributes[INTERNAL].attributeList;
|
||||
for (let i = 0; i < attributeList.length; ++i) {
|
||||
const attr = attributeList[i];
|
||||
const impl = idlUtils.implForWrapper(attr);
|
||||
if (impl._namespace === namespace && impl._localName === localName) {
|
||||
return attr;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
exports.getAttributeValueByNameNS = function (element, namespace, localName) {
|
||||
const attr = exports.getAttributeByNameNS(element, namespace, localName);
|
||||
|
||||
if (!attr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return idlUtils.implForWrapper(attr)._value;
|
||||
};
|
||||
|
||||
exports.setAttribute = function (element, attr) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-set
|
||||
|
||||
const impl = idlUtils.implForWrapper(attr);
|
||||
|
||||
if (impl._element !== null && impl._element !== element) {
|
||||
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
|
||||
}
|
||||
|
||||
const oldAttr = exports.getAttributeByNameNS(element, impl._namespace, impl._localName);
|
||||
if (oldAttr === attr) {
|
||||
return attr;
|
||||
}
|
||||
|
||||
if (oldAttr !== null) {
|
||||
exports.removeAttribute(element, oldAttr);
|
||||
}
|
||||
|
||||
exports.appendAttribute(element, attr);
|
||||
|
||||
return oldAttr;
|
||||
};
|
||||
|
||||
exports.setAttributeValue = function (element, localName, value, prefix, namespace) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-set-value
|
||||
|
||||
if (prefix === undefined) {
|
||||
prefix = null;
|
||||
}
|
||||
if (namespace === undefined) {
|
||||
namespace = null;
|
||||
}
|
||||
|
||||
const attribute = exports.getAttributeByNameNS(element, namespace, localName);
|
||||
if (attribute === null) {
|
||||
const newAttribute = attrGenerated.create([], { namespace, namespacePrefix: prefix, localName, value });
|
||||
exports.appendAttribute(element, newAttribute);
|
||||
return;
|
||||
}
|
||||
|
||||
exports.changeAttribute(element, attribute, value);
|
||||
};
|
||||
|
||||
exports.removeAttributeByName = function (element, name) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
|
||||
|
||||
const attr = exports.getAttributeByName(element, name);
|
||||
|
||||
if (attr !== null) {
|
||||
exports.removeAttribute(element, attr);
|
||||
}
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
exports.removeAttributeByNameNS = function (element, namespace, localName) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
|
||||
|
||||
const attr = exports.getAttributeByNameNS(element, namespace, localName);
|
||||
|
||||
if (attr !== null) {
|
||||
exports.removeAttribute(element, attr);
|
||||
}
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
exports.copyAttributeList = function (sourceElement, destElement) {
|
||||
// Needed by https://dom.spec.whatwg.org/#concept-node-clone
|
||||
|
||||
for (const sourceAttr of sourceElement._attributes[INTERNAL].attributeList) {
|
||||
const sourceImpl = idlUtils.implForWrapper(sourceAttr);
|
||||
|
||||
const destAttr = attrGenerated.create([], {
|
||||
namespace: sourceImpl._namespace,
|
||||
prefix: sourceImpl._prefix,
|
||||
localName: sourceImpl._localName,
|
||||
value: sourceImpl._value
|
||||
});
|
||||
|
||||
exports.appendAttribute(destElement, destAttr);
|
||||
}
|
||||
};
|
||||
|
||||
exports.attributeListsEqual = function (elementA, elementB) {
|
||||
// Needed by https://dom.spec.whatwg.org/#concept-node-equals
|
||||
|
||||
const listA = elementA._attributes[INTERNAL].attributeList;
|
||||
const listB = elementB._attributes[INTERNAL].attributeList;
|
||||
|
||||
if (listA.length !== listB.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < listA.length; ++i) {
|
||||
const attrA = listA[i];
|
||||
const implA = idlUtils.implForWrapper(attrA);
|
||||
|
||||
if (!listB.some(attrB => equalsA(attrB))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function equalsA(attrB) {
|
||||
const implB = idlUtils.implForWrapper(attrB);
|
||||
|
||||
return implA._namespace === implB._namespace && implA._localName === implB._localName &&
|
||||
implA._value === implB._value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.hasAttributes = function (element) {
|
||||
// Needed by https://dom.spec.whatwg.org/#dom-element-hasattributes
|
||||
|
||||
return element._attributes[INTERNAL].attributeList.length > 0;
|
||||
};
|
||||
82
node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js
generated
vendored
Normal file
82
node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
|
||||
exports.implementation = class AttrImpl {
|
||||
constructor(_, privateData) {
|
||||
this._namespace = privateData.namespace !== undefined ? privateData.namespace : null;
|
||||
this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null;
|
||||
this._localName = privateData.localName;
|
||||
this._value = privateData.value !== undefined ? privateData.value : "";
|
||||
this._element = privateData.element !== undefined ? privateData.element : null;
|
||||
|
||||
this.specified = true;
|
||||
}
|
||||
|
||||
get namespaceURI() {
|
||||
return this._namespace;
|
||||
}
|
||||
|
||||
get prefix() {
|
||||
return this._namespacePrefix;
|
||||
}
|
||||
|
||||
get localName() {
|
||||
return this._localName;
|
||||
}
|
||||
|
||||
get name() {
|
||||
return exports.getAttrImplQualifiedName(this);
|
||||
}
|
||||
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
set value(v) {
|
||||
if (this._element === null) {
|
||||
this._value = v;
|
||||
} else {
|
||||
exports.changeAttributeImpl(this._element, this, v);
|
||||
}
|
||||
}
|
||||
|
||||
// Delegate to value
|
||||
get nodeValue() {
|
||||
return this.value;
|
||||
}
|
||||
set nodeValue(v) {
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
// Delegate to value
|
||||
get textContent() {
|
||||
return this.value;
|
||||
}
|
||||
set textContent(v) {
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
get ownerElement() {
|
||||
return this._element;
|
||||
}
|
||||
};
|
||||
|
||||
exports.changeAttributeImpl = function (element, attributeImpl, value) {
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change
|
||||
|
||||
// TODO mutation observer stuff
|
||||
|
||||
const oldValue = attributeImpl._value;
|
||||
attributeImpl._value = value;
|
||||
|
||||
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
|
||||
element._attrModified(exports.getAttrImplQualifiedName(attributeImpl), value, oldValue);
|
||||
};
|
||||
|
||||
exports.getAttrImplQualifiedName = function (attributeImpl) {
|
||||
// https://dom.spec.whatwg.org/#concept-attribute-qualified-name
|
||||
|
||||
if (attributeImpl._namespacePrefix === null) {
|
||||
return attributeImpl._localName;
|
||||
}
|
||||
|
||||
return attributeImpl._namespacePrefix + ":" + attributeImpl._localName;
|
||||
};
|
||||
7
node_modules/jsdom/lib/jsdom/living/blob-symbols.js
generated
vendored
Normal file
7
node_modules/jsdom/lib/jsdom/living/blob-symbols.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
exports.buffer = Symbol("buffer");
|
||||
exports.type = Symbol("type");
|
||||
exports.lastModified = Symbol("lastModified");
|
||||
exports.closed = Symbol("closed");
|
||||
|
||||
76
node_modules/jsdom/lib/jsdom/living/blob.js
generated
vendored
Normal file
76
node_modules/jsdom/lib/jsdom/living/blob.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
const blobSymbols = require("./blob-symbols");
|
||||
|
||||
class Blob {
|
||||
constructor() {
|
||||
if (!(this instanceof Blob)) {
|
||||
throw new TypeError("DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
const parts = arguments[0];
|
||||
const properties = arguments[1];
|
||||
if (arguments.length > 0) {
|
||||
if (!parts || typeof parts !== "object" || parts instanceof Date || parts instanceof RegExp) {
|
||||
throw new TypeError("Blob parts must be objects that are not Dates or RegExps");
|
||||
}
|
||||
}
|
||||
|
||||
const buffers = [];
|
||||
|
||||
if (parts) {
|
||||
const l = Number(parts.length);
|
||||
for (let i = 0; i < l; i++) {
|
||||
const part = parts[i];
|
||||
let buffer;
|
||||
if (part instanceof ArrayBuffer) {
|
||||
buffer = new Buffer(new Uint8Array(part));
|
||||
} else if (part instanceof Blob) {
|
||||
buffer = part[blobSymbols.buffer];
|
||||
} else if (ArrayBuffer.isView(part)) {
|
||||
buffer = new Buffer(new Uint8Array(part.buffer, part.byteOffset, part.byteLength));
|
||||
} else {
|
||||
buffer = new Buffer(typeof part === "string" ? part : String(part));
|
||||
}
|
||||
buffers.push(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
this[blobSymbols.buffer] = Buffer.concat(buffers);
|
||||
|
||||
this[blobSymbols.type] = properties && properties.type ? String(properties.type).toLowerCase() : "";
|
||||
if (!this[blobSymbols.type].match(/^ *[a-z0-9-]+(?:\/[a-z0-9-]+)? *(; *charset *= *[a-z0-9-]+ *)?$/)) {
|
||||
this[blobSymbols.type] = "";
|
||||
}
|
||||
this[blobSymbols.lastModified] = properties && properties.lastModified ? properties.lastModified : null;
|
||||
this[blobSymbols.closed] = false;
|
||||
}
|
||||
get size() {
|
||||
return this[blobSymbols.buffer].length;
|
||||
}
|
||||
get type() {
|
||||
return this[blobSymbols.type];
|
||||
}
|
||||
get lastModified() {
|
||||
return this[blobSymbols.lastModified];
|
||||
}
|
||||
slice() {
|
||||
const buffer = this[blobSymbols.buffer];
|
||||
const slicedBuffer = buffer.slice(
|
||||
arguments[0] || 0,
|
||||
arguments[1] || this.size
|
||||
);
|
||||
const blob = new Blob([], { type: arguments[2] || this.type });
|
||||
blob[blobSymbols.buffer] = slicedBuffer;
|
||||
return blob;
|
||||
}
|
||||
close() {
|
||||
this[blobSymbols.closed] = true;
|
||||
}
|
||||
toString() {
|
||||
return "[object Blob]";
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (core) {
|
||||
core.Blob = Blob;
|
||||
};
|
||||
113
node_modules/jsdom/lib/jsdom/living/character-data.js
generated
vendored
Normal file
113
node_modules/jsdom/lib/jsdom/living/character-data.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
const inheritFrom = require("../utils").inheritFrom;
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
|
||||
module.exports = function (core) {
|
||||
core.CharacterData = function CharacterData(ownerDocument, data) {
|
||||
core.Node.call(this, ownerDocument);
|
||||
|
||||
this._data = data;
|
||||
};
|
||||
|
||||
inheritFrom(core.Node, core.CharacterData, {
|
||||
get data() {
|
||||
return this._data;
|
||||
},
|
||||
set data(data) {
|
||||
if (data === null) {
|
||||
data = "";
|
||||
}
|
||||
data = String(data);
|
||||
|
||||
this._setData(data);
|
||||
},
|
||||
|
||||
get length() {
|
||||
return this._data.length;
|
||||
},
|
||||
|
||||
substringData(offset, count) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to CharacterData.prototype.substringData");
|
||||
}
|
||||
offset >>>= 0;
|
||||
count >>>= 0;
|
||||
|
||||
const length = this.length;
|
||||
|
||||
if (offset > length) {
|
||||
throw new core.DOMException(core.DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
|
||||
if (offset + count > length) {
|
||||
return this._data.substring(offset);
|
||||
}
|
||||
|
||||
return this._data.substring(offset, offset + count);
|
||||
},
|
||||
|
||||
appendData(data) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to CharacterData.prototype.appendData");
|
||||
}
|
||||
|
||||
this.replaceData(this.length, 0, data);
|
||||
},
|
||||
|
||||
insertData(offset, data) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to CharacterData.prototype.insertData");
|
||||
}
|
||||
|
||||
this.replaceData(offset, 0, data);
|
||||
},
|
||||
|
||||
deleteData(offset, count) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to CharacterData.prototype.deleteData");
|
||||
}
|
||||
|
||||
this.replaceData(offset, count, "");
|
||||
},
|
||||
|
||||
replaceData(offset, count, data) {
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError("Not enough arguments to CharacterData.prototype.replaceData");
|
||||
}
|
||||
offset >>>= 0;
|
||||
count >>>= 0;
|
||||
data = String(data);
|
||||
|
||||
const length = this.length;
|
||||
|
||||
if (offset > length) {
|
||||
throw new core.DOMException(core.DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
|
||||
if (offset + count > length) {
|
||||
count = length - offset;
|
||||
}
|
||||
|
||||
const start = this._data.substring(0, offset);
|
||||
const end = this._data.substring(offset + count);
|
||||
|
||||
this._setData(start + data + end);
|
||||
|
||||
// TODO: range stuff
|
||||
},
|
||||
|
||||
_setData(newData) {
|
||||
// TODO: remove this once we no longer rely on mutation events internally, since they are nonstandard
|
||||
const oldData = this._data;
|
||||
this._data = newData;
|
||||
|
||||
if (this._ownerDocument &&
|
||||
domSymbolTree.parent(this) &&
|
||||
this._ownerDocument.implementation._hasFeature("MutationEvents")) {
|
||||
const ev = this._ownerDocument.createEvent("MutationEvents");
|
||||
ev.initMutationEvent("DOMCharacterDataModified", true, false, this, oldData, newData, null, null);
|
||||
this.dispatchEvent(ev);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
14
node_modules/jsdom/lib/jsdom/living/comment.js
generated
vendored
Normal file
14
node_modules/jsdom/lib/jsdom/living/comment.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
const inheritFrom = require("../utils").inheritFrom;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
module.exports = function (core) {
|
||||
// TODO: constructor should not take ownerDocument
|
||||
core.Comment = function Comment(ownerDocument, data) {
|
||||
core.CharacterData.call(this, ownerDocument, data);
|
||||
};
|
||||
|
||||
inheritFrom(core.CharacterData, core.Comment, {
|
||||
nodeType: NODE_TYPE.COMMENT_NODE // TODO should be on prototype, not here
|
||||
});
|
||||
};
|
||||
47
node_modules/jsdom/lib/jsdom/living/document-type.js
generated
vendored
Normal file
47
node_modules/jsdom/lib/jsdom/living/document-type.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
const privates = Symbol("DocumentType internal slots");
|
||||
|
||||
module.exports = core => {
|
||||
core.DocumentType = class DocumentType extends core.Node {
|
||||
constructor(secret, ownerDocument, name, publicId, systemId) {
|
||||
if (secret !== privates) {
|
||||
throw new TypeError("Invalid constructor");
|
||||
}
|
||||
|
||||
super(ownerDocument);
|
||||
this[privates] = { name, publicId, systemId };
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this[privates].name;
|
||||
}
|
||||
get publicId() {
|
||||
return this[privates].publicId;
|
||||
}
|
||||
get systemId() {
|
||||
return this[privates].systemId;
|
||||
}
|
||||
};
|
||||
|
||||
core.DocumentType.prototype.nodeType = NODE_TYPE.DOCUMENT_TYPE_NODE; // TODO should be on Node, not here
|
||||
};
|
||||
|
||||
module.exports.create = (core, ownerDocument, name, publicId, systemId) => {
|
||||
return new core.DocumentType(privates, ownerDocument, name, publicId, systemId);
|
||||
};
|
||||
|
||||
module.exports.clone = (core, otherDoctype) => {
|
||||
return new core.DocumentType(
|
||||
privates,
|
||||
otherDoctype._ownerDocument,
|
||||
otherDoctype[privates].name,
|
||||
otherDoctype[privates].publicId,
|
||||
otherDoctype[privates].systemId
|
||||
);
|
||||
};
|
||||
|
||||
module.exports.getPrivates = doctype => {
|
||||
return doctype[privates];
|
||||
};
|
||||
162
node_modules/jsdom/lib/jsdom/living/document.js
generated
vendored
Normal file
162
node_modules/jsdom/lib/jsdom/living/document.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
"use strict";
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
const validateNames = require("./helpers/validate-names");
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const defineSetter = require("../utils").defineSetter;
|
||||
const memoizeQuery = require("../utils").memoizeQuery;
|
||||
const generatedAttr = require("./generated/Attr");
|
||||
const clone = require("./node").clone;
|
||||
const listOfElementsWithClassNames = require("./node").listOfElementsWithClassNames;
|
||||
const validateName = require("./helpers/validate-names").name;
|
||||
const validateAndExtract = require("./helpers/validate-names").validateAndExtract;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
module.exports = function (core) {
|
||||
core.Document.prototype.createProcessingInstruction = function (target, data) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.createProcessingInstruction");
|
||||
}
|
||||
target = String(target);
|
||||
data = String(data);
|
||||
|
||||
validateNames.name(target);
|
||||
|
||||
if (data.indexOf("?>") !== -1) {
|
||||
throw new core.DOMException(core.DOMException.INVALID_CHARACTER_ERR,
|
||||
"Processing instruction data cannot contain the string \"?>\"");
|
||||
}
|
||||
|
||||
return new core.ProcessingInstruction(this._ownerDocument, target, data);
|
||||
};
|
||||
|
||||
core.Document.prototype.createTextNode = function (data) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.createTextNode");
|
||||
}
|
||||
data = String(data);
|
||||
|
||||
return new core.Text(this, data);
|
||||
};
|
||||
|
||||
core.Document.prototype.createComment = function (data) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.createComment");
|
||||
}
|
||||
data = String(data);
|
||||
|
||||
return new core.Comment(this, data);
|
||||
};
|
||||
|
||||
core.Document.prototype.createElement = function (localName) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.createElement");
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
validateName(localName);
|
||||
if (this._parsingMode === "html") {
|
||||
localName = localName.toLowerCase();
|
||||
}
|
||||
|
||||
const element = this._createElementWithCorrectElementInterface(localName, "http://www.w3.org/1999/xhtml");
|
||||
element._namespaceURI = "http://www.w3.org/1999/xhtml";
|
||||
element._localName = localName;
|
||||
element._ownerDocument = this;
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
core.Document.prototype.createElementNS = function (namespace, qualifiedName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.createElementNS");
|
||||
}
|
||||
namespace = namespace !== null ? String(namespace) : namespace;
|
||||
qualifiedName = String(qualifiedName);
|
||||
|
||||
const extracted = validateAndExtract(namespace, qualifiedName);
|
||||
|
||||
const element = this._createElementWithCorrectElementInterface(extracted.localName, extracted.namespace);
|
||||
element._namespaceURI = extracted.namespace;
|
||||
element._prefix = extracted.prefix;
|
||||
element._localName = extracted.localName;
|
||||
element._ownerDocument = this;
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
core.Document.prototype.createDocumentFragment = function () {
|
||||
return new core.DocumentFragment(this);
|
||||
};
|
||||
|
||||
core.Document.prototype.createAttribute = function (localName) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("not enough arguments to Document.prototype.createAttribute");
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
validateName(localName);
|
||||
|
||||
if (this._parsingMode === "html") {
|
||||
localName = localName.toLowerCase();
|
||||
}
|
||||
|
||||
return generatedAttr.create([], { localName });
|
||||
};
|
||||
|
||||
core.Document.prototype.createAttributeNS = function (namespace, name) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("not enough arguments to Document.prototype.createAttributeNS");
|
||||
}
|
||||
if (namespace === undefined) {
|
||||
namespace = null;
|
||||
}
|
||||
namespace = namespace !== null ? String(namespace) : namespace;
|
||||
name = String(name);
|
||||
|
||||
const extracted = validateAndExtract(namespace, name);
|
||||
return generatedAttr.create([], {
|
||||
namespace: extracted.namespace,
|
||||
namespacePrefix: extracted.prefix,
|
||||
localName: extracted.localName
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
core.Document.prototype.importNode = function (node, deep) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.createElement");
|
||||
}
|
||||
if (!("_ownerDocument" in node)) {
|
||||
throw new TypeError("First argument to importNode must be a Node");
|
||||
}
|
||||
deep = Boolean(deep);
|
||||
|
||||
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
|
||||
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Cannot import a document node");
|
||||
}
|
||||
|
||||
return clone(core, node, this, deep);
|
||||
};
|
||||
|
||||
core.Document.prototype.getElementsByClassName = memoizeQuery(function getElementsByClassName(classNames) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Document.prototype.getElementsByClassName");
|
||||
}
|
||||
|
||||
classNames = String(classNames);
|
||||
return listOfElementsWithClassNames(classNames, this);
|
||||
});
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#dom-document-cookie
|
||||
defineGetter(core.Document.prototype, "cookie", function () {
|
||||
return this._cookieJar.getCookieStringSync(this._URL, { http: false });
|
||||
});
|
||||
|
||||
defineSetter(core.Document.prototype, "cookie", function (cookieStr) {
|
||||
cookieStr = String(cookieStr);
|
||||
this._cookieJar.setCookieSync(cookieStr, this._URL, {
|
||||
http: false,
|
||||
ignoreError: true
|
||||
});
|
||||
});
|
||||
};
|
||||
90
node_modules/jsdom/lib/jsdom/living/dom-implementation.js
generated
vendored
Normal file
90
node_modules/jsdom/lib/jsdom/living/dom-implementation.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
const validateNames = require("./helpers/validate-names");
|
||||
const createDocumentTypeInternal = require("./document-type").create;
|
||||
|
||||
module.exports = function (core) {
|
||||
core.DOMImplementation.prototype.hasFeature = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
core.DOMImplementation.prototype.createDocumentType = function (qualifiedName, publicId, systemId) {
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError("Expected 3 arguments to createDocumentType");
|
||||
}
|
||||
|
||||
qualifiedName = String(qualifiedName);
|
||||
publicId = String(publicId);
|
||||
systemId = String(systemId);
|
||||
|
||||
validateNames.qname(qualifiedName);
|
||||
|
||||
return createDocumentTypeInternal(core, this._ownerDocument, qualifiedName, publicId, systemId);
|
||||
};
|
||||
|
||||
core.DOMImplementation.prototype.createDocument = function (namespace, qualifiedName, doctype) {
|
||||
namespace = namespace !== null ? String(namespace) : namespace;
|
||||
qualifiedName = qualifiedName === null ? "" : String(qualifiedName);
|
||||
if (doctype === undefined) {
|
||||
doctype = null;
|
||||
}
|
||||
|
||||
const document = new core.Document({ parsingMode: "xml" });
|
||||
|
||||
let element = null;
|
||||
if (qualifiedName !== "") {
|
||||
element = document.createElementNS(namespace, qualifiedName);
|
||||
}
|
||||
|
||||
if (doctype !== null) {
|
||||
document.appendChild(doctype);
|
||||
}
|
||||
|
||||
if (element !== null) {
|
||||
document.appendChild(element);
|
||||
}
|
||||
|
||||
return document;
|
||||
};
|
||||
|
||||
core.DOMImplementation.prototype.createHTMLDocument = function (title) {
|
||||
// Let doc be a new document that is an HTML document.
|
||||
// Set doc's content type to "text/html".
|
||||
const document = new core.HTMLDocument({ parsingMode: "html" });
|
||||
|
||||
// Create a doctype, with "html" as its name and with its node document set
|
||||
// to doc. Append the newly created node to doc.
|
||||
const doctype = createDocumentTypeInternal(core, this, "html", "", "");
|
||||
document.appendChild(doctype);
|
||||
|
||||
// Create an html element in the HTML namespace, and append it to doc.
|
||||
const htmlElement = document.createElementNS("http://www.w3.org/1999/xhtml", "html");
|
||||
document.appendChild(htmlElement);
|
||||
|
||||
// Create a head element in the HTML namespace, and append it to the html
|
||||
// element created in the previous step.
|
||||
const headElement = document.createElement("head");
|
||||
htmlElement.appendChild(headElement);
|
||||
|
||||
// If the title argument is not omitted:
|
||||
if (title !== undefined) {
|
||||
// Create a title element in the HTML namespace, and append it to the head
|
||||
// element created in the previous step.
|
||||
const titleElement = document.createElement("title");
|
||||
headElement.appendChild(titleElement);
|
||||
|
||||
// Create a Text node, set its data to title (which could be the empty
|
||||
// string), and append it to the title element created in the previous step.
|
||||
titleElement.appendChild(document.createTextNode(title));
|
||||
}
|
||||
|
||||
// Create a body element in the HTML namespace, and append it to the html
|
||||
// element created in the earlier step.
|
||||
htmlElement.appendChild(document.createElement("body"));
|
||||
|
||||
// doc's origin is an alias to the origin of the context object's associated
|
||||
// document, and doc's effective script origin is an alias to the effective
|
||||
// script origin of the context object's associated document.
|
||||
|
||||
return document;
|
||||
};
|
||||
};
|
||||
193
node_modules/jsdom/lib/jsdom/living/dom-token-list.js
generated
vendored
Normal file
193
node_modules/jsdom/lib/jsdom/living/dom-token-list.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
"use strict";
|
||||
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
const orderedSetParser = require("./helpers/ordered-set-parser");
|
||||
|
||||
// https://dom.spec.whatwg.org/#domtokenlist
|
||||
|
||||
const INTERNAL = Symbol("DOMTokenList internal");
|
||||
|
||||
class DOMTokenList {
|
||||
constructor() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
item(index) {
|
||||
const length = this.length;
|
||||
return length <= index || index < 0 ? null : this[index];
|
||||
}
|
||||
|
||||
contains(token) {
|
||||
token = String(token);
|
||||
|
||||
validateToken(token);
|
||||
return indexOf(this, token) !== -1;
|
||||
}
|
||||
|
||||
add(/* tokens... */) {
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
const token = String(arguments[i]);
|
||||
validateToken(token);
|
||||
|
||||
if (indexOf(this, token) === -1) {
|
||||
push(this, token);
|
||||
}
|
||||
}
|
||||
update(this);
|
||||
}
|
||||
|
||||
remove(/* tokens... */) {
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
const token = String(arguments[i]);
|
||||
validateToken(token);
|
||||
|
||||
const index = indexOf(this, token);
|
||||
if (index !== -1) {
|
||||
spliceLite(this, index, 1);
|
||||
}
|
||||
}
|
||||
update(this);
|
||||
}
|
||||
|
||||
// if force is true, this behaves like add
|
||||
// if force is false, this behaves like remove
|
||||
// if force is undefined, this behaves as one would expect toggle to
|
||||
// always returns whether classList contains token after toggling
|
||||
toggle(token, force) {
|
||||
token = String(token);
|
||||
force = force === undefined ? undefined : Boolean(force);
|
||||
|
||||
validateToken(token);
|
||||
|
||||
const index = indexOf(this, token);
|
||||
|
||||
if (index !== -1) {
|
||||
if (force === false || force === undefined) {
|
||||
spliceLite(this, index, 1);
|
||||
update(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (force === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
push(this, token);
|
||||
update(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
get length() {
|
||||
return this[INTERNAL].tokens.length;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this[INTERNAL].tokens.join(" ");
|
||||
}
|
||||
}
|
||||
|
||||
function validateToken(token) {
|
||||
if (token === "") {
|
||||
throw new DOMException(DOMException.SYNTAX_ERR, "The token provided must not be empty.");
|
||||
}
|
||||
|
||||
if (/\s/.test(token)) {
|
||||
const whitespaceMsg = "The token provided contains HTML space characters, which are not valid in tokens.";
|
||||
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, whitespaceMsg);
|
||||
}
|
||||
}
|
||||
|
||||
function update(list) {
|
||||
const attribute = list[INTERNAL].attribute;
|
||||
if (attribute !== undefined) {
|
||||
list[INTERNAL].element.setAttribute(attribute, list.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// calls indexOf on internal array
|
||||
function indexOf(dtl, token) {
|
||||
return dtl[INTERNAL].tokens.indexOf(token);
|
||||
}
|
||||
|
||||
// calls push on internal array, then manually adds indexed property to dtl
|
||||
function push(dtl, token) {
|
||||
const len = dtl[INTERNAL].tokens.push(token);
|
||||
dtl[len - 1] = token;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
// calls splice on internal array then rewrites indexed properties of dtl
|
||||
// does not allow items to be added, only removed, so splice-lite
|
||||
function spliceLite(dtl, start, deleteCount) {
|
||||
const tokens = dtl[INTERNAL].tokens;
|
||||
const removedTokens = tokens.splice(start, deleteCount);
|
||||
|
||||
// remove indexed properties from list
|
||||
const re = /^\d+$/;
|
||||
|
||||
for (const prop in dtl) {
|
||||
if (re.test(prop)) {
|
||||
delete dtl[prop];
|
||||
}
|
||||
}
|
||||
|
||||
// copy indexed properties from internal array
|
||||
const len = tokens.length;
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
dtl[i] = tokens[i];
|
||||
}
|
||||
|
||||
return removedTokens;
|
||||
}
|
||||
|
||||
exports.DOMTokenList = DOMTokenList;
|
||||
|
||||
// set dom token list without running update steps
|
||||
exports.reset = function resetDOMTokenList(list, value) {
|
||||
const tokens = list[INTERNAL].tokens;
|
||||
|
||||
spliceLite(list, 0, tokens.length);
|
||||
value = (value || "").trim();
|
||||
|
||||
if (value !== "") {
|
||||
for (const token of orderedSetParser(value)) {
|
||||
push(list, token);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.create = function createDOMTokenList(element, attribute) {
|
||||
const list = Object.create(DOMTokenList.prototype);
|
||||
|
||||
list[INTERNAL] = {
|
||||
element,
|
||||
attribute,
|
||||
tokens: []
|
||||
};
|
||||
|
||||
exports.reset(list, element.getAttribute(attribute));
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
exports.contains = function domTokenListContains(list, token, options) {
|
||||
const caseInsensitive = options && options.caseInsensitive;
|
||||
|
||||
if (!caseInsensitive) {
|
||||
return indexOf(list, token) !== -1;
|
||||
}
|
||||
|
||||
const tokens = list[INTERNAL].tokens;
|
||||
const lowerToken = token.toLowerCase();
|
||||
for (let i = 0; i < tokens.length; ++i) {
|
||||
if (tokens[i].toLowerCase() === lowerToken) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
215
node_modules/jsdom/lib/jsdom/living/element.js
generated
vendored
Normal file
215
node_modules/jsdom/lib/jsdom/living/element.js
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
"use strict";
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const memoizeQuery = require("../utils").memoizeQuery;
|
||||
const attributes = require("./attributes");
|
||||
const attrGenerated = require("./generated/Attr");
|
||||
const createDOMTokenList = require("./dom-token-list").create;
|
||||
const listOfElementsWithClassNames = require("./node").listOfElementsWithClassNames;
|
||||
const validateNames = require("./helpers/validate-names");
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
|
||||
module.exports = function (core) {
|
||||
defineGetter(core.Element, "attributes", function () {
|
||||
return this._attributes;
|
||||
});
|
||||
|
||||
defineGetter(core.Element.prototype, "classList", function () {
|
||||
if (this._classList === undefined) {
|
||||
this._classList = createDOMTokenList(this, "class");
|
||||
}
|
||||
return this._classList;
|
||||
});
|
||||
|
||||
core.Element.prototype.hasAttributes = function hasAttributes() {
|
||||
return attributes.hasAttributes(this);
|
||||
};
|
||||
|
||||
core.Element.prototype.getAttribute = function getAttribute(name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.getAttribute");
|
||||
}
|
||||
name = String(name);
|
||||
|
||||
return attributes.getAttributeValue(this, name);
|
||||
};
|
||||
|
||||
core.Element.prototype.getAttributeNS = function getAttributeNS(namespace, localName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.getAttributeNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
return attributes.getAttributeValueByNameNS(this, namespace, localName);
|
||||
};
|
||||
|
||||
core.Element.prototype.setAttribute = function setAttribute(name, value) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.setAttribute");
|
||||
}
|
||||
name = String(name);
|
||||
value = String(value);
|
||||
|
||||
validateNames.name(name);
|
||||
|
||||
if (this._namespaceURI === "http://www.w3.org/1999/xhtml" && this._ownerDocument._parsingMode === "html") {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
const attribute = attributes.getAttributeByName(this, name);
|
||||
|
||||
if (attribute === null) {
|
||||
const newAttr = attrGenerated.create([], { localName: name, value });
|
||||
attributes.appendAttribute(this, newAttr);
|
||||
return;
|
||||
}
|
||||
|
||||
attributes.changeAttribute(this, attribute, value);
|
||||
};
|
||||
|
||||
core.Element.prototype.setAttributeNS = function setAttributeNS(namespace, name, value) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.setAttributeNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
name = String(name);
|
||||
value = String(value);
|
||||
|
||||
const extracted = validateNames.validateAndExtract(namespace, name);
|
||||
|
||||
attributes.setAttributeValue(this, extracted.localName, value, extracted.prefix, extracted.namespace);
|
||||
};
|
||||
|
||||
core.Element.prototype.removeAttribute = function removeAttribute(name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.removeAttribute");
|
||||
}
|
||||
name = String(name);
|
||||
|
||||
attributes.removeAttributeByName(this, name);
|
||||
};
|
||||
|
||||
core.Element.prototype.removeAttributeNS = function removeAttributeNS(namespace, localName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.removeAttributeNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
attributes.removeAttributeByNameNS(this, namespace, localName);
|
||||
};
|
||||
|
||||
core.Element.prototype.hasAttribute = function hasAttribute(name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.hasAttribute");
|
||||
}
|
||||
name = String(name);
|
||||
|
||||
if (this._namespaceURI === "http://www.w3.org/1999/xhtml" && this._ownerDocument._parsingMode === "html") {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
return attributes.hasAttributeByName(this, name);
|
||||
};
|
||||
|
||||
core.Element.prototype.hasAttributeNS = function hasAttributeNS(namespace, localName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.hasAttributeNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
if (namespace === "") {
|
||||
namespace = null;
|
||||
}
|
||||
|
||||
return attributes.hasAttributeByNameNS(this, namespace, localName);
|
||||
};
|
||||
|
||||
core.Element.prototype.getAttributeNode = function getAttributeNode(name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.getAttributeNode");
|
||||
}
|
||||
name = String(name);
|
||||
|
||||
return attributes.getAttributeByName(this, name);
|
||||
};
|
||||
|
||||
core.Element.prototype.getAttributeNodeNS = function getAttributeNodeNS(namespace, localName) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.getAttributeNodeNS");
|
||||
}
|
||||
if (namespace === undefined || namespace === null) {
|
||||
namespace = null;
|
||||
} else {
|
||||
namespace = String(namespace);
|
||||
}
|
||||
localName = String(localName);
|
||||
|
||||
return attributes.getAttributeByNameNS(this, namespace, localName);
|
||||
};
|
||||
|
||||
core.Element.prototype.setAttributeNode = function setAttributeNode(attr) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.setAttributeNode");
|
||||
}
|
||||
if (!attrGenerated.is(attr)) {
|
||||
throw new TypeError("First argument to Element.prototype.setAttributeNode must be an Attr");
|
||||
}
|
||||
|
||||
return attributes.setAttribute(this, attr);
|
||||
};
|
||||
|
||||
core.Element.prototype.setAttributeNodeNS = function setAttributeNodeNS(attr) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.setAttributeNodeNS");
|
||||
}
|
||||
if (!attrGenerated.is(attr)) {
|
||||
throw new TypeError("First argument to Element.prototype.setAttributeNodeNS must be an Attr");
|
||||
}
|
||||
|
||||
return attributes.setAttribute(this, attr);
|
||||
};
|
||||
|
||||
core.Element.prototype.removeAttributeNode = function removeAttributeNode(attr) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.setAttributeNode");
|
||||
}
|
||||
if (!attrGenerated.is(attr)) {
|
||||
throw new TypeError("First argument to Element.prototype.removeAttributeNode must be an Attr");
|
||||
}
|
||||
|
||||
if (!attributes.hasAttribute(this, attr)) {
|
||||
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
|
||||
}
|
||||
|
||||
attributes.removeAttribute(this, attr);
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
core.Element.prototype.getElementsByClassName = memoizeQuery(function getElementsByClassName(classNames) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Not enough arguments to Element.prototype.getElementsByClassName");
|
||||
}
|
||||
|
||||
classNames = String(classNames);
|
||||
return listOfElementsWithClassNames(classNames, this);
|
||||
});
|
||||
};
|
||||
18
node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js
generated
vendored
Normal file
18
node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class CustomEventImpl extends EventImpl {
|
||||
initCustomEvent(type, bubbles, cancelable, detail) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initEvent(type, bubbles, cancelable);
|
||||
this.detail = detail;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: CustomEventImpl
|
||||
};
|
||||
11
node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js
generated
vendored
Normal file
11
node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class ErrorEventImpl extends EventImpl {
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: ErrorEventImpl
|
||||
};
|
||||
87
node_modules/jsdom/lib/jsdom/living/events/Event-impl.js
generated
vendored
Normal file
87
node_modules/jsdom/lib/jsdom/living/events/Event-impl.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
|
||||
const EventInit = require("../generated/EventInit");
|
||||
|
||||
class EventImpl {
|
||||
constructor(args, privateData) {
|
||||
const type = args[0]; // TODO: Replace with destructuring
|
||||
const eventInitDict = args[1] || EventInit.convert(undefined);
|
||||
|
||||
if (type) {
|
||||
this.type = type;
|
||||
this._initializedFlag = true;
|
||||
} else {
|
||||
this.type = "";
|
||||
this._initializedFlag = false;
|
||||
}
|
||||
|
||||
const wrapper = privateData.wrapper;
|
||||
for (const key in eventInitDict) {
|
||||
if (key in wrapper) {
|
||||
this[key] = eventInitDict[key];
|
||||
}
|
||||
}
|
||||
|
||||
this.target = null;
|
||||
this.currentTarget = null;
|
||||
this.eventPhase = 0;
|
||||
|
||||
this._stopPropagationFlag = false;
|
||||
this._stopImmediatePropagationFlag = false;
|
||||
this._canceledFlag = false;
|
||||
this._dispatchFlag = false;
|
||||
|
||||
this.isTrusted = false;
|
||||
this.timeStamp = Date.now();
|
||||
}
|
||||
|
||||
get defaultPrevented() {
|
||||
return this._canceledFlag;
|
||||
}
|
||||
|
||||
stopPropagation() {
|
||||
this._stopPropagationFlag = true;
|
||||
}
|
||||
|
||||
stopImmediatePropagation() {
|
||||
this._stopPropagationFlag = true;
|
||||
this._stopImmediatePropagation = true;
|
||||
}
|
||||
|
||||
preventDefault() {
|
||||
if (this.cancelable) {
|
||||
this._canceledFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
_initialize(type, bubbles, cancelable) {
|
||||
if (type) {
|
||||
this.type = type;
|
||||
this._initializedFlag = true;
|
||||
} else {
|
||||
this.type = "";
|
||||
this._initializedFlag = false;
|
||||
}
|
||||
|
||||
this._stopPropagationFlag = false;
|
||||
this._stopImmediatePropagationFlag = false;
|
||||
this._canceledFlag = false;
|
||||
|
||||
this.isTrusted = false;
|
||||
this.target = null;
|
||||
this.bubbles = bubbles;
|
||||
this.cancelable = cancelable;
|
||||
}
|
||||
|
||||
initEvent(type, bubbles, cancelable) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._initialize(type, bubbles, cancelable);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: EventImpl
|
||||
};
|
||||
244
node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js
generated
vendored
Normal file
244
node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
"use strict";
|
||||
const DOMException = require("../../web-idl/DOMException");
|
||||
const reportException = require("../helpers/runtime-script-errors");
|
||||
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
|
||||
const idlUtils = require("../generated/utils");
|
||||
|
||||
const Event = require("../generated/Event").interface;
|
||||
|
||||
class EventTargetImpl {
|
||||
constructor() {
|
||||
this._eventListeners = Object.create(null);
|
||||
}
|
||||
|
||||
addEventListener(type, callback, capture) {
|
||||
// webidl2js currently can't handle neither optional arguments nor callback interfaces
|
||||
if (callback === undefined || callback === null) {
|
||||
callback = null;
|
||||
} else if (typeof callback === "object") {
|
||||
callback = callback.handleEvent;
|
||||
} else if (typeof callback !== "function") {
|
||||
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
|
||||
}
|
||||
|
||||
if (callback === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._eventListeners[type]) {
|
||||
this._eventListeners[type] = [];
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._eventListeners[type].length; ++i) {
|
||||
const listener = this._eventListeners[type][i];
|
||||
if (listener.capture === capture && listener.callback === callback) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._eventListeners[type].push({
|
||||
callback,
|
||||
capture
|
||||
});
|
||||
}
|
||||
|
||||
removeEventListener(type, callback, capture) {
|
||||
if (callback === undefined || callback === null) {
|
||||
callback = null;
|
||||
} else if (typeof callback === "object") {
|
||||
callback = callback.handleEvent;
|
||||
} else if (typeof callback !== "function") {
|
||||
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
|
||||
}
|
||||
|
||||
if (callback === null) {
|
||||
// Optimization, not in the spec.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._eventListeners[type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._eventListeners[type].length; ++i) {
|
||||
const listener = this._eventListeners[type][i];
|
||||
if (listener.callback === callback && listener.capture === capture) {
|
||||
this._eventListeners[type].splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispatchEvent(event) {
|
||||
if (!(event instanceof Event)) {
|
||||
throw new TypeError("Argument to dispatchEvent must be an Event");
|
||||
}
|
||||
|
||||
const eventImpl = idlUtils.implForWrapper(event);
|
||||
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
|
||||
throw new DOMException(DOMException.INVALID_STATE_ERR, "Tried to dispatch an uninitialized event");
|
||||
}
|
||||
if (event.eventPhase !== event.NONE) {
|
||||
throw new DOMException(DOMException.INVALID_STATE_ERR, "Tried to dispatch a dispatching event");
|
||||
}
|
||||
|
||||
eventImpl.isTrusted = false;
|
||||
|
||||
return this._dispatch(event);
|
||||
}
|
||||
|
||||
_dispatch(event, targetOverride) {
|
||||
const eventImpl = idlUtils.implForWrapper(event);
|
||||
eventImpl._dispatchFlag = true;
|
||||
eventImpl.target = targetOverride || idlUtils.wrapperForImpl(this);
|
||||
|
||||
const eventPath = [];
|
||||
let targetParent = domSymbolTree.parent(eventImpl.target);
|
||||
let target = eventImpl.target;
|
||||
while (targetParent) {
|
||||
eventPath.push(targetParent);
|
||||
target = targetParent;
|
||||
targetParent = domSymbolTree.parent(targetParent);
|
||||
}
|
||||
if (event.type !== "load" && target._defaultView) { // https://html.spec.whatwg.org/#events-and-the-window-object
|
||||
eventPath.push(target._defaultView);
|
||||
}
|
||||
|
||||
eventImpl.eventPhase = Event.CAPTURING_PHASE;
|
||||
for (let i = eventPath.length - 1; i >= 0; --i) {
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
break;
|
||||
}
|
||||
|
||||
const object = eventPath[i];
|
||||
const objectImpl = idlUtils.implForWrapper(object);
|
||||
const eventListeners = objectImpl._eventListeners[event.type];
|
||||
invokeEventListeners(eventListeners, object, event);
|
||||
}
|
||||
|
||||
eventImpl.eventPhase = Event.AT_TARGET;
|
||||
|
||||
if (!eventImpl._stopPropagationFlag) {
|
||||
invokeInlineListeners(eventImpl.target, event);
|
||||
|
||||
if (this._eventListeners[event.type]) {
|
||||
const eventListeners = this._eventListeners[event.type];
|
||||
invokeEventListeners(eventListeners, eventImpl.target, event);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.bubbles) {
|
||||
eventImpl.eventPhase = Event.BUBBLING_PHASE;
|
||||
for (let i = 0; i < eventPath.length; ++i) {
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
break;
|
||||
}
|
||||
|
||||
const object = eventPath[i];
|
||||
const objectImpl = idlUtils.implForWrapper(object);
|
||||
const eventListeners = objectImpl._eventListeners[event.type];
|
||||
invokeInlineListeners(object, event);
|
||||
invokeEventListeners(eventListeners, object, event);
|
||||
}
|
||||
}
|
||||
|
||||
eventImpl._dispatchFlag = false;
|
||||
eventImpl.eventPhase = Event.NONE;
|
||||
eventImpl.currentTarget = null;
|
||||
return !eventImpl._canceledFlag;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: EventTargetImpl
|
||||
};
|
||||
|
||||
function invokeInlineListeners(object, event) {
|
||||
const inlineListener = getListenerForInlineEventHandler(object, event.type);
|
||||
if (inlineListener) {
|
||||
const document = object._ownerDocument || object._document;
|
||||
|
||||
// Will be falsy for windows that have closed
|
||||
if (document && (!object.nodeName || document.implementation._hasFeature("ProcessExternalResources", "script"))) {
|
||||
invokeEventListeners([{ callback: inlineListener }], object, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function invokeEventListeners(listeners, target, event) {
|
||||
const document = target._ownerDocument || target._document;
|
||||
// Will be falsy for windows that have closed
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
const eventImpl = idlUtils.implForWrapper(event);
|
||||
eventImpl.currentTarget = target;
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
|
||||
const handlers = listeners.slice();
|
||||
for (let i = 0; i < handlers.length; ++i) {
|
||||
if (eventImpl._stopImmediatePropagationFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
const listener = handlers[i];
|
||||
if (listeners.indexOf(listener) === -1 ||
|
||||
(event.eventPhase === Event.CAPTURING_PHASE && !listener.capture) ||
|
||||
(event.eventPhase === Event.BUBBLING_PHASE && listener.capture)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
listener.callback.call(eventImpl.currentTarget, event);
|
||||
} catch (e) {
|
||||
let window = null;
|
||||
if (target._document) {
|
||||
window = target;
|
||||
} else if (target._ownerDocument) {
|
||||
window = target._ownerDocument._defaultView;
|
||||
}
|
||||
|
||||
if (window) {
|
||||
reportException(window, e);
|
||||
}
|
||||
// Errors in window-less documents just get swallowed... can you think of anything better?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const wrappedListener = Symbol("inline event listener wrapper");
|
||||
|
||||
function getListenerForInlineEventHandler(target, type) {
|
||||
const callback = target["on" + type];
|
||||
|
||||
if (!callback) { // TODO event handlers: only check null
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!callback[wrappedListener]) {
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm
|
||||
callback[wrappedListener] = function (E) {
|
||||
const isWindowError = E.constructor.name === "ErrorEvent" && type === "error"; // TODO branding
|
||||
|
||||
let returnValue;
|
||||
if (isWindowError) {
|
||||
returnValue = callback.call(E.currentTarget, E.message, E.filename, E.lineno, E.colno, E.error);
|
||||
} else {
|
||||
returnValue = callback.call(E.currentTarget, E);
|
||||
}
|
||||
|
||||
if (type === "mouseover" || isWindowError) {
|
||||
if (returnValue) {
|
||||
E.preventDefault();
|
||||
}
|
||||
} else if (!returnValue) {
|
||||
E.preventDefault();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return callback[wrappedListener];
|
||||
}
|
||||
11
node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js
generated
vendored
Normal file
11
node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class HashChangeEventImpl extends EventImpl {
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: HashChangeEventImpl
|
||||
};
|
||||
21
node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js
generated
vendored
Normal file
21
node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
const UIEventImpl = require("./UIEvent-impl").implementation;
|
||||
|
||||
class KeyboardEventImpl extends UIEventImpl {
|
||||
initKeyboardEvent(type, bubbles, cancelable, view, key, location, modifiersList, repeat, locale) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initUIEvent(type, bubbles, cancelable, view, key);
|
||||
this.location = location;
|
||||
this.modifiersList = modifiersList;
|
||||
this.repeat = repeat;
|
||||
this.locale = locale;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: KeyboardEventImpl
|
||||
};
|
||||
22
node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js
generated
vendored
Normal file
22
node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class MessageEventImpl extends EventImpl {
|
||||
initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initEvent(type, bubbles, cancelable);
|
||||
this.data = data;
|
||||
this.origin = origin;
|
||||
this.lastEventId = lastEventId;
|
||||
this.source = source;
|
||||
this.ports = ports;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: MessageEventImpl
|
||||
};
|
||||
28
node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js
generated
vendored
Normal file
28
node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
const UIEventImpl = require("./UIEvent-impl").implementation;
|
||||
|
||||
class MouseEventImpl extends UIEventImpl {
|
||||
initMouseEvent(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,
|
||||
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initUIEvent(type, bubbles, cancelable, view, detail);
|
||||
this.screenX = screenX;
|
||||
this.screenY = screenY;
|
||||
this.clientX = clientX;
|
||||
this.clientY = clientY;
|
||||
this.ctrlKey = ctrlKey;
|
||||
this.altKey = altKey;
|
||||
this.shiftKey = shiftKey;
|
||||
this.metaKey = metaKey;
|
||||
this.button = button;
|
||||
this.relatedTarget = relatedTarget;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: MouseEventImpl
|
||||
};
|
||||
22
node_modules/jsdom/lib/jsdom/living/events/MutationEvent-impl.js
generated
vendored
Normal file
22
node_modules/jsdom/lib/jsdom/living/events/MutationEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class MutationEventImpl extends EventImpl {
|
||||
initMutationEvent(type, bubbles, cancelable, relatedNode, prevValue, newValue, attrName, attrChange) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initEvent(type, bubbles, cancelable);
|
||||
this.relatedNode = relatedNode;
|
||||
this.prevValue = prevValue;
|
||||
this.newValue = newValue;
|
||||
this.attrName = attrName;
|
||||
this.attrChange = attrChange;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: MutationEventImpl
|
||||
};
|
||||
11
node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js
generated
vendored
Normal file
11
node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class ProgressEventImpl extends EventImpl {
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: ProgressEventImpl
|
||||
};
|
||||
11
node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js
generated
vendored
Normal file
11
node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const UIEventImpl = require("./UIEvent-impl").implementation;
|
||||
|
||||
class TouchEventImpl extends UIEventImpl {
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: TouchEventImpl
|
||||
};
|
||||
19
node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js
generated
vendored
Normal file
19
node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const EventImpl = require("./Event-impl").implementation;
|
||||
|
||||
class UIEventImpl extends EventImpl {
|
||||
initUIEvent(type, bubbles, cancelable, view, detail) {
|
||||
if (this._dispatchFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initEvent(type, bubbles, cancelable);
|
||||
this.view = view;
|
||||
this.detail = detail;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: UIEventImpl
|
||||
};
|
||||
145
node_modules/jsdom/lib/jsdom/living/file-reader.js
generated
vendored
Normal file
145
node_modules/jsdom/lib/jsdom/living/file-reader.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
"use strict";
|
||||
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
const EventTarget = require("./generated/EventTarget");
|
||||
const addConstants = require("../utils").addConstants;
|
||||
const blobSymbols = require("./blob-symbols");
|
||||
|
||||
function FileReaderEventTarget() {
|
||||
if (!(this instanceof FileReaderEventTarget)) {
|
||||
throw new TypeError("DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
EventTarget.setup(this);
|
||||
}
|
||||
|
||||
FileReaderEventTarget.prototype = Object.create(EventTarget.interface.prototype);
|
||||
|
||||
module.exports = function createFileReader(window) {
|
||||
const ProgressEvent = window.ProgressEvent;
|
||||
|
||||
class FileReader extends FileReaderEventTarget {
|
||||
constructor() {
|
||||
super();
|
||||
this.error = null;
|
||||
this.readyState = FileReader.EMPTY;
|
||||
this.result = null;
|
||||
this.onloadstart = null;
|
||||
this.onprogress = null;
|
||||
this.onload = null;
|
||||
this.onabort = null;
|
||||
this.onerror = null;
|
||||
this.onloadend = null;
|
||||
}
|
||||
readAsArrayBuffer(file) {
|
||||
readFile(this, file, "buffer");
|
||||
}
|
||||
readAsBinaryString(file) {
|
||||
readFile(this, file, "binary");
|
||||
}
|
||||
readAsDataURL(file) {
|
||||
readFile(this, file, "dataUrl");
|
||||
}
|
||||
readAsText(file, encoding) {
|
||||
readFile(this, file, "text", encoding);
|
||||
}
|
||||
abort() {
|
||||
if (this.readyState === this.DONE || this.readyState === this.EMPTY) {
|
||||
this.result = null;
|
||||
return;
|
||||
}
|
||||
if (this.readyState === this.LOADING) {
|
||||
this.readyState = this.DONE;
|
||||
}
|
||||
this.dispatchEvent(new ProgressEvent("abort"));
|
||||
this.dispatchEvent(new ProgressEvent("loadend"));
|
||||
}
|
||||
|
||||
get _ownerDocument() {
|
||||
return window.document;
|
||||
}
|
||||
}
|
||||
|
||||
addConstants(FileReader, {
|
||||
EMPTY: 0,
|
||||
LOADING: 1,
|
||||
DONE: 2
|
||||
});
|
||||
|
||||
function readFile(self, file, format, encoding) {
|
||||
if (self.readyState === self.LOADING) {
|
||||
throw new DOMException(DOMException.INVALID_STATE_ERR);
|
||||
}
|
||||
if (file[blobSymbols.closed]) {
|
||||
self.error = new DOMException(DOMException.INVALID_STATE_ERR);
|
||||
self.dispatchEvent(new ProgressEvent("error"));
|
||||
}
|
||||
|
||||
self.readyState = self.LOADING;
|
||||
self.dispatchEvent(new ProgressEvent("loadstart"));
|
||||
|
||||
process.nextTick(() => {
|
||||
let data = file[blobSymbols.buffer];
|
||||
if (!data) {
|
||||
data = new Buffer("");
|
||||
}
|
||||
self.dispatchEvent(new ProgressEvent("progress", {
|
||||
lengthComputable: !isNaN(file.size),
|
||||
total: file.size,
|
||||
loaded: data.length
|
||||
}));
|
||||
|
||||
process.nextTick(() => {
|
||||
self.readyState = self.DONE;
|
||||
switch (format) {
|
||||
default:
|
||||
case "buffer":
|
||||
const ab = new ArrayBuffer(data.length);
|
||||
const view = new Uint8Array(ab);
|
||||
for (let i = 0; i < data.length; ++i) {
|
||||
view[i] = data[i];
|
||||
}
|
||||
self.result = ab;
|
||||
break;
|
||||
case "binary":
|
||||
self.result = data.toString("binary");
|
||||
break;
|
||||
case "dataUrl":
|
||||
let dataUrl = "data:";
|
||||
if (file.type) {
|
||||
dataUrl += file.type + ";";
|
||||
}
|
||||
if (/text/i.test(file.type)) {
|
||||
dataUrl += "charset=utf-8,";
|
||||
dataUrl += data.toString("utf8");
|
||||
} else {
|
||||
dataUrl += "base64,";
|
||||
dataUrl += data.toString("base64");
|
||||
}
|
||||
self.result = dataUrl;
|
||||
break;
|
||||
case "text":
|
||||
if (encoding) {
|
||||
encoding = encoding.toLowerCase();
|
||||
if (encoding === "utf-16" || encoding === "utf16") {
|
||||
encoding = "utf-16le";
|
||||
}
|
||||
} else {
|
||||
encoding = "utf8";
|
||||
}
|
||||
self.result = data.toString(encoding);
|
||||
break;
|
||||
}
|
||||
|
||||
self.dispatchEvent(new ProgressEvent("load"));
|
||||
|
||||
process.nextTick(() => {
|
||||
if (self.readyState !== self.LOADING) {
|
||||
self.dispatchEvent(new ProgressEvent("loadend"));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return FileReader;
|
||||
};
|
||||
3
node_modules/jsdom/lib/jsdom/living/file-symbols.js
generated
vendored
Normal file
3
node_modules/jsdom/lib/jsdom/living/file-symbols.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports.name = Symbol("name");
|
||||
21
node_modules/jsdom/lib/jsdom/living/file.js
generated
vendored
Normal file
21
node_modules/jsdom/lib/jsdom/living/file.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
const fileSymbols = require("./file-symbols");
|
||||
|
||||
module.exports = function (core) {
|
||||
const Blob = core.Blob;
|
||||
|
||||
class File extends Blob {
|
||||
constructor(fileBits, fileName) {
|
||||
super(fileBits, arguments[2]);
|
||||
if (!(this instanceof File)) {
|
||||
throw new TypeError("DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
this[fileSymbols.name] = fileName.replace(/\//g, ":");
|
||||
}
|
||||
get name() {
|
||||
return this[fileSymbols.name];
|
||||
}
|
||||
}
|
||||
core.File = File;
|
||||
};
|
||||
3
node_modules/jsdom/lib/jsdom/living/filelist-symbols.js
generated
vendored
Normal file
3
node_modules/jsdom/lib/jsdom/living/filelist-symbols.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports.list = Symbol("list");
|
||||
21
node_modules/jsdom/lib/jsdom/living/filelist.js
generated
vendored
Normal file
21
node_modules/jsdom/lib/jsdom/living/filelist.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
const filelistSymbols = require("./filelist-symbols");
|
||||
|
||||
module.exports = function (core) {
|
||||
class FileList {
|
||||
constructor() {
|
||||
if (!(this instanceof FileList)) {
|
||||
throw new TypeError("DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
this[filelistSymbols.list] = [];
|
||||
}
|
||||
item(index) {
|
||||
return this[filelistSymbols.list][index] || null;
|
||||
}
|
||||
get length() {
|
||||
return this[filelistSymbols.list].length;
|
||||
}
|
||||
}
|
||||
core.FileList = FileList;
|
||||
};
|
||||
3
node_modules/jsdom/lib/jsdom/living/form-data-symbols.js
generated
vendored
Normal file
3
node_modules/jsdom/lib/jsdom/living/form-data-symbols.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports.formData = Symbol("entries");
|
||||
79
node_modules/jsdom/lib/jsdom/living/form-data.js
generated
vendored
Normal file
79
node_modules/jsdom/lib/jsdom/living/form-data.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
|
||||
const formDataSymbols = require("./form-data-symbols");
|
||||
|
||||
module.exports = function (core) {
|
||||
const Blob = core.Blob;
|
||||
const File = core.File;
|
||||
|
||||
class FormData {
|
||||
constructor(form) {
|
||||
if (!(this instanceof FormData)) {
|
||||
throw new TypeError("DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
const entries = this[formDataSymbols.entries] = [];
|
||||
if (form && form.elements) {
|
||||
for (let i = 0; i < form.elements.length; i++) {
|
||||
const el = form.elements[i];
|
||||
if (el.type === "file") {
|
||||
for (let j = 0; j < el.files.length; j++) {
|
||||
entries.push({ name: el.name, value: el.files.item(j) });
|
||||
}
|
||||
} else {
|
||||
entries.push({ name: el.name, value: el.value });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
append(name, value, filename) {
|
||||
if (value instanceof Blob) {
|
||||
value = new File(
|
||||
[value],
|
||||
filename || value.name || "blob",
|
||||
{ type: value.type, lastModified: value.lastModified }
|
||||
);
|
||||
} else {
|
||||
value = String(value);
|
||||
}
|
||||
const entries = this[formDataSymbols.entries];
|
||||
entries.push({ name, value });
|
||||
}
|
||||
delete(name) {
|
||||
this[formDataSymbols.entries] = this[formDataSymbols.entries].filter(entry => entry.name !== name);
|
||||
}
|
||||
get(name) {
|
||||
return this[formDataSymbols.entries].find(entry => entry.name === name) || null;
|
||||
}
|
||||
getAll(name) {
|
||||
return this[formDataSymbols.entries].filter(entry => entry.name === name).map(entry => entry.value);
|
||||
}
|
||||
has(name) {
|
||||
return this[formDataSymbols.entries].findIndex(entry => entry.name === name) !== -1;
|
||||
}
|
||||
set(name, value, filename) {
|
||||
if (value instanceof Blob) {
|
||||
value = new File(
|
||||
[value],
|
||||
filename || value.name || "blob",
|
||||
{ type: value.type, lastModified: value.lastModified }
|
||||
);
|
||||
} else {
|
||||
value = String(value);
|
||||
}
|
||||
const newEntry = { name, value };
|
||||
const entries = this[formDataSymbols.entries];
|
||||
const existing = entries.findIndex(entry => entry.name === name);
|
||||
if (existing !== -1) {
|
||||
entries[existing] = newEntry;
|
||||
this[formDataSymbols.entries] = entries.filter((entry, index) => entry.name !== name || index === existing);
|
||||
} else {
|
||||
entries.push(newEntry);
|
||||
}
|
||||
}
|
||||
toString() {
|
||||
return "[object FormData]";
|
||||
}
|
||||
}
|
||||
|
||||
core.FormData = FormData;
|
||||
};
|
||||
0
node_modules/jsdom/lib/jsdom/living/generated/.gitkeep
generated
vendored
Normal file
0
node_modules/jsdom/lib/jsdom/living/generated/.gitkeep
generated
vendored
Normal file
118
node_modules/jsdom/lib/jsdom/living/generated/Attr.js
generated
vendored
Normal file
118
node_modules/jsdom/lib/jsdom/living/generated/Attr.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../attributes/Attr-impl.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function Attr() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
Object.defineProperty(Attr.prototype, "namespaceURI", {
|
||||
get() {
|
||||
return this[impl].namespaceURI;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "prefix", {
|
||||
get() {
|
||||
return this[impl].prefix;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "localName", {
|
||||
get() {
|
||||
return this[impl].localName;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "name", {
|
||||
get() {
|
||||
return this[impl].name;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "value", {
|
||||
get() {
|
||||
return this[impl].value;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["DOMString"](V);
|
||||
this[impl].value = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "nodeValue", {
|
||||
get() {
|
||||
return this[impl].nodeValue;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
|
||||
this[impl].nodeValue = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "textContent", {
|
||||
get() {
|
||||
return this[impl].textContent;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
|
||||
this[impl].textContent = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "ownerElement", {
|
||||
get() {
|
||||
return this[impl].ownerElement;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Attr.prototype, "specified", {
|
||||
get() {
|
||||
return this[impl].specified;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(Attr.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: Attr,
|
||||
expose: {
|
||||
Window: { Attr: Attr }
|
||||
}
|
||||
};
|
||||
|
||||
77
node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js
generated
vendored
Normal file
77
node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/CustomEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertCustomEventInit = require("./CustomEventInit").convert;
|
||||
|
||||
function CustomEvent(type) {
|
||||
if (!this || this[impl] || !(this instanceof CustomEvent)) {
|
||||
throw new TypeError("Failed to construct 'CustomEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertCustomEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
CustomEvent.prototype = Object.create(Event.interface.prototype);
|
||||
CustomEvent.prototype.constructor = CustomEvent;
|
||||
|
||||
CustomEvent.prototype.initCustomEvent = function initCustomEvent(type, bubbles, cancelable, detail) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 4) {
|
||||
throw new TypeError("Failed to execute 'initCustomEvent' on 'CustomEvent': 4 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 4; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
return this[impl].initCustomEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(CustomEvent.prototype, "detail", {
|
||||
get() {
|
||||
return this[impl].detail;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(CustomEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: CustomEvent,
|
||||
expose: {
|
||||
Window: { CustomEvent: CustomEvent },
|
||||
Worker: { CustomEvent: CustomEvent }
|
||||
}
|
||||
};
|
||||
|
||||
34
node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js
generated
vendored
Normal file
34
node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "detail";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
92
node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js
generated
vendored
Normal file
92
node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/ErrorEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertErrorEventInit = require("./ErrorEventInit").convert;
|
||||
|
||||
function ErrorEvent(type) {
|
||||
if (!this || this[impl] || !(this instanceof ErrorEvent)) {
|
||||
throw new TypeError("Failed to construct 'ErrorEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertErrorEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
ErrorEvent.prototype = Object.create(Event.interface.prototype);
|
||||
ErrorEvent.prototype.constructor = ErrorEvent;
|
||||
Object.defineProperty(ErrorEvent.prototype, "message", {
|
||||
get() {
|
||||
return this[impl].message;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "filename", {
|
||||
get() {
|
||||
return this[impl].filename;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "lineno", {
|
||||
get() {
|
||||
return this[impl].lineno;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "colno", {
|
||||
get() {
|
||||
return this[impl].colno;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ErrorEvent.prototype, "error", {
|
||||
get() {
|
||||
return this[impl].error;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(ErrorEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: ErrorEvent,
|
||||
expose: {
|
||||
Window: { ErrorEvent: ErrorEvent },
|
||||
Worker: { ErrorEvent: ErrorEvent }
|
||||
}
|
||||
};
|
||||
|
||||
56
node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js
generated
vendored
Normal file
56
node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "colno";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long"](value);
|
||||
}
|
||||
|
||||
key = "error";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
}
|
||||
|
||||
key = "filename";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
}
|
||||
|
||||
key = "lineno";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long"](value);
|
||||
}
|
||||
|
||||
key = "message";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
208
node_modules/jsdom/lib/jsdom/living/generated/Event.js
generated
vendored
Normal file
208
node_modules/jsdom/lib/jsdom/living/generated/Event.js
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/Event-impl.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
const convertEventInit = require("./EventInit").convert;
|
||||
|
||||
function Event(type) {
|
||||
if (!this || this[impl] || !(this instanceof Event)) {
|
||||
throw new TypeError("Failed to construct 'Event': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
|
||||
Event.prototype.stopPropagation = function stopPropagation() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 0; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return this[impl].stopPropagation.apply(this[impl], args);
|
||||
};
|
||||
|
||||
Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 0; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return this[impl].stopImmediatePropagation.apply(this[impl], args);
|
||||
};
|
||||
|
||||
Event.prototype.preventDefault = function preventDefault() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 0; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return this[impl].preventDefault.apply(this[impl], args);
|
||||
};
|
||||
|
||||
Event.prototype.initEvent = function initEvent(type, bubbles, cancelable) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError("Failed to execute 'initEvent' on 'Event': 3 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 3; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
return this[impl].initEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(Event.prototype, "type", {
|
||||
get() {
|
||||
return this[impl].type;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "target", {
|
||||
get() {
|
||||
return this[impl].target;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "currentTarget", {
|
||||
get() {
|
||||
return this[impl].currentTarget;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "NONE", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "NONE", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "CAPTURING_PHASE", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "CAPTURING_PHASE", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "AT_TARGET", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "AT_TARGET", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event, "BUBBLING_PHASE", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(Event.prototype, "BUBBLING_PHASE", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "eventPhase", {
|
||||
get() {
|
||||
return this[impl].eventPhase;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "bubbles", {
|
||||
get() {
|
||||
return this[impl].bubbles;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "cancelable", {
|
||||
get() {
|
||||
return this[impl].cancelable;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "defaultPrevented", {
|
||||
get() {
|
||||
return this[impl].defaultPrevented;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(Event.prototype, "timeStamp", {
|
||||
get() {
|
||||
return this[impl].timeStamp;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(Event.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
Object.defineProperty(obj, "isTrusted", {
|
||||
get() {
|
||||
return obj[impl].isTrusted;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: Event,
|
||||
expose: {
|
||||
Window: { Event: Event },
|
||||
Worker: { Event: Event }
|
||||
}
|
||||
};
|
||||
|
||||
40
node_modules/jsdom/lib/jsdom/living/generated/EventInit.js
generated
vendored
Normal file
40
node_modules/jsdom/lib/jsdom/living/generated/EventInit.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
let key, value;
|
||||
|
||||
key = "bubbles";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "cancelable";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
146
node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js
generated
vendored
Normal file
146
node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const UIEventInit = require("./UIEventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
UIEventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "altKey";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "ctrlKey";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "metaKey";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierAltGraph";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierCapsLock";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierFn";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierFnLock";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierHyper";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierNumLock";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierOS";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierScrollLock";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierSuper";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierSymbol";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "modifierSymbolLock";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "shiftKey";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
85
node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js
generated
vendored
Normal file
85
node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/EventTarget-impl.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function EventTarget() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
|
||||
EventTarget.prototype.addEventListener = function addEventListener(type, callback) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 3; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
if (args[2] !== undefined) {
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
}
|
||||
return this[impl].addEventListener.apply(this[impl], args);
|
||||
};
|
||||
|
||||
EventTarget.prototype.removeEventListener = function removeEventListener(type, callback) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 3; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
if (args[2] !== undefined) {
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
}
|
||||
return this[impl].removeEventListener.apply(this[impl], args);
|
||||
};
|
||||
|
||||
EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return this[impl].dispatchEvent.apply(this[impl], args);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(EventTarget.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: EventTarget,
|
||||
expose: {
|
||||
Window: { EventTarget: EventTarget },
|
||||
Worker: { EventTarget: EventTarget }
|
||||
}
|
||||
};
|
||||
|
||||
45
node_modules/jsdom/lib/jsdom/living/generated/HTMLTemplateElement.js
generated
vendored
Normal file
45
node_modules/jsdom/lib/jsdom/living/generated/HTMLTemplateElement.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../elements/HTMLTemplateElement-impl.js");
|
||||
|
||||
const HTMLElement = require("./HTMLElement.js");
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function HTMLTemplateElement() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
HTMLTemplateElement.prototype = Object.create(HTMLElement.interface.prototype);
|
||||
HTMLTemplateElement.prototype.constructor = HTMLTemplateElement;
|
||||
Object.defineProperty(HTMLTemplateElement.prototype, "content", {
|
||||
get() {
|
||||
return this[impl].content;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(HTMLTemplateElement.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: HTMLTemplateElement,
|
||||
expose: {
|
||||
Window: { HTMLTemplateElement: HTMLTemplateElement }
|
||||
}
|
||||
};
|
||||
|
||||
68
node_modules/jsdom/lib/jsdom/living/generated/HashChangeEvent.js
generated
vendored
Normal file
68
node_modules/jsdom/lib/jsdom/living/generated/HashChangeEvent.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/HashChangeEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertHashChangeEventInit = require("./HashChangeEventInit").convert;
|
||||
|
||||
function HashChangeEvent(type) {
|
||||
if (!this || this[impl] || !(this instanceof HashChangeEvent)) {
|
||||
throw new TypeError("Failed to construct 'HashChangeEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'HashChangeEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertHashChangeEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
HashChangeEvent.prototype = Object.create(Event.interface.prototype);
|
||||
HashChangeEvent.prototype.constructor = HashChangeEvent;
|
||||
Object.defineProperty(HashChangeEvent.prototype, "oldURL", {
|
||||
get() {
|
||||
return this[impl].oldURL;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(HashChangeEvent.prototype, "newURL", {
|
||||
get() {
|
||||
return this[impl].newURL;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(HashChangeEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: HashChangeEvent,
|
||||
expose: {
|
||||
Window: { HashChangeEvent: HashChangeEvent },
|
||||
Worker: { HashChangeEvent: HashChangeEvent }
|
||||
}
|
||||
};
|
||||
|
||||
38
node_modules/jsdom/lib/jsdom/living/generated/HashChangeEventInit.js
generated
vendored
Normal file
38
node_modules/jsdom/lib/jsdom/living/generated/HashChangeEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "newURL";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
}
|
||||
|
||||
key = "oldURL";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
220
node_modules/jsdom/lib/jsdom/living/generated/KeyboardEvent.js
generated
vendored
Normal file
220
node_modules/jsdom/lib/jsdom/living/generated/KeyboardEvent.js
generated
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/KeyboardEvent-impl.js");
|
||||
|
||||
const UIEvent = require("./UIEvent.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertKeyboardEventInit = require("./KeyboardEventInit").convert;
|
||||
|
||||
function KeyboardEvent(typeArg) {
|
||||
if (!this || this[impl] || !(this instanceof KeyboardEvent)) {
|
||||
throw new TypeError("Failed to construct 'KeyboardEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'KeyboardEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertKeyboardEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
KeyboardEvent.prototype = Object.create(UIEvent.interface.prototype);
|
||||
KeyboardEvent.prototype.constructor = KeyboardEvent;
|
||||
|
||||
KeyboardEvent.prototype.getModifierState = function getModifierState(keyArg) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to execute 'getModifierState' on 'KeyboardEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
return this[impl].getModifierState.apply(this[impl], args);
|
||||
};
|
||||
|
||||
KeyboardEvent.prototype.initKeyboardEvent = function initKeyboardEvent(typeArg, bubblesArg, cancelableArg, viewArg, keyArg, locationArg, modifiersListArg, repeat, locale) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 9) {
|
||||
throw new TypeError("Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': 9 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 9; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
args[4] = conversions["DOMString"](args[4]);
|
||||
args[5] = conversions["unsigned long"](args[5]);
|
||||
args[6] = conversions["DOMString"](args[6]);
|
||||
args[7] = conversions["boolean"](args[7]);
|
||||
args[8] = conversions["DOMString"](args[8]);
|
||||
return this[impl].initKeyboardEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_STANDARD", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_STANDARD", {
|
||||
value: 0,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_LEFT", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_LEFT", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_RIGHT", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_RIGHT", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent, "DOM_KEY_LOCATION_NUMPAD", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(KeyboardEvent.prototype, "DOM_KEY_LOCATION_NUMPAD", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "key", {
|
||||
get() {
|
||||
return this[impl].key;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "code", {
|
||||
get() {
|
||||
return this[impl].code;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "location", {
|
||||
get() {
|
||||
return this[impl].location;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "ctrlKey", {
|
||||
get() {
|
||||
return this[impl].ctrlKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "shiftKey", {
|
||||
get() {
|
||||
return this[impl].shiftKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "altKey", {
|
||||
get() {
|
||||
return this[impl].altKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "metaKey", {
|
||||
get() {
|
||||
return this[impl].metaKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "repeat", {
|
||||
get() {
|
||||
return this[impl].repeat;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "isComposing", {
|
||||
get() {
|
||||
return this[impl].isComposing;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "charCode", {
|
||||
get() {
|
||||
return this[impl].charCode;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "keyCode", {
|
||||
get() {
|
||||
return this[impl].keyCode;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(KeyboardEvent.prototype, "which", {
|
||||
get() {
|
||||
return this[impl].which;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(KeyboardEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: KeyboardEvent,
|
||||
expose: {
|
||||
Window: { KeyboardEvent: KeyboardEvent }
|
||||
}
|
||||
};
|
||||
|
||||
90
node_modules/jsdom/lib/jsdom/living/generated/KeyboardEventInit.js
generated
vendored
Normal file
90
node_modules/jsdom/lib/jsdom/living/generated/KeyboardEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventModifierInit = require("./EventModifierInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventModifierInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "charCode";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "code";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
|
||||
key = "isComposing";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "key";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
} else {
|
||||
ret[key] = "";
|
||||
}
|
||||
|
||||
key = "keyCode";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "location";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "repeat";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "which";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
111
node_modules/jsdom/lib/jsdom/living/generated/MessageEvent.js
generated
vendored
Normal file
111
node_modules/jsdom/lib/jsdom/living/generated/MessageEvent.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/MessageEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertMessageEventInit = require("./MessageEventInit").convert;
|
||||
|
||||
function MessageEvent(type) {
|
||||
if (!this || this[impl] || !(this instanceof MessageEvent)) {
|
||||
throw new TypeError("Failed to construct 'MessageEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'MessageEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertMessageEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
MessageEvent.prototype = Object.create(Event.interface.prototype);
|
||||
MessageEvent.prototype.constructor = MessageEvent;
|
||||
|
||||
MessageEvent.prototype.initMessageEvent = function initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 8) {
|
||||
throw new TypeError("Failed to execute 'initMessageEvent' on 'MessageEvent': 8 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 8; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
args[4] = conversions["DOMString"](args[4]);
|
||||
args[5] = conversions["DOMString"](args[5]);
|
||||
return this[impl].initMessageEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(MessageEvent.prototype, "data", {
|
||||
get() {
|
||||
return this[impl].data;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MessageEvent.prototype, "origin", {
|
||||
get() {
|
||||
return this[impl].origin;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MessageEvent.prototype, "lastEventId", {
|
||||
get() {
|
||||
return this[impl].lastEventId;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MessageEvent.prototype, "source", {
|
||||
get() {
|
||||
return this[impl].source;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MessageEvent.prototype, "ports", {
|
||||
get() {
|
||||
return this[impl].ports;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(MessageEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: MessageEvent,
|
||||
expose: {
|
||||
Window: { MessageEvent: MessageEvent },
|
||||
Worker: { MessageEvent: MessageEvent }
|
||||
}
|
||||
};
|
||||
|
||||
56
node_modules/jsdom/lib/jsdom/living/generated/MessageEventInit.js
generated
vendored
Normal file
56
node_modules/jsdom/lib/jsdom/living/generated/MessageEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "data";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
}
|
||||
|
||||
key = "lastEventId";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
}
|
||||
|
||||
key = "origin";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["DOMString"](value);
|
||||
}
|
||||
|
||||
key = "ports";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
}
|
||||
|
||||
key = "source";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
181
node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js
generated
vendored
Normal file
181
node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/MouseEvent-impl.js");
|
||||
|
||||
const UIEvent = require("./UIEvent.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertMouseEventInit = require("./MouseEventInit").convert;
|
||||
|
||||
function MouseEvent(typeArg) {
|
||||
if (!this || this[impl] || !(this instanceof MouseEvent)) {
|
||||
throw new TypeError("Failed to construct 'MouseEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'MouseEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertMouseEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
MouseEvent.prototype = Object.create(UIEvent.interface.prototype);
|
||||
MouseEvent.prototype.constructor = MouseEvent;
|
||||
|
||||
MouseEvent.prototype.getModifierState = function getModifierState(keyArg) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to execute 'getModifierState' on 'MouseEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 1; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
return this[impl].getModifierState.apply(this[impl], args);
|
||||
};
|
||||
|
||||
MouseEvent.prototype.initMouseEvent = function initMouseEvent(typeArg, bubblesArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 15) {
|
||||
throw new TypeError("Failed to execute 'initMouseEvent' on 'MouseEvent': 15 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 15; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
args[4] = conversions["long"](args[4]);
|
||||
args[5] = conversions["long"](args[5]);
|
||||
args[6] = conversions["long"](args[6]);
|
||||
args[7] = conversions["long"](args[7]);
|
||||
args[8] = conversions["long"](args[8]);
|
||||
args[9] = conversions["boolean"](args[9]);
|
||||
args[10] = conversions["boolean"](args[10]);
|
||||
args[11] = conversions["boolean"](args[11]);
|
||||
args[12] = conversions["boolean"](args[12]);
|
||||
args[13] = conversions["short"](args[13]);
|
||||
return this[impl].initMouseEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(MouseEvent.prototype, "screenX", {
|
||||
get() {
|
||||
return this[impl].screenX;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "screenY", {
|
||||
get() {
|
||||
return this[impl].screenY;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "clientX", {
|
||||
get() {
|
||||
return this[impl].clientX;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "clientY", {
|
||||
get() {
|
||||
return this[impl].clientY;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "ctrlKey", {
|
||||
get() {
|
||||
return this[impl].ctrlKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "shiftKey", {
|
||||
get() {
|
||||
return this[impl].shiftKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "altKey", {
|
||||
get() {
|
||||
return this[impl].altKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "metaKey", {
|
||||
get() {
|
||||
return this[impl].metaKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "button", {
|
||||
get() {
|
||||
return this[impl].button;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "relatedTarget", {
|
||||
get() {
|
||||
return this[impl].relatedTarget;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MouseEvent.prototype, "buttons", {
|
||||
get() {
|
||||
return this[impl].buttons;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(MouseEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: MouseEvent,
|
||||
expose: {
|
||||
Window: { MouseEvent: MouseEvent }
|
||||
}
|
||||
};
|
||||
|
||||
82
node_modules/jsdom/lib/jsdom/living/generated/MouseEventInit.js
generated
vendored
Normal file
82
node_modules/jsdom/lib/jsdom/living/generated/MouseEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventModifierInit = require("./EventModifierInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventModifierInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "button";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["short"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "buttons";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned short"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "clientX";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "clientY";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "relatedTarget";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
|
||||
key = "screenX";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "screenY";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
125
node_modules/jsdom/lib/jsdom/living/generated/MutationEvent.js
generated
vendored
Normal file
125
node_modules/jsdom/lib/jsdom/living/generated/MutationEvent.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/MutationEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function MutationEvent() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
MutationEvent.prototype = Object.create(Event.interface.prototype);
|
||||
MutationEvent.prototype.constructor = MutationEvent;
|
||||
|
||||
MutationEvent.prototype.initMutationEvent = function initMutationEvent(typeArg, bubblesArg, cancelableArg, relatedNodeArg, prevValueArg, newValueArg, attrNameArg, attrChangeArg) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 8) {
|
||||
throw new TypeError("Failed to execute 'initMutationEvent' on 'MutationEvent': 8 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 8; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
args[4] = conversions["DOMString"](args[4]);
|
||||
args[5] = conversions["DOMString"](args[5]);
|
||||
args[6] = conversions["DOMString"](args[6]);
|
||||
args[7] = conversions["unsigned short"](args[7]);
|
||||
return this[impl].initMutationEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(MutationEvent, "MODIFICATION", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(MutationEvent.prototype, "MODIFICATION", {
|
||||
value: 1,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent, "ADDITION", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(MutationEvent.prototype, "ADDITION", {
|
||||
value: 2,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent, "REMOVAL", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
Object.defineProperty(MutationEvent.prototype, "REMOVAL", {
|
||||
value: 3,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent.prototype, "relatedNode", {
|
||||
get() {
|
||||
return this[impl].relatedNode;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent.prototype, "prevValue", {
|
||||
get() {
|
||||
return this[impl].prevValue;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent.prototype, "newValue", {
|
||||
get() {
|
||||
return this[impl].newValue;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent.prototype, "attrName", {
|
||||
get() {
|
||||
return this[impl].attrName;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(MutationEvent.prototype, "attrChange", {
|
||||
get() {
|
||||
return this[impl].attrChange;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(MutationEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: MutationEvent,
|
||||
expose: {
|
||||
Window: { MutationEvent: MutationEvent }
|
||||
}
|
||||
};
|
||||
|
||||
77
node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js
generated
vendored
Normal file
77
node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/ProgressEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertProgressEventInit = require("./ProgressEventInit").convert;
|
||||
|
||||
function ProgressEvent(type) {
|
||||
if (!this || this[impl] || !(this instanceof ProgressEvent)) {
|
||||
throw new TypeError("Failed to construct 'ProgressEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'ProgressEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertProgressEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
ProgressEvent.prototype = Object.create(Event.interface.prototype);
|
||||
ProgressEvent.prototype.constructor = ProgressEvent;
|
||||
Object.defineProperty(ProgressEvent.prototype, "lengthComputable", {
|
||||
get() {
|
||||
return this[impl].lengthComputable;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ProgressEvent.prototype, "loaded", {
|
||||
get() {
|
||||
return this[impl].loaded;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(ProgressEvent.prototype, "total", {
|
||||
get() {
|
||||
return this[impl].total;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(ProgressEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: ProgressEvent,
|
||||
expose: {
|
||||
Window: { ProgressEvent: ProgressEvent },
|
||||
DedicatedWorker: { ProgressEvent: ProgressEvent },
|
||||
SharedWorker: { ProgressEvent: ProgressEvent }
|
||||
}
|
||||
};
|
||||
|
||||
50
node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js
generated
vendored
Normal file
50
node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "lengthComputable";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["boolean"](value);
|
||||
} else {
|
||||
ret[key] = false;
|
||||
}
|
||||
|
||||
key = "loaded";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "total";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["unsigned long long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
93
node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js
generated
vendored
Normal file
93
node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/TouchEvent-impl.js");
|
||||
|
||||
const UIEvent = require("./UIEvent.js");
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function TouchEvent() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
}
|
||||
TouchEvent.prototype = Object.create(UIEvent.interface.prototype);
|
||||
TouchEvent.prototype.constructor = TouchEvent;
|
||||
Object.defineProperty(TouchEvent.prototype, "touches", {
|
||||
get() {
|
||||
return this[impl].touches;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(TouchEvent.prototype, "targetTouches", {
|
||||
get() {
|
||||
return this[impl].targetTouches;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(TouchEvent.prototype, "changedTouches", {
|
||||
get() {
|
||||
return this[impl].changedTouches;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(TouchEvent.prototype, "altKey", {
|
||||
get() {
|
||||
return this[impl].altKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(TouchEvent.prototype, "metaKey", {
|
||||
get() {
|
||||
return this[impl].metaKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(TouchEvent.prototype, "ctrlKey", {
|
||||
get() {
|
||||
return this[impl].ctrlKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(TouchEvent.prototype, "shiftKey", {
|
||||
get() {
|
||||
return this[impl].shiftKey;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(TouchEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: TouchEvent,
|
||||
expose: {
|
||||
Window: { TouchEvent: TouchEvent }
|
||||
}
|
||||
};
|
||||
|
||||
85
node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js
generated
vendored
Normal file
85
node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require("../events/UIEvent-impl.js");
|
||||
|
||||
const Event = require("./Event.js");
|
||||
const impl = utils.implSymbol;
|
||||
const convertUIEventInit = require("./UIEventInit").convert;
|
||||
|
||||
function UIEvent(type) {
|
||||
if (!this || this[impl] || !(this instanceof UIEvent)) {
|
||||
throw new TypeError("Failed to construct 'UIEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'UIEvent': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = convertUIEventInit(args[1]);
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
UIEvent.prototype = Object.create(Event.interface.prototype);
|
||||
UIEvent.prototype.constructor = UIEvent;
|
||||
|
||||
UIEvent.prototype.initUIEvent = function initUIEvent(typeArg, bubblesArg, cancelableArg, viewArg, detailArg) {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
if (arguments.length < 5) {
|
||||
throw new TypeError("Failed to execute 'initUIEvent' on 'UIEvent': 5 arguments required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 5; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["DOMString"](args[0]);
|
||||
args[1] = conversions["boolean"](args[1]);
|
||||
args[2] = conversions["boolean"](args[2]);
|
||||
args[4] = conversions["long"](args[4]);
|
||||
return this[impl].initUIEvent.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(UIEvent.prototype, "view", {
|
||||
get() {
|
||||
return this[impl].view;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(UIEvent.prototype, "detail", {
|
||||
get() {
|
||||
return this[impl].detail;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(UIEvent.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: UIEvent,
|
||||
expose: {
|
||||
Window: { UIEvent: UIEvent }
|
||||
}
|
||||
};
|
||||
|
||||
42
node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js
generated
vendored
Normal file
42
node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const EventInit = require("./EventInit");
|
||||
|
||||
module.exports = {
|
||||
convertInherit(obj, ret) {
|
||||
EventInit.convertInherit(obj, ret);
|
||||
let key, value;
|
||||
|
||||
key = "detail";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = conversions["long"](value);
|
||||
} else {
|
||||
ret[key] = 0;
|
||||
}
|
||||
|
||||
key = "view";
|
||||
value = obj === undefined || obj === null ? undefined : obj[key];
|
||||
if (value !== undefined) {
|
||||
ret[key] = (value);
|
||||
} else {
|
||||
ret[key] = null;
|
||||
}
|
||||
},
|
||||
|
||||
convert(obj) {
|
||||
if (obj !== undefined && typeof obj !== "object") {
|
||||
throw new TypeError("Dictionary has to be an object");
|
||||
}
|
||||
if (obj instanceof Date || obj instanceof RegExp) {
|
||||
throw new TypeError("Dictionary may not be a Date or RegExp object");
|
||||
}
|
||||
|
||||
const ret = Object.create(null);
|
||||
module.exports.convertInherit(obj, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
20
node_modules/jsdom/lib/jsdom/living/generated/idl-utils.js
generated
vendored
Normal file
20
node_modules/jsdom/lib/jsdom/living/generated/idl-utils.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
module.exports.mixin = function mixin(target, source) {
|
||||
const keys = Object.getOwnPropertyNames(source);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.wrapperSymbol = Symbol("wrapper");
|
||||
module.exports.implSymbol = Symbol("impl");
|
||||
|
||||
module.exports.wrapperForImpl = function (impl) {
|
||||
return impl[module.exports.wrapperSymbol];
|
||||
};
|
||||
|
||||
module.exports.implForWrapper = function (wrapper) {
|
||||
return wrapper[module.exports.implSymbol];
|
||||
};
|
||||
|
||||
20
node_modules/jsdom/lib/jsdom/living/generated/utils.js
generated
vendored
Normal file
20
node_modules/jsdom/lib/jsdom/living/generated/utils.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
module.exports.mixin = function mixin(target, source) {
|
||||
const keys = Object.getOwnPropertyNames(source);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.wrapperSymbol = Symbol("wrapper");
|
||||
module.exports.implSymbol = Symbol("impl");
|
||||
|
||||
module.exports.wrapperForImpl = function (impl) {
|
||||
return impl[module.exports.wrapperSymbol];
|
||||
};
|
||||
|
||||
module.exports.implForWrapper = function (wrapper) {
|
||||
return wrapper[module.exports.implSymbol];
|
||||
};
|
||||
|
||||
43
node_modules/jsdom/lib/jsdom/living/helpers/document-base-url.js
generated
vendored
Normal file
43
node_modules/jsdom/lib/jsdom/living/helpers/document-base-url.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
const internalQuerySelector = require("../selectors").querySelector;
|
||||
const internalGetAttr = require("../attributes").getAttributeValue;
|
||||
const URL = require("../../utils").URL;
|
||||
|
||||
exports.documentBaseURL = function (document) {
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#document-base-url
|
||||
|
||||
const firstBase = internalQuerySelector(document, "base[href]");
|
||||
const fallbackBaseURL = exports.fallbackBaseURL(document);
|
||||
|
||||
if (firstBase === null) {
|
||||
return fallbackBaseURL;
|
||||
}
|
||||
|
||||
return exports.frozenBaseURL(firstBase, fallbackBaseURL);
|
||||
};
|
||||
|
||||
exports.fallbackBaseURL = function (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) {
|
||||
return module.exports.documentBaseURL(document._defaultView._parent._document);
|
||||
}
|
||||
|
||||
return document._URL;
|
||||
};
|
||||
|
||||
exports.frozenBaseURL = function (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 = internalGetAttr(baseElement, "href");
|
||||
|
||||
try {
|
||||
return new URL(baseHrefAttribute, fallbackBaseURL).href;
|
||||
} catch (e) {
|
||||
return fallbackBaseURL;
|
||||
}
|
||||
};
|
||||
17
node_modules/jsdom/lib/jsdom/living/helpers/internal-constants.js
generated
vendored
Normal file
17
node_modules/jsdom/lib/jsdom/living/helpers/internal-constants.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
const SymbolTree = require("symbol-tree");
|
||||
|
||||
exports.cloningSteps = Symbol("cloning steps");
|
||||
exports.locationInfo = Symbol("location info");
|
||||
exports.accept = Symbol("accept");
|
||||
exports.requestManager = Symbol("request manager");
|
||||
exports.pool = Symbol("pool");
|
||||
exports.agentOptions = Symbol("agentOptions");
|
||||
|
||||
// TODO: the many underscore-prefixed hooks should move here
|
||||
// E.g. _attrModified (which maybe should be split into its per-spec variants)
|
||||
|
||||
/**
|
||||
* This SymbolTree is used to build the tree for all Node in a document
|
||||
*/
|
||||
exports.domSymbolTree = new SymbolTree("DOM SymbolTree");
|
||||
5
node_modules/jsdom/lib/jsdom/living/helpers/ordered-set-parser.js
generated
vendored
Normal file
5
node_modules/jsdom/lib/jsdom/living/helpers/ordered-set-parser.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function orderedSetParser(input) {
|
||||
return new Set(input.split(/\s+/).filter(Boolean));
|
||||
};
|
||||
11
node_modules/jsdom/lib/jsdom/living/helpers/proxied-window-event-handlers.js
generated
vendored
Normal file
11
node_modules/jsdom/lib/jsdom/living/helpers/proxied-window-event-handlers.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers-on-elements,-document-objects,-and-window-objects
|
||||
|
||||
module.exports = new Set(["onblur", "onerror", "onfocus", "onload", "onresize", "onscroll", "onafterprint",
|
||||
"onbeforeprint", "onbeforeunload", "onhashchange", "onlanguagechange", "onmessage", "onoffline", "ononline",
|
||||
"onpagehide", "onpageshow", "onpopstate", "onstorage", "onunload"]);
|
||||
|
||||
// level2/html sets up setters/getters on HTMLBodyElement that proxy to the window (setting data properties there)
|
||||
// level1/core sets up so that modifying the appropriate attributes on body elements will forward to setting on
|
||||
// the window, with the appropriate `this`.
|
||||
61
node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js
generated
vendored
Normal file
61
node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
const util = require("util");
|
||||
const ErrorEvent = require("../generated/ErrorEvent").interface;
|
||||
|
||||
const errorReportingMode = Symbol("error reporting mode");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error
|
||||
// Omits script parameter and any check for muted errors; takes error object, message, and location as params, unlike
|
||||
// the spec. Returns whether the event was handled or not.
|
||||
function reportAnError(line, col, target, errorObject, message, location) {
|
||||
if (errorReportingMode in target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
target[errorReportingMode] = true;
|
||||
|
||||
// TODO Events: use constructor directly, once they are no longer tied to a window.
|
||||
const event = new ErrorEvent("error", {
|
||||
bubbles: false,
|
||||
cancelable: true,
|
||||
message,
|
||||
filename: location,
|
||||
lineno: line,
|
||||
colno: col,
|
||||
error: errorObject
|
||||
});
|
||||
|
||||
target.dispatchEvent(event);
|
||||
|
||||
delete target[errorReportingMode];
|
||||
|
||||
return event.defaultPrevented;
|
||||
}
|
||||
|
||||
module.exports = function reportException(window, error, filenameHint) {
|
||||
// This function will give good results on real Error objects with stacks; poor ones otherwise
|
||||
|
||||
const stack = error && error.stack;
|
||||
const lines = stack && stack.split("\n");
|
||||
|
||||
// Find the first line that matches; important for multi-line messages
|
||||
let pieces;
|
||||
if (lines) {
|
||||
for (let i = 1; i < lines.length && !pieces; ++i) {
|
||||
pieces = lines[i].match(/at (?:(.+)\s+)?\(?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/);
|
||||
}
|
||||
}
|
||||
|
||||
const fileName = pieces && pieces[2] || filenameHint || window._document._URL;
|
||||
const lineNumber = pieces && parseInt(pieces[3]) || 0;
|
||||
const columnNumber = pieces && parseInt(pieces[4]) || 0;
|
||||
|
||||
const handled = reportAnError(lineNumber, columnNumber, window, error, error.message, fileName);
|
||||
|
||||
if (!handled) {
|
||||
const jsdomError = new Error(`Uncaught ${util.inspect(error)}`);
|
||||
jsdomError.detail = error;
|
||||
|
||||
window._virtualConsole.emit("jsdomError", jsdomError);
|
||||
}
|
||||
};
|
||||
62
node_modules/jsdom/lib/jsdom/living/helpers/validate-names.js
generated
vendored
Normal file
62
node_modules/jsdom/lib/jsdom/living/helpers/validate-names.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
const xnv = require("xml-name-validator");
|
||||
const DOMException = require("../../web-idl/DOMException");
|
||||
|
||||
// https://dom.spec.whatwg.org/#validate
|
||||
|
||||
exports.name = function (name) {
|
||||
const result = xnv.name(name);
|
||||
if (!result.success) {
|
||||
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
|
||||
"\"" + name + "\" did not match the Name production: " + result.error);
|
||||
}
|
||||
};
|
||||
|
||||
exports.qname = function (qname) {
|
||||
exports.name(qname);
|
||||
|
||||
const result = xnv.qname(qname);
|
||||
if (!result.success) {
|
||||
throw new DOMException(DOMException.NAMESPACE_ERR,
|
||||
"\"" + qname + "\" did not match the QName production: " + result.error);
|
||||
}
|
||||
};
|
||||
|
||||
exports.validateAndExtract = function (namespace, qualifiedName) {
|
||||
if (namespace === "") {
|
||||
namespace = null;
|
||||
}
|
||||
|
||||
exports.qname(qualifiedName);
|
||||
|
||||
let prefix = null;
|
||||
let localName = qualifiedName;
|
||||
|
||||
const colonIndex = qualifiedName.indexOf(":");
|
||||
if (colonIndex !== -1) {
|
||||
prefix = qualifiedName.substring(0, colonIndex);
|
||||
localName = qualifiedName.substring(colonIndex + 1);
|
||||
}
|
||||
|
||||
if (prefix !== null && namespace === null) {
|
||||
throw new DOMException(DOMException.NAMESPACE_ERR,
|
||||
"A namespace was given but a prefix was also extracted from the qualifiedName");
|
||||
}
|
||||
|
||||
if (prefix === "xml" && namespace !== "http://www.w3.org/XML/1998/namespace") {
|
||||
throw new DOMException(DOMException.NAMESPACE_ERR,
|
||||
"A prefix of \"xml\" was given but the namespace was not the XML namespace");
|
||||
}
|
||||
|
||||
if ((qualifiedName === "xmlns" || prefix === "xmlns") && namespace !== "http://www.w3.org/2000/xmlns/") {
|
||||
throw new DOMException(DOMException.NAMESPACE_ERR,
|
||||
"A prefix or qualifiedName of \"xmlns\" was given but the namespace was not the XMLNS namespace");
|
||||
}
|
||||
|
||||
if (namespace === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && prefix !== "xmlns") {
|
||||
throw new DOMException(DOMException.NAMESPACE_ERR,
|
||||
"The XMLNS namespace was given but neither the prefix nor qualifiedName was \"xmlns\"");
|
||||
}
|
||||
|
||||
return { namespace, prefix, localName };
|
||||
};
|
||||
95
node_modules/jsdom/lib/jsdom/living/html-collection.js
generated
vendored
Normal file
95
node_modules/jsdom/lib/jsdom/living/html-collection.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
const lengthFromProperties = require("../utils").lengthFromProperties;
|
||||
const getAttributeValue = require("./attributes").getAttributeValue;
|
||||
|
||||
const privates = Symbol("HTMLCollection internal slots");
|
||||
|
||||
class HTMLCollection {
|
||||
constructor(secret, element, query) {
|
||||
if (secret !== privates) {
|
||||
throw new TypeError("Invalid constructor");
|
||||
}
|
||||
|
||||
this[privates] = { element, query, snapshot: undefined, keys: [], length: 0, version: -1 };
|
||||
updateHTMLCollection(this);
|
||||
}
|
||||
|
||||
get length() {
|
||||
updateHTMLCollection(this);
|
||||
return this[privates].length;
|
||||
}
|
||||
|
||||
item(index) {
|
||||
updateHTMLCollection(this);
|
||||
return this[index] || null;
|
||||
}
|
||||
|
||||
namedItem(name) {
|
||||
updateHTMLCollection(this);
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
||||
return this[name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function updateHTMLCollection(collection) {
|
||||
if (collection[privates].version < collection[privates].element._version) {
|
||||
collection[privates].snapshot = collection[privates].query();
|
||||
resetHTMLCollectionTo(collection, collection[privates].snapshot);
|
||||
collection[privates].version = collection[privates].element._version;
|
||||
}
|
||||
}
|
||||
|
||||
function resetHTMLCollectionTo(collection, els) {
|
||||
const startingLength = lengthFromProperties(collection);
|
||||
for (let i = 0; i < startingLength; ++i) {
|
||||
delete collection[i];
|
||||
}
|
||||
|
||||
for (let i = 0; i < els.length; ++i) {
|
||||
collection[i] = els[i];
|
||||
}
|
||||
collection[privates].length = els.length;
|
||||
|
||||
const keys = collection[privates].keys;
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
delete collection[keys[i]];
|
||||
}
|
||||
keys.length = 0;
|
||||
|
||||
for (let i = 0; i < els.length; ++i) {
|
||||
addIfAttrPresent(els[i], "name");
|
||||
}
|
||||
for (let i = 0; i < els.length; ++i) {
|
||||
addIfAttrPresent(els[i], "id");
|
||||
}
|
||||
|
||||
function addIfAttrPresent(el, attr) {
|
||||
const value = getAttributeValue(el, attr);
|
||||
|
||||
if (value === null || value === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't overwrite numeric indices with named ones.
|
||||
const valueAsNumber = Number(value);
|
||||
if (!Number.isNaN(valueAsNumber) && valueAsNumber >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
collection[value] = el;
|
||||
keys.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (core) {
|
||||
core.HTMLCollection = HTMLCollection;
|
||||
};
|
||||
|
||||
module.exports.create = function (element, query) {
|
||||
return new HTMLCollection(privates, element, query);
|
||||
};
|
||||
|
||||
module.exports.update = updateHTMLCollection;
|
||||
39
node_modules/jsdom/lib/jsdom/living/index.js
generated
vendored
Normal file
39
node_modules/jsdom/lib/jsdom/living/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
const core = module.exports = require("../level1/core");
|
||||
|
||||
// These (because of how they were written) directly include level1/core and modify it.
|
||||
// ORDER IS IMPORTANT
|
||||
require("../level2/core");
|
||||
require("../level2/events");
|
||||
require("../level2/html");
|
||||
require("../level2/style");
|
||||
require("../level3/core");
|
||||
require("../level3/ls");
|
||||
require("../level3/xpath");
|
||||
|
||||
require("./document-type")(core);
|
||||
require("./character-data")(core);
|
||||
require("./processing-instruction")(core);
|
||||
require("./comment")(core);
|
||||
require("./text")(core);
|
||||
require("./dom-implementation")(core);
|
||||
require("./document")(core);
|
||||
require("./element")(core);
|
||||
require("./html-collection")(core);
|
||||
require("./node-filter")(core);
|
||||
require("./node-iterator")(core);
|
||||
require("./node-list")(core);
|
||||
require("./node")(core);
|
||||
require("./selectors")(core);
|
||||
require("./parent-node")(core);
|
||||
require("./non-document-type-child-node")(core);
|
||||
require("./url")(core);
|
||||
require("./blob")(core);
|
||||
require("./file")(core);
|
||||
require("./filelist")(core);
|
||||
require("./form-data")(core);
|
||||
require("./xmlhttprequest-event-target")(core);
|
||||
require("./xmlhttprequest-upload")(core);
|
||||
|
||||
core.Attr = require("./generated/Attr").interface;
|
||||
core.DOMTokenList = require("./dom-token-list").DOMTokenList;
|
||||
137
node_modules/jsdom/lib/jsdom/living/named-properties-window.js
generated
vendored
Normal file
137
node_modules/jsdom/lib/jsdom/living/named-properties-window.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
const hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
const namedPropertiesTracker = require("../named-properties-tracker");
|
||||
const NODE_TYPE = require("./node-type");
|
||||
const createHTMLCollection = require("./html-collection").create;
|
||||
const treeOrderSorter = require("../utils").treeOrderSorter;
|
||||
|
||||
function isNamedPropertyElement(element) {
|
||||
// (for the name attribute)
|
||||
|
||||
// use hasOwnProperty to make sure contentWindow comes from the prototype,
|
||||
// and is not set directly on the node by a script.
|
||||
if ("contentWindow" in element && !hasOwnProp.call(element, "contentWindow")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (element.nodeName) {
|
||||
case "A":
|
||||
case "APPLET":
|
||||
case "AREA":
|
||||
case "EMBED":
|
||||
case "FORM":
|
||||
case "FRAMESET":
|
||||
case "IMG":
|
||||
case "OBJECT":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function namedPropertyResolver(HTMLCollection, window, name, values) {
|
||||
function getResult() {
|
||||
const results = [];
|
||||
|
||||
for (const node of values().keys()) {
|
||||
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.getAttribute("id") === name) {
|
||||
results.push(node);
|
||||
} else if (node.getAttribute("name") === name && isNamedPropertyElement(node)) {
|
||||
results.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
results.sort(treeOrderSorter);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
const document = window._document;
|
||||
const objects = createHTMLCollection(document.documentElement, getResult);
|
||||
|
||||
const length = objects.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const node = objects[i];
|
||||
|
||||
if ("contentWindow" in node && !hasOwnProp.call(node, "contentWindow")) {
|
||||
return node.contentWindow;
|
||||
}
|
||||
}
|
||||
|
||||
if (length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (length === 1) {
|
||||
return objects[0];
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
exports.initializeWindow = function (window, HTMLCollection) {
|
||||
namedPropertiesTracker.create(window, namedPropertyResolver.bind(null, HTMLCollection));
|
||||
};
|
||||
|
||||
exports.elementAttributeModified = function (element, name, value, oldValue) {
|
||||
if (!element._attached) {
|
||||
return;
|
||||
}
|
||||
|
||||
const useName = isNamedPropertyElement(element);
|
||||
|
||||
if (name === "id" || (name === "name" && useName)) {
|
||||
const tracker = namedPropertiesTracker.get(element._ownerDocument._global);
|
||||
|
||||
// (tracker will be null if the document has no Window)
|
||||
if (tracker) {
|
||||
if (name === "id" && (!useName || element.getAttribute("name") !== oldValue)) {
|
||||
tracker.untrack(oldValue, element);
|
||||
}
|
||||
|
||||
if (name === "name" && element.getAttribute("id") !== oldValue) {
|
||||
tracker.untrack(oldValue, element);
|
||||
}
|
||||
|
||||
tracker.track(value, element);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.nodeAttachedToDocument = function (node) {
|
||||
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tracker = namedPropertiesTracker.get(node._ownerDocument._global);
|
||||
if (!tracker) {
|
||||
return;
|
||||
}
|
||||
|
||||
tracker.track(node.getAttribute("id"), node);
|
||||
|
||||
if (isNamedPropertyElement(node)) {
|
||||
tracker.track(node.getAttribute("name"), node);
|
||||
}
|
||||
};
|
||||
|
||||
exports.nodeDetachedFromDocument = function (node) {
|
||||
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tracker = namedPropertiesTracker.get(node._ownerDocument._global);
|
||||
if (!tracker) {
|
||||
return;
|
||||
}
|
||||
|
||||
tracker.untrack(node.getAttribute("id"), node);
|
||||
|
||||
if (isNamedPropertyElement(node)) {
|
||||
tracker.untrack(node.getAttribute("name"), node);
|
||||
}
|
||||
};
|
||||
47
node_modules/jsdom/lib/jsdom/living/node-filter.js
generated
vendored
Normal file
47
node_modules/jsdom/lib/jsdom/living/node-filter.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
const addConstants = require("../utils").addConstants;
|
||||
|
||||
module.exports = function (core) {
|
||||
// https://dom.spec.whatwg.org/#interface-nodefilter
|
||||
core.NodeFilter = function () {
|
||||
throw new TypeError("Illegal constructor");
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an unsigned short that will be used to tell if a given Node must
|
||||
* be accepted or not by the NodeIterator or TreeWalker iteration
|
||||
* algorithm. This method is expected to be written by the user of a
|
||||
* NodeFilter.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/NodeFilter
|
||||
* @interface
|
||||
*
|
||||
* @param {Node} node DOM Node
|
||||
* @return {FILTER_ACCEPT|FILTER_REJECT|FILTER_SKIP}
|
||||
*/
|
||||
core.NodeFilter.acceptNode = function (/* node */) {
|
||||
throw new Error("This method is expected to be written by the user of a NodeFilter.");
|
||||
};
|
||||
|
||||
addConstants(core.NodeFilter, {
|
||||
// Constants for whatToShow
|
||||
SHOW_ALL: 0xFFFFFFFF,
|
||||
SHOW_ELEMENT: 0x00000001,
|
||||
SHOW_ATTRIBUTE: 0x00000002,
|
||||
SHOW_TEXT: 0x00000004,
|
||||
SHOW_CDATA_SECTION: 0x00000008,
|
||||
SHOW_ENTITY_REFERENCE: 0x00000010,
|
||||
SHOW_ENTITY: 0x00000020,
|
||||
SHOW_PROCESSING_INSTRUCTION: 0x00000040,
|
||||
SHOW_COMMENT: 0x00000080,
|
||||
SHOW_DOCUMENT: 0x00000100,
|
||||
SHOW_DOCUMENT_TYPE: 0x00000200,
|
||||
SHOW_DOCUMENT_FRAGMENT: 0x00000400,
|
||||
SHOW_NOTATION: 0x00000800,
|
||||
|
||||
// Constants returned by acceptNode
|
||||
FILTER_ACCEPT: 1,
|
||||
FILTER_REJECT: 2,
|
||||
FILTER_SKIP: 3
|
||||
});
|
||||
};
|
||||
229
node_modules/jsdom/lib/jsdom/living/node-iterator.js
generated
vendored
Normal file
229
node_modules/jsdom/lib/jsdom/living/node-iterator.js
generated
vendored
Normal file
@@ -0,0 +1,229 @@
|
||||
"use strict";
|
||||
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const INTERNAL = Symbol("NodeIterator internal");
|
||||
|
||||
module.exports = function (core) {
|
||||
// https://dom.spec.whatwg.org/#interface-nodeiterator
|
||||
|
||||
function NodeIteratorInternal(document, root, whatToShow, filter) {
|
||||
this.active = true;
|
||||
this.document = document;
|
||||
this.root = root;
|
||||
this.referenceNode = root;
|
||||
this.pointerBeforeReferenceNode = true;
|
||||
this.whatToShow = whatToShow;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
NodeIteratorInternal.prototype.throwIfNotActive = function () {
|
||||
// (only thrown for getters/methods that are affected by removing steps)
|
||||
if (!this.active) {
|
||||
throw Error("This NodeIterator is no longer active. " +
|
||||
"More than " + this.document._activeNodeIteratorsMax +
|
||||
" iterators are being used concurrently. " +
|
||||
"You can increase the 'concurrentNodeIterators' option to " +
|
||||
"make this error go away."
|
||||
);
|
||||
// Alternatively, you can pester Ecma to add support for weak references,
|
||||
// the DOM standard assumes the implementor has control over object life cycles.
|
||||
}
|
||||
};
|
||||
|
||||
NodeIteratorInternal.prototype.traverse = function (next) {
|
||||
let node = this.referenceNode;
|
||||
let beforeNode = this.pointerBeforeReferenceNode;
|
||||
|
||||
do {
|
||||
if (next) {
|
||||
if (!beforeNode) {
|
||||
node = domSymbolTree.following(node, { root: this.root });
|
||||
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
beforeNode = false;
|
||||
} else { // previous
|
||||
if (beforeNode) {
|
||||
node = domSymbolTree.preceding(node, { root: this.root });
|
||||
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
beforeNode = true;
|
||||
}
|
||||
}
|
||||
while (this.filterNode(node) !== core.NodeFilter.FILTER_ACCEPT);
|
||||
|
||||
this.pointerBeforeReferenceNode = beforeNode;
|
||||
this.referenceNode = node;
|
||||
return node;
|
||||
};
|
||||
|
||||
NodeIteratorInternal.prototype.filterNode = function (node) {
|
||||
const n = node.nodeType - 1;
|
||||
if (!(this.whatToShow & (1 << n))) {
|
||||
return core.NodeFilter.FILTER_SKIP;
|
||||
}
|
||||
|
||||
let ret = core.NodeFilter.FILTER_ACCEPT;
|
||||
const filter = this.filter;
|
||||
if (typeof filter === "function") {
|
||||
ret = filter(node);
|
||||
} else if (filter && typeof filter.acceptNode === "function") {
|
||||
ret = filter.acceptNode(node);
|
||||
}
|
||||
|
||||
if (ret === true) {
|
||||
return core.NodeFilter.FILTER_ACCEPT;
|
||||
} else if (ret === false) {
|
||||
return core.NodeFilter.FILTER_REJECT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
NodeIteratorInternal.prototype.runRemovingSteps = function (oldNode, oldParent, oldPreviousSibling) {
|
||||
if (oldNode.contains(this.root)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If oldNode is not an inclusive ancestor of the referenceNode
|
||||
// attribute value, terminate these steps.
|
||||
if (!oldNode.contains(this.referenceNode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.pointerBeforeReferenceNode) {
|
||||
// Let nextSibling be oldPreviousSibling’s next sibling, if oldPreviousSibling is non-null,
|
||||
// and oldParent’s first child otherwise.
|
||||
const nextSibling = oldPreviousSibling ?
|
||||
oldPreviousSibling.nextSibling :
|
||||
oldParent.firstChild;
|
||||
|
||||
// If nextSibling is non-null, set the referenceNode attribute to nextSibling
|
||||
// and terminate these steps.
|
||||
if (nextSibling) {
|
||||
this.referenceNode = nextSibling;
|
||||
return;
|
||||
}
|
||||
|
||||
// Let next be the first node following oldParent (excluding any children of oldParent).
|
||||
const next = domSymbolTree.following(oldParent, { skipChildren: true });
|
||||
|
||||
// If root is an inclusive ancestor of next, set the referenceNode
|
||||
// attribute to next and terminate these steps.
|
||||
if (this.root.contains(next)) {
|
||||
this.referenceNode = next;
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, set the pointerBeforeReferenceNode attribute to false.
|
||||
this.pointerBeforeReferenceNode = false;
|
||||
|
||||
// Note: Steps are not terminated here.
|
||||
}
|
||||
|
||||
// Set the referenceNode attribute to the last inclusive descendant in tree order of oldPreviousSibling,
|
||||
// if oldPreviousSibling is non-null, and to oldParent otherwise.
|
||||
this.referenceNode = oldPreviousSibling ?
|
||||
domSymbolTree.lastInclusiveDescendant(oldPreviousSibling) :
|
||||
oldParent;
|
||||
};
|
||||
|
||||
core.Document._removingSteps.push((document, oldNode, oldParent, oldPreviousSibling) => {
|
||||
for (let i = 0; i < document._activeNodeIterators.length; ++i) {
|
||||
const internal = document._activeNodeIterators[i];
|
||||
internal.runRemovingSteps(oldNode, oldParent, oldPreviousSibling);
|
||||
}
|
||||
});
|
||||
|
||||
core.Document.prototype.createNodeIterator = function (root, whatToShow, filter) {
|
||||
if (!root) {
|
||||
throw new TypeError("Not enough arguments to Document.createNodeIterator.");
|
||||
}
|
||||
|
||||
if (filter === undefined) {
|
||||
filter = null;
|
||||
}
|
||||
|
||||
if (filter !== null &&
|
||||
typeof filter !== "function" &&
|
||||
typeof filter.acceptNode !== "function") {
|
||||
throw new TypeError("Argument 3 of Document.createNodeIterator should be a function or implement NodeFilter.");
|
||||
}
|
||||
|
||||
const document = root._ownerDocument;
|
||||
|
||||
whatToShow = whatToShow === undefined ?
|
||||
core.NodeFilter.SHOW_ALL :
|
||||
(whatToShow & core.NodeFilter.SHOW_ALL) >>> 0; // >>> makes sure the result is unsigned
|
||||
|
||||
filter = filter || null;
|
||||
|
||||
const it = Object.create(core.NodeIterator.prototype);
|
||||
const internal = new NodeIteratorInternal(document, root, whatToShow, filter);
|
||||
it[INTERNAL] = internal;
|
||||
|
||||
document._activeNodeIterators.push(internal);
|
||||
while (document._activeNodeIterators.length > document._activeNodeIteratorsMax) {
|
||||
const internalOther = document._activeNodeIterators.shift();
|
||||
internalOther.active = false;
|
||||
}
|
||||
|
||||
return it;
|
||||
};
|
||||
|
||||
core.NodeIterator = function NodeIterator() {
|
||||
throw new TypeError("Illegal constructor");
|
||||
};
|
||||
|
||||
defineGetter(core.NodeIterator.prototype, "root", function () {
|
||||
return this[INTERNAL].root;
|
||||
});
|
||||
|
||||
defineGetter(core.NodeIterator.prototype, "referenceNode", function () {
|
||||
const internal = this[INTERNAL];
|
||||
internal.throwIfNotActive();
|
||||
return internal.referenceNode;
|
||||
});
|
||||
|
||||
defineGetter(core.NodeIterator.prototype, "pointerBeforeReferenceNode", function () {
|
||||
const internal = this[INTERNAL];
|
||||
internal.throwIfNotActive();
|
||||
return internal.pointerBeforeReferenceNode;
|
||||
});
|
||||
|
||||
defineGetter(core.NodeIterator.prototype, "whatToShow", function () {
|
||||
return this[INTERNAL].whatToShow;
|
||||
});
|
||||
|
||||
defineGetter(core.NodeIterator.prototype, "filter", function () {
|
||||
return this[INTERNAL].filter;
|
||||
});
|
||||
|
||||
core.NodeIterator.prototype.previousNode = function () {
|
||||
const internal = this[INTERNAL];
|
||||
internal.throwIfNotActive();
|
||||
return internal.traverse(false);
|
||||
};
|
||||
|
||||
core.NodeIterator.prototype.nextNode = function () {
|
||||
const internal = this[INTERNAL];
|
||||
internal.throwIfNotActive();
|
||||
return internal.traverse(true);
|
||||
};
|
||||
|
||||
core.NodeIterator.prototype.detach = function () {
|
||||
// noop
|
||||
};
|
||||
|
||||
core.NodeIterator.prototype.toString = function () {
|
||||
return "[object NodeIterator]";
|
||||
};
|
||||
};
|
||||
83
node_modules/jsdom/lib/jsdom/living/node-list.js
generated
vendored
Normal file
83
node_modules/jsdom/lib/jsdom/living/node-list.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
const lengthFromProperties = require("../utils").lengthFromProperties;
|
||||
|
||||
const privates = Symbol("NodeList internal slots");
|
||||
|
||||
class NodeList {
|
||||
constructor(secret, config) {
|
||||
if (secret !== privates) {
|
||||
throw new TypeError("Invalid constructor");
|
||||
}
|
||||
|
||||
if (config.nodes) {
|
||||
this[privates] = {
|
||||
isLive: false,
|
||||
length: config.nodes.length
|
||||
};
|
||||
|
||||
for (let i = 0; i < config.nodes.length; ++i) {
|
||||
this[i] = config.nodes[i];
|
||||
}
|
||||
} else {
|
||||
this[privates] = {
|
||||
isLive: true,
|
||||
element: config.element,
|
||||
query: config.query,
|
||||
snapshot: undefined,
|
||||
length: 0,
|
||||
version: -1
|
||||
};
|
||||
updateNodeList(this);
|
||||
}
|
||||
}
|
||||
|
||||
get length() {
|
||||
updateNodeList(this);
|
||||
return this[privates].length;
|
||||
}
|
||||
|
||||
item(index) {
|
||||
updateNodeList(this);
|
||||
return this[index] || null;
|
||||
}
|
||||
}
|
||||
|
||||
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
||||
|
||||
function updateNodeList(nodeList) {
|
||||
if (nodeList[privates].isLive) {
|
||||
if (nodeList[privates].version < nodeList[privates].element._version) {
|
||||
nodeList[privates].snapshot = nodeList[privates].query();
|
||||
resetNodeListTo(nodeList, nodeList[privates].snapshot);
|
||||
nodeList[privates].version = nodeList[privates].element._version;
|
||||
}
|
||||
} else {
|
||||
nodeList[privates].length = lengthFromProperties(nodeList);
|
||||
}
|
||||
}
|
||||
|
||||
function resetNodeListTo(nodeList, nodes) {
|
||||
const startingLength = lengthFromProperties(nodeList);
|
||||
for (let i = 0; i < startingLength; ++i) {
|
||||
delete nodeList[i];
|
||||
}
|
||||
|
||||
for (let i = 0; i < nodes.length; ++i) {
|
||||
nodeList[i] = nodes[i];
|
||||
}
|
||||
nodeList[privates].length = nodes.length;
|
||||
}
|
||||
|
||||
module.exports = function (core) {
|
||||
core.NodeList = NodeList;
|
||||
};
|
||||
|
||||
module.exports.createLive = function (element, query) {
|
||||
return new NodeList(privates, { element, query });
|
||||
};
|
||||
|
||||
module.exports.createStatic = function (nodes) {
|
||||
return new NodeList(privates, { nodes });
|
||||
};
|
||||
|
||||
module.exports.update = updateNodeList;
|
||||
16
node_modules/jsdom/lib/jsdom/living/node-type.js
generated
vendored
Normal file
16
node_modules/jsdom/lib/jsdom/living/node-type.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = Object.freeze({
|
||||
ELEMENT_NODE: 1,
|
||||
ATTRIBUTE_NODE: 2, // historical
|
||||
TEXT_NODE: 3,
|
||||
CDATA_SECTION_NODE: 4, // historical
|
||||
ENTITY_REFERENCE_NODE: 5, // historical
|
||||
ENTITY_NODE: 6, // historical
|
||||
PROCESSING_INSTRUCTION_NODE: 7,
|
||||
COMMENT_NODE: 8,
|
||||
DOCUMENT_NODE: 9,
|
||||
DOCUMENT_TYPE_NODE: 10,
|
||||
DOCUMENT_FRAGMENT_NODE: 11,
|
||||
NOTATION_NODE: 12 // historical
|
||||
});
|
||||
250
node_modules/jsdom/lib/jsdom/living/node.js
generated
vendored
Normal file
250
node_modules/jsdom/lib/jsdom/living/node.js
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
"use strict";
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const simultaneousIterators = require("../utils").simultaneousIterators;
|
||||
const attributes = require("./attributes");
|
||||
const cloneDoctype = require("./document-type").clone;
|
||||
const cloningSteps = require("./helpers/internal-constants").cloningSteps;
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("./node-type");
|
||||
const documentBaseURL = require("./helpers/document-base-url").documentBaseURL;
|
||||
const orderedSetParser = require("./helpers/ordered-set-parser");
|
||||
const createHTMLCollection = require("./html-collection").create;
|
||||
const domTokenListContains = require("./dom-token-list").contains;
|
||||
const getDoctypePrivates = require("./document-type").getPrivates;
|
||||
|
||||
module.exports = function (core) {
|
||||
const DOCUMENT_POSITION_DISCONNECTED = core.Node.DOCUMENT_POSITION_DISCONNECTED;
|
||||
const DOCUMENT_POSITION_FOLLOWING = core.Node.DOCUMENT_POSITION_FOLLOWING;
|
||||
const DOCUMENT_POSITION_CONTAINED_BY = core.Node.DOCUMENT_POSITION_CONTAINED_BY;
|
||||
const DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = core.Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
|
||||
|
||||
/**
|
||||
* Return true if node is of a type obsoleted by the WHATWG living standard
|
||||
* @param {Node} node
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function isObsoleteNodeType(node) {
|
||||
return node.nodeType === NODE_TYPE.ENTITY_NODE ||
|
||||
node.nodeType === NODE_TYPE.ENTITY_REFERENCE_NODE ||
|
||||
node.nodeType === NODE_TYPE.NOTATION_NODE ||
|
||||
node.nodeType === NODE_TYPE.CDATA_SECTION_NODE;
|
||||
}
|
||||
|
||||
core.Node.prototype.cloneNode = function (deep) {
|
||||
deep = Boolean(deep);
|
||||
|
||||
return module.exports.clone(core, this, undefined, deep);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a bitmask Number composed of DOCUMENT_POSITION constants based upon the rules defined in
|
||||
* http://dom.spec.whatwg.org/#dom-node-comparedocumentposition
|
||||
* @param {Node} other
|
||||
* @return {Number}
|
||||
*/
|
||||
core.Node.prototype.compareDocumentPosition = function (other) {
|
||||
// Let reference be the context object.
|
||||
const reference = this;
|
||||
|
||||
if (!(other instanceof core.Node)) {
|
||||
throw new Error("Comparing position against non-Node values is not allowed");
|
||||
}
|
||||
|
||||
if (isObsoleteNodeType(reference) || isObsoleteNodeType(other)) {
|
||||
throw new Error("Obsolete node type");
|
||||
}
|
||||
|
||||
const result = domSymbolTree.compareTreePosition(reference, other);
|
||||
|
||||
// “If other and reference are not in the same tree, return the result of adding DOCUMENT_POSITION_DISCONNECTED,
|
||||
// DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, and either DOCUMENT_POSITION_PRECEDING or
|
||||
// DOCUMENT_POSITION_FOLLOWING, with the constraint that this is to be consistent, together.”
|
||||
if (result === DOCUMENT_POSITION_DISCONNECTED) {
|
||||
// symbol-tree does not add these bits required by the spec:
|
||||
return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_FOLLOWING;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* The contains(other) method returns true if other is an inclusive descendant of the context object,
|
||||
* and false otherwise (including when other is null).
|
||||
* @param {[Node]} other [the node to test]
|
||||
* @return {[boolean]} [whether other is an inclusive descendant of this]
|
||||
*/
|
||||
core.Node.prototype.contains = function (other) {
|
||||
return Boolean(other instanceof core.Node &&
|
||||
(this === other || this.compareDocumentPosition(other) & DOCUMENT_POSITION_CONTAINED_BY)
|
||||
);
|
||||
};
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-node-parentelement
|
||||
defineGetter(core.Node.prototype, "parentElement", function () {
|
||||
const parentNode = domSymbolTree.parent(this);
|
||||
return parentNode !== null && parentNode.nodeType === NODE_TYPE.ELEMENT_NODE ? parentNode : null;
|
||||
});
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-baseuri
|
||||
defineGetter(core.Node.prototype, "baseURI", function () {
|
||||
return documentBaseURL(this._ownerDocument);
|
||||
});
|
||||
|
||||
function nodeEquals(a, b) {
|
||||
if (a.nodeType !== b.nodeType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (a.nodeType) {
|
||||
case NODE_TYPE.DOCUMENT_TYPE_NODE:
|
||||
const privatesA = getDoctypePrivates(a);
|
||||
const privatesB = getDoctypePrivates(b);
|
||||
if (privatesA.name !== privatesB.name || privatesA.publicId !== privatesB.publicId ||
|
||||
privatesA.systemId !== privatesB.systemId) {
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
|
||||
if (a._target !== b._target || a._data !== b._data) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case NODE_TYPE.TEXT_NODE:
|
||||
case NODE_TYPE.COMMENT_NODE:
|
||||
if (a._data !== b._data) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (a.nodeType === NODE_TYPE.ELEMENT_NODE && !attributes.attributeListsEqual(a, b)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const nodes of simultaneousIterators(domSymbolTree.childrenIterator(a), domSymbolTree.childrenIterator(b))) {
|
||||
if (!nodes[0] || !nodes[1]) {
|
||||
// mismatch in the amount of childNodes
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!nodeEquals(nodes[0], nodes[1])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-isequalnode
|
||||
core.Node.prototype.isEqualNode = function (node) {
|
||||
if (node === undefined) {
|
||||
// this is what Node? means in the IDL
|
||||
node = null;
|
||||
}
|
||||
|
||||
if (node === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fast-path, not in the spec
|
||||
if (this === node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return nodeEquals(this, node);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.clone = function (core, node, document, cloneChildren) {
|
||||
if (document === undefined) {
|
||||
document = node._ownerDocument;
|
||||
}
|
||||
|
||||
let copy;
|
||||
switch (node.nodeType) {
|
||||
case NODE_TYPE.DOCUMENT_NODE:
|
||||
// TODO: just use Document when we eliminate the difference between Document and HTMLDocument.
|
||||
copy = new node.constructor({
|
||||
contentType: node._contentType,
|
||||
url: node._URL,
|
||||
parsingMode: node._parsingMode
|
||||
});
|
||||
document = copy;
|
||||
break;
|
||||
|
||||
case NODE_TYPE.DOCUMENT_TYPE_NODE:
|
||||
copy = cloneDoctype(core, node);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.ELEMENT_NODE:
|
||||
copy = document._createElementWithCorrectElementInterface(node._localName, node._namespaceURI);
|
||||
copy._namespaceURI = node._namespaceURI;
|
||||
copy._prefix = node._prefix;
|
||||
copy._localName = node._localName;
|
||||
attributes.copyAttributeList(node, copy);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.TEXT_NODE:
|
||||
copy = new core.Text(document, node._data);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.COMMENT_NODE:
|
||||
copy = new core.Comment(document, node._data);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.PROCESSING_INSTRUCTION_NODE:
|
||||
copy = new core.ProcessingInstruction(document, node._target, node._data);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.DOCUMENT_FRAGMENT_NODE:
|
||||
copy = new core.DocumentFragment(document);
|
||||
break;
|
||||
}
|
||||
|
||||
if (node[cloningSteps]) {
|
||||
node[cloningSteps](copy, node, document, cloneChildren);
|
||||
}
|
||||
|
||||
if (cloneChildren) {
|
||||
for (const child of domSymbolTree.childrenIterator(node)) {
|
||||
const childCopy = module.exports.clone(core, child, document, true);
|
||||
copy.appendChild(childCopy);
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
module.exports.listOfElementsWithClassNames = function (classNames, root) {
|
||||
// https://dom.spec.whatwg.org/#concept-getElementsByClassName
|
||||
|
||||
const classes = orderedSetParser(classNames);
|
||||
|
||||
if (classes.size === 0) {
|
||||
return createHTMLCollection(root, () => false);
|
||||
}
|
||||
|
||||
return createHTMLCollection(root, () => {
|
||||
const isQuirksMode = root._ownerDocument.compatMode === "BackCompat";
|
||||
|
||||
return domSymbolTree.treeToArray(root, { filter(node) {
|
||||
if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const className of classes) {
|
||||
if (!domTokenListContains(node.classList, className, { caseInsensitive: isQuirksMode })) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} });
|
||||
});
|
||||
};
|
||||
29
node_modules/jsdom/lib/jsdom/living/non-document-type-child-node.js
generated
vendored
Normal file
29
node_modules/jsdom/lib/jsdom/living/non-document-type-child-node.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("./node-type");
|
||||
|
||||
module.exports = function (core) {
|
||||
// https://dom.spec.whatwg.org/#nondocumenttypechildnode
|
||||
|
||||
for (const Constructor of [core.Element, core.CharacterData]) {
|
||||
defineGetter(Constructor.prototype, "nextElementSibling", function () {
|
||||
for (const sibling of domSymbolTree.nextSiblingsIterator(this)) {
|
||||
if (sibling.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
return sibling;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
defineGetter(Constructor.prototype, "previousElementSibling", function () {
|
||||
for (const sibling of domSymbolTree.previousSiblingsIterator(this)) {
|
||||
if (sibling.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
return sibling;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
};
|
||||
50
node_modules/jsdom/lib/jsdom/living/parent-node.js
generated
vendored
Normal file
50
node_modules/jsdom/lib/jsdom/living/parent-node.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
const defineGetter = require("../utils").defineGetter;
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("./node-type");
|
||||
const createHTMLCollection = require("./html-collection").create;
|
||||
const updateHTMLCollection = require("./html-collection").update;
|
||||
|
||||
module.exports = function (core) {
|
||||
// https://dom.spec.whatwg.org/#interface-parentnode
|
||||
// Note that ParentNode is a "NoInterfaceObject"
|
||||
|
||||
for (const Constructor of [core.Document, core.DocumentFragment, core.Element]) {
|
||||
defineGetter(Constructor.prototype, "children", function () {
|
||||
if (!this._childrenList) {
|
||||
this._childrenList = createHTMLCollection(this, () => {
|
||||
return domSymbolTree.childrenToArray(this, { filter(node) {
|
||||
return node.nodeType === NODE_TYPE.ELEMENT_NODE;
|
||||
} });
|
||||
});
|
||||
} else {
|
||||
updateHTMLCollection(this._childrenList);
|
||||
}
|
||||
return this._childrenList;
|
||||
});
|
||||
|
||||
defineGetter(Constructor.prototype, "firstElementChild", function () {
|
||||
for (const child of domSymbolTree.childrenIterator(this)) {
|
||||
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
defineGetter(Constructor.prototype, "lastElementChild", function () {
|
||||
for (const child of domSymbolTree.childrenIterator(this, { reverse: true })) {
|
||||
if (child.nodeType === NODE_TYPE.ELEMENT_NODE) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
defineGetter(Constructor.prototype, "childElementCount", function () {
|
||||
return this.children.length;
|
||||
});
|
||||
}
|
||||
};
|
||||
36
node_modules/jsdom/lib/jsdom/living/post-message.js
generated
vendored
Normal file
36
node_modules/jsdom/lib/jsdom/living/post-message.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
const isValidTargetOrigin = require("../utils").isValidTargetOrigin;
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
|
||||
module.exports = function (message, targetOrigin) {
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError("'postMessage' requires 2 arguments: 'message' and 'targetOrigin'");
|
||||
}
|
||||
|
||||
targetOrigin = String(targetOrigin);
|
||||
|
||||
if (!isValidTargetOrigin(targetOrigin)) {
|
||||
throw new DOMException(DOMException.SYNTAX_ERR, "Failed to execute 'postMessage' on 'Window': " +
|
||||
"Invalid target origin '" + targetOrigin + "' in a call to 'postMessage'.");
|
||||
}
|
||||
|
||||
// TODO: targetOrigin === '/' - requires reference to source window
|
||||
// See https://github.com/tmpvar/jsdom/pull/1140#issuecomment-111587499
|
||||
if (targetOrigin !== "*" && targetOrigin !== this.origin) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: event.source - requires reference to source window
|
||||
// TODO: event.origin - requires reference to source window
|
||||
// TODO: event.ports
|
||||
// TODO: event.data - structured clone message - requires cloning DOM nodes
|
||||
const event = new this.MessageEvent("message", {
|
||||
data: message
|
||||
});
|
||||
|
||||
event.initEvent("message", false, false);
|
||||
|
||||
setTimeout(() => {
|
||||
this.dispatchEvent(event);
|
||||
}, 0);
|
||||
};
|
||||
18
node_modules/jsdom/lib/jsdom/living/processing-instruction.js
generated
vendored
Normal file
18
node_modules/jsdom/lib/jsdom/living/processing-instruction.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
const inheritFrom = require("../utils").inheritFrom;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
module.exports = function (core) {
|
||||
core.ProcessingInstruction = function ProcessingInstruction(ownerDocument, target, data) {
|
||||
core.CharacterData.call(this, ownerDocument, data);
|
||||
|
||||
this._target = target;
|
||||
};
|
||||
|
||||
inheritFrom(core.CharacterData, core.ProcessingInstruction, {
|
||||
nodeType: NODE_TYPE.PROCESSING_INSTRUCTION_NODE, // TODO should be on prototype, not here
|
||||
get target() {
|
||||
return this._target;
|
||||
}
|
||||
});
|
||||
};
|
||||
71
node_modules/jsdom/lib/jsdom/living/selectors.js
generated
vendored
Normal file
71
node_modules/jsdom/lib/jsdom/living/selectors.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
const nwmatcher = require("nwmatcher/src/nwmatcher-noqsa");
|
||||
const memoizeQuery = require("../utils").memoizeQuery;
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
const createStaticNodeList = require("../living/node-list").createStatic;
|
||||
const DOMException = require("../web-idl/DOMException");
|
||||
|
||||
module.exports = function (core) {
|
||||
for (const Class of [core.Document, core.DocumentFragment, core.Element]) {
|
||||
Class.prototype.querySelector = memoizeQuery(function (selectors) {
|
||||
selectors = String(selectors);
|
||||
const matcher = addNwmatcher(this);
|
||||
|
||||
try {
|
||||
return matcher.first(selectors, this);
|
||||
} catch (e) {
|
||||
throw new DOMException(DOMException.SYNTAX_ERR, e.message);
|
||||
}
|
||||
});
|
||||
|
||||
Class.prototype.querySelectorAll = memoizeQuery(function (selectors) {
|
||||
selectors = String(selectors);
|
||||
const matcher = addNwmatcher(this);
|
||||
|
||||
let list;
|
||||
try {
|
||||
list = matcher.select(selectors, this);
|
||||
} catch (e) {
|
||||
throw new DOMException(DOMException.SYNTAX_ERR, e.message);
|
||||
}
|
||||
|
||||
return createStaticNodeList(list);
|
||||
});
|
||||
}
|
||||
|
||||
core.Element.prototype.matches = memoizeQuery(function (selectors) {
|
||||
selectors = String(selectors);
|
||||
const matcher = addNwmatcher(this);
|
||||
|
||||
try {
|
||||
return matcher.match(this, selectors);
|
||||
} catch (e) {
|
||||
throw new DOMException(DOMException.SYNTAX_ERR, e.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Internal method so you don't have to go through the public API
|
||||
module.exports.querySelector = function (parentNode, selectors) {
|
||||
if (!domSymbolTree.hasChildren(parentNode) ||
|
||||
(parentNode === parentNode._ownerDocument && !parentNode._documentElement)) {
|
||||
// This allows us to avoid the explosion that occurs if you try to add nwmatcher to a document that is not yet
|
||||
// initialized.
|
||||
return null;
|
||||
}
|
||||
|
||||
return addNwmatcher(parentNode).first(selectors, parentNode);
|
||||
};
|
||||
|
||||
// nwmatcher gets `document.documentElement` at creation-time, so we have to initialize lazily, since in the initial
|
||||
// stages of Document initialization, there is no documentElement present yet.
|
||||
function addNwmatcher(parentNode) {
|
||||
const document = parentNode._ownerDocument;
|
||||
|
||||
if (!document._nwmatcher) {
|
||||
document._nwmatcher = nwmatcher({ document });
|
||||
document._nwmatcher.configure({ UNIQUE_ID: false });
|
||||
}
|
||||
|
||||
return document._nwmatcher;
|
||||
}
|
||||
43
node_modules/jsdom/lib/jsdom/living/text.js
generated
vendored
Normal file
43
node_modules/jsdom/lib/jsdom/living/text.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
const inheritFrom = require("../utils").inheritFrom;
|
||||
const domSymbolTree = require("./helpers/internal-constants").domSymbolTree;
|
||||
const NODE_TYPE = require("../living/node-type");
|
||||
|
||||
module.exports = function (core) {
|
||||
// TODO: constructor should not take ownerDocument
|
||||
core.Text = function Text(ownerDocument, data) {
|
||||
core.CharacterData.call(this, ownerDocument, data);
|
||||
};
|
||||
|
||||
inheritFrom(core.CharacterData, core.Text, {
|
||||
nodeType: NODE_TYPE.TEXT_NODE, // TODO should be on prototype, not here
|
||||
splitText(offset) {
|
||||
offset >>>= 0;
|
||||
|
||||
const length = this.length;
|
||||
|
||||
if (offset > length) {
|
||||
throw new core.DOMException(core.DOMException.INDEX_SIZE_ERR);
|
||||
}
|
||||
|
||||
const count = length - offset;
|
||||
const newData = this.substringData(offset, count);
|
||||
|
||||
const newNode = this._ownerDocument.createTextNode(newData);
|
||||
|
||||
const parent = domSymbolTree.parent(this);
|
||||
|
||||
if (parent !== null) {
|
||||
parent.insertBefore(newNode, this.nextSibling);
|
||||
}
|
||||
|
||||
this.replaceData(offset, count, "");
|
||||
|
||||
return newNode;
|
||||
|
||||
// TODO: range stuff
|
||||
}
|
||||
|
||||
// TODO: wholeText property
|
||||
});
|
||||
};
|
||||
7
node_modules/jsdom/lib/jsdom/living/url.js
generated
vendored
Normal file
7
node_modules/jsdom/lib/jsdom/living/url.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const URL = require("whatwg-url-compat");
|
||||
|
||||
module.exports = function (core) {
|
||||
core.URL = URL.createURLConstructor();
|
||||
};
|
||||
45
node_modules/jsdom/lib/jsdom/living/xhr-sync-worker.js
generated
vendored
Normal file
45
node_modules/jsdom/lib/jsdom/living/xhr-sync-worker.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
const util = require("util");
|
||||
|
||||
const jsdom = require("../../jsdom");
|
||||
const xhrSymbols = require("./xmlhttprequest-symbols");
|
||||
|
||||
const chunks = [];
|
||||
|
||||
process.stdin.on("data", chunk => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
process.stdin.on("end", () => {
|
||||
const buffer = Buffer.concat(chunks);
|
||||
const doc = jsdom.jsdom();
|
||||
const xhr = new doc.defaultView.XMLHttpRequest();
|
||||
const flag = JSON.parse(buffer.toString(), (k, v) => {
|
||||
if (v && v.type === "Buffer" && v.data) {
|
||||
return new Buffer(v.data);
|
||||
}
|
||||
return v;
|
||||
});
|
||||
flag.synchronous = false;
|
||||
xhr[xhrSymbols.flag] = flag;
|
||||
const properties = xhr[xhrSymbols.properties];
|
||||
properties.readyState = doc.defaultView.XMLHttpRequest.OPENED;
|
||||
try {
|
||||
xhr.addEventListener("load", () => {
|
||||
process.stdout.write(JSON.stringify({ properties }), () => {
|
||||
process.exit(0);
|
||||
});
|
||||
}, false);
|
||||
xhr.addEventListener("error", error => {
|
||||
process.stdout.write(JSON.stringify({ properties, error: error.stack || util.inspect(error) }), () => {
|
||||
process.exit(0);
|
||||
});
|
||||
}, false);
|
||||
xhr.send(flag.body);
|
||||
} catch (error) {
|
||||
process.stdout.write(JSON.stringify({ properties, error: error.stack || util.inspect(error) }), () => {
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user