diff --git a/.deepsource.toml b/.deepsource.toml
index e8c615cb..09b254f4 100644
--- a/.deepsource.toml
+++ b/.deepsource.toml
@@ -1,5 +1,13 @@
version = 1
+test_patterns = ["*.test.js"]
+
+exclude_patterns = ["**/node_modules/**"]
+
+[[analyzers]]
+name = "test-coverage"
+enabled = true
+
[[analyzers]]
name = "javascript"
-enabled = true
\ No newline at end of file
+enabled = false
\ No newline at end of file
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
new file mode 100644
index 00000000..55399f77
--- /dev/null
+++ b/.github/workflows/ci-build.yml
@@ -0,0 +1,24 @@
+name: Run Unit Tests
+
+on:
+ pull_request:
+ types: [opened, reopened]
+ push:
+ branches:
+ - '*'
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ name: Run tests
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ - name: Report results to DeepSource
+ run: |
+ npm test
+ curl https://deepsource.io/cli | sh
+ ./bin/deepsource report --analyzer test-coverage --key javascript --value-file ./coverage/cobertura-coverage.xml
+ env:
+ DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
diff --git a/gitsync.js b/gitsync.js
index 163c7f10..cc820113 100644
--- a/gitsync.js
+++ b/gitsync.js
@@ -4,12 +4,18 @@ const core = require('@actions/core');
const github = require('@actions/github');
const azdo = require('azure-devops-node-api');
const showdown = require('showdown');
+showdown.setFlavor('github');
+
+const JSDOM = require('jsdom').JSDOM;
+;(globalThis).window = new JSDOM('', {}).window;
module.exports = class GitSync {
+
constructor(level = "silent") {
log.setLevel(level, true);
}
-
+
+ // skipcq: TCV-001
async run() {
try {
const context = github.context;
@@ -18,7 +24,13 @@ module.exports = class GitSync {
let config = this.getConfig(context.payload, env);
log.debug(config);
- let workItem = await this.performWork(config);
+ // Temporary fix until support of PRs
+ if (config.issue.nodeId.startsWith("PR_")) {
+ // Log and skip PRs (comments)
+ log.info(`Action is performed on PR #${config.issue.number}. Skipping...`);
+ } else {
+ await this.performWork(config);
+ }
} catch (exc) {
log.error(exc);
}
@@ -625,7 +637,7 @@ module.exports = class GitSync {
result = await client.queryByWiql(wiql, context);
log.debug("Query results:", result);
- if (result == null) {
+ if (result === null) {
log.error("Error: project name appears to be invalid.");
core.setFailed("Error: project name appears to be invalid.");
return -1;
@@ -641,17 +653,19 @@ module.exports = class GitSync {
workItems.forEach(async (workItem) => { await this.updateIssue(config, client, workItem); });
}
- async updateIssue(config, client, workItem) {
+ updateIssue(config, client, workItem) {
log.info(`Updating issue for work item (${workItem.id})...`);
const octokit = new github.getOctokit(config.github.token);
const owner = config.GITHUB_REPOSITORY_OWNER;
const repo = config.GITHUB_REPOSITORY.replace(owner + "/", "");
+ const converter = new showdown.Converter();
log.debug(`[WORKITEM: ${workItem.id}] Owner:`, owner);
log.debug(`[WORKITEM: ${workItem.id}] Repo:`, repo);
return client.getWorkItem(workItem.id, ["System.Title", "System.Description", "System.State", "System.ChangedDate"]).then(async (wiObj) => {
let parsed = wiObj.fields["System.Title"].match(/^GH\s#(\d+):\s(.*)/);
+
let issue_number = parsed[1];
log.debug(`[WORKITEM: ${workItem.id} / ISSUE: ${issue_number}] Issue Number:`, issue_number);
@@ -672,17 +686,18 @@ module.exports = class GitSync {
if (new Date(wiObj.fields["System.ChangedDate"]) > new Date(issue.updated_at)) {
log.debug(`[WORKITEM: ${workItem.id} / ISSUE: ${issue_number}] WorkItem.ChangedDate (${new Date(wiObj.fields["System.ChangedDate"])}) is more recent than Issue.UpdatedAt (${new Date(issue.updated_at)}). Updating issue...`);
let title = parsed[2];
- let body = wiObj.fields["System.Description"];
+ let body = converter.makeMarkdown(wiObj.fields["System.Description"]).replace(/
/g, "").trim();
+
let states = config.ado.states;
- let state = Object.keys(states).find(k => states[k]==wiObj.fields["System.State"]);
+ let state = Object.keys(states).find(k => states[k]===wiObj.fields["System.State"]);
log.debug(`[WORKITEM: ${workItem.id} / ISSUE: ${issue_number}] Title:`, title);
log.debug(`[WORKITEM: ${workItem.id} / ISSUE: ${issue_number}] Body:`, body);
log.debug(`[WORKITEM: ${workItem.id} / ISSUE: ${issue_number}] State:`, state);
- if (title != issue.title ||
- body != issue.body ||
- state != issue.state) {
+ if (title !== issue.title ||
+ body !== issue.body ||
+ state !== issue.state) {
let result = await octokit.rest.issues.update({
owner,
diff --git a/gitsync.test.js b/gitsync.test.js
index 65877bc4..72a759ed 100644
--- a/gitsync.test.js
+++ b/gitsync.test.js
@@ -2,8 +2,9 @@ const chai = require('chai');
var sinon = require('sinon');
const assert = chai.assert;
chai.use(require('sinon-chai'));
-const proxyquire = require('proxyquire');
+const proxyquire = require('proxyquire').noPreserveCache();
const { DateTime } = require('luxon');
+const decache = require('decache');
const GitSync = require('./gitsync');
@@ -2355,6 +2356,8 @@ describe("index", () => {
state: "new"
});
sinon.restore();
+ decache("./mocks/workItem.json");
+ decache("./mocks/githubIssue.json");
});
it("should update github issue when AzDO change date is newer than github change date and body is different", async () => {
@@ -2426,6 +2429,8 @@ describe("index", () => {
state: "new"
});
sinon.restore();
+ decache("./mocks/workItem.json");
+ decache("./mocks/githubIssue.json");
});
it("should update github issue when AzDO change date is newer than github change date and state is different", async () => {
@@ -2499,11 +2504,157 @@ describe("index", () => {
state: "closed"
});
sinon.restore();
+ decache("./mocks/workItem.json");
+ decache("./mocks/githubIssue.json");
});
+ it("should successfully convert html code blocks back to markdown and not update github issue when equal", async () => {
+ let workItem = require("./mocks/workItemCode.json");
+ workItem.fields["System.Description"] = "testing
" + workItem.fields["System.Description"];
+ workItem.fields["System.Title"] = "GH #12: Testing title";
+ let gitHubIssue = require("./mocks/githubIssue.json");
+ gitHubIssue.data.updated_at = DateTime.fromJSDate(new Date(workItem.fields["System.ChangedDate"])).minus({ days: 5}).toJSDate();
+ gitHubIssue.data.body = "testing\n\n
public class Foo() {\n var number = 0;\n var text = \"Hello World!\";\n return 0;\n}"; + + const stubbedCore = sinon.stub().callsFake(); + const stubbedWorkItemTrackingApi = { + getWorkItem: sinon.stub().resolves(workItem) + } + const stubbedIssues = { + get: sinon.stub().resolves(gitHubIssue), + update: sinon.stub().resolves() + } + const proxiedGitSync = proxyquire('./gitsync', { + "@actions/github": { + getOctokit: sinon.stub().returns({ + rest: { + issues: stubbedIssues + } + }) + }, + "@actions/core": { + setFailed: stubbedCore + } + }); + + let now = Date.now(); + let config = { + log_level: 'silent', + ado: { + states: { reopened: "New" }, + project: "foo", + bypassRules: true, + wit: "User Story", + states: { + new: "New", + closed: "Closed", + reopened: "New", + deleted: "Removed", + active: "Active" + }, + }, + closed_at: now, + repository: { + full_name: "foo/bar" + }, + label: { + name: "baz" + }, + github: { + token: "blah blah" + }, + GITHUB_REPOSITORY: "foo/bar", + GITHUB_REPOSITORY_OWNER: "foo" + }; + + var sync = new proxiedGitSync(); + var result = await sync.updateIssue(config, stubbedWorkItemTrackingApi, workItem); + + assert.isNull(result); + sinon.assert.notCalled(stubbedIssues.update); + sinon.restore(); + decache("./mocks/workItemCode.json"); + decache("./mocks/githubIssue.json"); + }); + + it("should successfully convert html code blocks back to markdown and update github issue when not equal", async () => { + let workItem = require("./mocks/workItemCode.json"); + workItem.fields["System.Description"] = "testing
public class Foo() {\n var number = 0;\n var text = \"Hello World!\";\n return 0;\n}"; + + const stubbedCore = sinon.stub().callsFake(); + const stubbedWorkItemTrackingApi = { + getWorkItem: sinon.stub().resolves(workItem) + } + const stubbedIssues = { + get: sinon.stub().resolves(gitHubIssue), + update: sinon.stub().resolves() + } + const proxiedGitSync = proxyquire('./gitsync', { + "@actions/github": { + getOctokit: sinon.stub().returns({ + rest: { + issues: stubbedIssues + } + }) + }, + "@actions/core": { + setFailed: stubbedCore + } + }); + + let now = Date.now(); + let config = { + log_level: 'silent', + ado: { + states: { reopened: "New" }, + project: "foo", + bypassRules: true, + wit: "User Story", + states: { + new: "New", + closed: "Closed", + reopened: "New", + deleted: "Removed", + active: "Active" + }, + }, + closed_at: now, + repository: { + full_name: "foo/bar" + }, + label: { + name: "baz" + }, + github: { + token: "blah blah" + }, + GITHUB_REPOSITORY: "foo/bar", + GITHUB_REPOSITORY_OWNER: "foo" + }; + + var sync = new proxiedGitSync(); + await sync.updateIssue(config, stubbedWorkItemTrackingApi, workItem); + + sinon.assert.calledWith(stubbedIssues.update, { + owner: "foo", + repo: "bar", + issue_number: '12', + title: "Testing title", + body: "testing\n\nsome more\n\n
public class Foo() {\n var number = 0;\n var text = \"Hello World!\";\n return 0;\n}", + state: "new" + }); + sinon.restore(); + decache("./mocks/workItemCode.json"); + decache("./mocks/githubIssue.json"); + }); + it("should not update github issue when AzDO change date is newer than github change date but data is the same", async () => { let workItem = require("./mocks/workItem.json"); - workItem.fields["System.Title"] = "GH #12: Testing title"; + workItem.fields["System.Title"] = "GH #14: Testing title"; workItem.fields["System.Description"] = "Some body"; workItem.fields["System.State"] = "New"; let gitHubIssue = require("./mocks/githubIssue.json"); @@ -2566,6 +2717,8 @@ describe("index", () => { assert.isNull(result); sinon.assert.notCalled(stubbedIssues.update); sinon.restore(); + decache("./mocks/workItem.json"); + decache("./mocks/githubIssue.json"); }); it("should not update github issue when AzDO change date is newer than github change date", async () => { @@ -2629,6 +2782,8 @@ describe("index", () => { assert.isNull(result); sinon.restore(); + decache("./mocks/workItem.json"); + decache("./mocks/githubIssue.json"); }); }); }); \ No newline at end of file diff --git a/mocks/workItemCode.json b/mocks/workItemCode.json new file mode 100644 index 00000000..c3fd41d5 --- /dev/null +++ b/mocks/workItemCode.json @@ -0,0 +1,11 @@ +{ + "id": 1, + "fields": { + "System.Title": "GH #12: title 1", + "System.Description": "
public class Foo() {\n var number = 0;\n var text = "Hello World!";\n return 0;\n}", + "System.WorkItemType": "User Story", + "System.State": "New", + "System.Tags": "GitHub Issue;GitHub Repo: foo/bar;GitHub Label: fiz;GitHub Label: baz;", + "System.ChangedDate": "2020-01-01" + } +} \ No newline at end of file diff --git a/node_modules/.bin/acorn b/node_modules/.bin/acorn new file mode 120000 index 00000000..cf767603 --- /dev/null +++ b/node_modules/.bin/acorn @@ -0,0 +1 @@ +../acorn/bin/acorn \ No newline at end of file diff --git a/node_modules/.bin/escodegen b/node_modules/.bin/escodegen new file mode 120000 index 00000000..01a7c325 --- /dev/null +++ b/node_modules/.bin/escodegen @@ -0,0 +1 @@ +../escodegen/bin/escodegen.js \ No newline at end of file diff --git a/node_modules/.bin/esgenerate b/node_modules/.bin/esgenerate new file mode 120000 index 00000000..7d0293e6 --- /dev/null +++ b/node_modules/.bin/esgenerate @@ -0,0 +1 @@ +../escodegen/bin/esgenerate.js \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 418748f8..e30e94f6 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "github-actions-gitsync", - "version": "1.0.0", + "version": "1.1.3", "lockfileVersion": 2, "requires": true, "packages": { @@ -709,12 +709,64 @@ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, + "node_modules/@tootallnate/once": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", + "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", + "engines": { + "node": ">= 10" + } + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "node_modules/abab": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", + "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==" + }, + "node_modules/acorn": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-globals": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-7.0.1.tgz", + "integrity": "sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==", + "dependencies": { + "acorn": "^8.1.0", + "acorn-walk": "^8.0.2" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -807,6 +859,11 @@ "node": "*" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/azure-devops-node-api": { "version": "11.2.0", "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-11.2.0.tgz", @@ -919,6 +976,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha512-0vdNRFXn5q+dtOqjfFtmtlI9N2eVZ7LMyEV2iKC5mEEFvSg/69Ml6b/WU2qF8W1nLRa0wiSrDT3Y5jOHZCwKPQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/camelcase": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", @@ -1076,6 +1142,17 @@ "node": ">=0.1.90" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "9.4.0", "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz", @@ -1125,11 +1202,75 @@ "node": ">= 8" } }, + "node_modules/cssom": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz", + "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==" + }, + "node_modules/cssstyle": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", + "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", + "dependencies": { + "cssom": "~0.3.6" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cssstyle/node_modules/cssom": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", + "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" + }, + "node_modules/data-urls": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", + "integrity": "sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==", + "dependencies": { + "abab": "^2.0.6", + "whatwg-mimetype": "^3.0.0", + "whatwg-url": "^11.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/data-urls/node_modules/tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dependencies": { + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/data-urls/node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/data-urls/node_modules/whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dependencies": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -1145,8 +1286,16 @@ "node_modules/debug/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/decache": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/decache/-/decache-4.6.1.tgz", + "integrity": "sha512-ohApBM8u9ygepJCjgBrEZSSxPjc0T/PJkD+uNyxXPkqudyUpdXpwJYp0VISm2WrPVzASU6DZyIi6BWdyw7uJ2Q==", + "dev": true, + "dependencies": { + "callsite": "^1.0.0" + } }, "node_modules/decamelize": { "version": "4.0.0", @@ -1160,6 +1309,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/decimal.js": { + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.2.tgz", + "integrity": "sha512-ic1yEvwT6GuvaYwBLLY6/aFFgjZdySKTE8en/fkU3QICTmRtgtSlFn0u0BXN06InZwtfCelR7j8LRiDI/02iGA==" + }, "node_modules/deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -1172,6 +1326,11 @@ "node": ">=0.12" } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + }, "node_modules/default-require-extensions": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", @@ -1184,6 +1343,14 @@ "node": ">=8" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -1198,6 +1365,25 @@ "node": ">=0.3.1" } }, + "node_modules/domexception": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", + "integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==", + "dependencies": { + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/domexception/node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.225", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.225.tgz", @@ -1210,6 +1396,17 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/entities": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz", + "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es6-error": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", @@ -1237,6 +1434,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/escodegen": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", + "integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==", + "dependencies": { + "esprima": "^4.0.1", + "estraverse": "^5.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=6.0" + }, + "optionalDependencies": { + "source-map": "~0.6.1" + } + }, "node_modules/esm": { "version": "3.2.25", "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", @@ -1250,7 +1468,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -1259,6 +1476,27 @@ "node": ">=4" } }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" + }, "node_modules/fill-keys": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz", @@ -1339,6 +1577,19 @@ "node": ">=8.0.0" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fromentries": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", @@ -1541,12 +1792,59 @@ "he": "bin/he" } }, + "node_modules/html-encoding-sniffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", + "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==", + "dependencies": { + "whatwg-encoding": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "node_modules/http-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", + "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "dependencies": { + "@tootallnate/once": "2", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -1670,6 +1968,11 @@ "node": ">=0.10.0" } }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==" + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -1873,6 +2176,81 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdom": { + "version": "20.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-20.0.1.tgz", + "integrity": "sha512-pksjj7Rqoa+wdpkKcLzQRHhJCEE42qQhl/xLMUKHgoSejaKOdaXEAnqs6uDNwMl/fciHTzKeR8Wm8cw7N+g98A==", + "dependencies": { + "abab": "^2.0.6", + "acorn": "^8.8.0", + "acorn-globals": "^7.0.0", + "cssom": "^0.5.0", + "cssstyle": "^2.3.0", + "data-urls": "^3.0.2", + "decimal.js": "^10.4.1", + "domexception": "^4.0.0", + "escodegen": "^2.0.0", + "form-data": "^4.0.0", + "html-encoding-sniffer": "^3.0.0", + "http-proxy-agent": "^5.0.0", + "https-proxy-agent": "^5.0.1", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.2", + "parse5": "^7.1.1", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^4.1.2", + "w3c-xmlserializer": "^3.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^2.0.0", + "whatwg-mimetype": "^3.0.0", + "whatwg-url": "^11.0.0", + "ws": "^8.9.0", + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "canvas": "^2.5.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsdom/node_modules/tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dependencies": { + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/jsdom/node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/jsdom/node_modules/whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dependencies": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -1903,6 +2281,18 @@ "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", "dev": true }, + "node_modules/levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", + "dependencies": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -1997,6 +2387,25 @@ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", "dev": true }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -2186,6 +2595,11 @@ "node": ">=0.10.0" } }, + "node_modules/nwsapi": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.2.tgz", + "integrity": "sha512-90yv+6538zuvUMnN+zCr8LuV6bPFdq50304114vJYJ8RDyK8D5O9Phpbd6SZWgI7PwzmmfN1upeOJlvybDSgCw==" + }, "node_modules/nyc": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", @@ -2379,6 +2793,22 @@ "wrappy": "1" } }, + "node_modules/optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dependencies": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -2445,6 +2875,17 @@ "node": ">=8" } }, + "node_modules/parse5": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.1.tgz", + "integrity": "sha512-kwpuwzB+px5WUg9pyK0IcK/shltJN5/OVhQagxhCQNtT9Y9QRZqNY2e1cmbu/paRh5LMnz/oVTVLBpjFmMZhSg==", + "dependencies": { + "entities": "^4.4.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2578,6 +3019,14 @@ "node": ">=8" } }, + "node_modules/prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/process-on-spawn": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", @@ -2601,6 +3050,19 @@ "resolve": "^1.11.1" } }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -2615,6 +3077,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -2663,6 +3130,11 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" + }, "node_modules/resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -2724,6 +3196,22 @@ } ] }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", @@ -2847,7 +3335,7 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.10.0" } @@ -2949,6 +3437,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -2984,6 +3477,20 @@ "node": ">=8.0" } }, + "node_modules/tough-cookie": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", + "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -2997,6 +3504,17 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, + "node_modules/type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", + "dependencies": { + "prelude-ls": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -3044,6 +3562,14 @@ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" }, + "node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/update-browserslist-db": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", @@ -3070,6 +3596,15 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -3078,11 +3613,41 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/w3c-xmlserializer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-3.0.0.tgz", + "integrity": "sha512-3WFqGEgSXIyGhOmAFtlicJNMjEps8b1MG31NCA0/vOF9+nKMUW1ckhi9cnNHmf88Rzw5V+dwIwsm2C7X8k9aQg==", + "dependencies": { + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, + "node_modules/whatwg-encoding": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz", + "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-mimetype": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", + "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", + "engines": { + "node": ">=12" + } + }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", @@ -3113,6 +3678,14 @@ "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==", "dev": true }, + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/workerpool": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", @@ -3153,6 +3726,39 @@ "typedarray-to-buffer": "^3.1.5" } }, + "node_modules/ws": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz", + "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-name-validator": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", + "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "engines": { + "node": ">=12" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==" + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/node_modules/@tootallnate/once/LICENSE b/node_modules/@tootallnate/once/LICENSE new file mode 100644 index 00000000..c4c56a2a --- /dev/null +++ b/node_modules/@tootallnate/once/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Nathan Rajlich + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@tootallnate/once/README.md b/node_modules/@tootallnate/once/README.md new file mode 100644 index 00000000..bc980fd4 --- /dev/null +++ b/node_modules/@tootallnate/once/README.md @@ -0,0 +1,93 @@ +# @tootallnate/once + +### Creates a Promise that waits for a single event + +## Installation + +Install with `npm`: + +```bash +$ npm install @tootallnate/once +``` + +## API + +### once(emitter: EventEmitter, name: string, opts?: OnceOptions): Promise<[...Args]> + +Creates a Promise that waits for event `name` to occur on `emitter`, and resolves +the promise with an array of the values provided to the event handler. If an +`error` event occurs before the event specified by `name`, then the Promise is +rejected with the error argument. + +```typescript +import once from '@tootallnate/once'; +import { EventEmitter } from 'events'; + +const emitter = new EventEmitter(); + +setTimeout(() => { + emitter.emit('foo', 'bar'); +}, 100); + +const [result] = await once(emitter, 'foo'); +console.log({ result }); +// { result: 'bar' } +``` + +#### Promise Strong Typing + +The main feature that this module provides over other "once" implementations is that +the Promise that is returned is _**strongly typed**_ based on the type of `emitter` +and the `name` of the event. Some examples are shown below. + +_The process "exit" event contains a single number for exit code:_ + +```typescript +const [code] = await once(process, 'exit'); +// ^ number +``` +_A child process "exit" event contains either an exit code or a signal:_ + +```typescript +const child = spawn('echo', []); +const [code, signal] = await once(child, 'exit'); +// ^ number | null +// ^ string | null +``` + +_A forked child process "message" event is type `any`, so you can cast the Promise directly:_ + +```typescript +const child = fork('file.js'); + +// With `await` +const [message, _]: [WorkerPayload, unknown] = await once(child, 'message'); + +// With Promise +const messagePromise: Promise<[WorkerPayload, unknown]> = once(child, 'message'); + +// Better yet would be to leave it as `any`, and validate the payload +// at runtime with i.e. `ajv` + `json-schema-to-typescript` +``` + +_If the TypeScript definition does not contain an overload for the specified event name, then the Promise will have type `unknown[]` and your code will need to narrow the result manually:_ + +```typescript +interface CustomEmitter extends EventEmitter { + on(name: 'foo', listener: (a: string, b: number) => void): this; +} + +const emitter: CustomEmitter = new EventEmitter(); + +// "foo" event is a defined overload, so it's properly typed +const fooPromise = once(emitter, 'foo'); +// ^ Promise<[a: string, b: number]> + +// "bar" event in not a defined overload, so it gets `unknown[]` +const barPromise = once(emitter, 'bar'); +// ^ Promise
Hello world
`); +console.log(dom.window.document.querySelector("p").textContent); // "Hello world" +``` + +(Note that jsdom will parse the HTML you pass it just like a browser does, including implied ``, ``, and `` tags.) + +The resulting object is an instance of the `JSDOM` class, which contains a number of useful properties and methods besides `window`. In general, it can be used to act on the jsdom from the "outside," doing things that are not possible with the normal DOM APIs. For simple cases, where you don't need any of this functionality, we recommend a coding pattern like + +```js +const { window } = new JSDOM(`...`); +// or even +const { document } = (new JSDOM(`...`)).window; +``` + +Full documentation on everything you can do with the `JSDOM` class is below, in the section "`JSDOM` Object API". + +## Customizing jsdom + +The `JSDOM` constructor accepts a second parameter which can be used to customize your jsdom in the following ways. + +### Simple options + +```js +const dom = new JSDOM(``, { + url: "https://example.org/", + referrer: "https://example.com/", + contentType: "text/html", + includeNodeLocations: true, + storageQuota: 10000000 +}); +``` + +- `url` sets the value returned by `window.location`, `document.URL`, and `document.documentURI`, and affects things like resolution of relative URLs within the document and the same-origin restrictions and referrer used while fetching subresources. It defaults to `"about:blank"`. +- `referrer` just affects the value read from `document.referrer`. It defaults to no referrer (which reflects as the empty string). +- `contentType` affects the value read from `document.contentType`, as well as how the document is parsed: as HTML or as XML. Values that are not a [HTML mime type](https://mimesniff.spec.whatwg.org/#html-mime-type) or an [XML mime type](https://mimesniff.spec.whatwg.org/#xml-mime-type) will throw. It defaults to `"text/html"`. If a `charset` parameter is present, it can affect [binary data processing](#encoding-sniffing). +- `includeNodeLocations` preserves the location info produced by the HTML parser, allowing you to retrieve it with the `nodeLocation()` method (described below). It also ensures that line numbers reported in exception stack traces for code running inside ` +`); + +// The script will not be executed, by default: +dom.window.document.body.children.length === 1; +``` + +To enable executing scripts inside the page, you can use the `runScripts: "dangerously"` option: + +```js +const dom = new JSDOM(` + +`, { runScripts: "dangerously" }); + +// The script will be executed and modify the DOM: +dom.window.document.body.children.length === 2; +``` + +Again we emphasize to only use this when feeding jsdom code you know is safe. If you use it on arbitrary user-supplied code, or code from the Internet, you are effectively running untrusted Node.js code, and your machine could be compromised. + +If you want to execute _external_ scripts, included via ` +``` + +If you do not control the page, you could try workarounds such as polling for the presence of a specific element. + +For more details, see the discussion in [#640](https://github.com/jsdom/jsdom/issues/640), especially [@matthewkastor](https://github.com/matthewkastor)'s [insightful comment](https://github.com/jsdom/jsdom/issues/640#issuecomment-22216965). + +### Unimplemented parts of the web platform + +Although we enjoy adding new features to jsdom and keeping it up to date with the latest web specs, it has many missing APIs. Please feel free to file an issue for anything missing, but we're a small and busy team, so a pull request might work even better. + +Beyond just features that we haven't gotten to yet, there are two major features that are currently outside the scope of jsdom. These are: + +- **Navigation**: the ability to change the global object, and all other objects, when clicking a link or assigning `location.href` or similar. +- **Layout**: the ability to calculate where elements will be visually laid out as a result of CSS, which impacts methods like `getBoundingClientRects()` or properties like `offsetTop`. + +Currently jsdom has dummy behaviors for some aspects of these features, such as sending a "not implemented" `"jsdomError"` to the virtual console for navigation, or returning zeros for many layout-related properties. Often you can work around these limitations in your code, e.g. by creating new `JSDOM` instances for each page you "navigate" to during a crawl, or using `Object.defineProperty()` to change what various layout-related getters and methods return. + +Note that other tools in the same space, such as PhantomJS, do support these features. On the wiki, we have a more complete writeup about [jsdom vs. PhantomJS](https://github.com/jsdom/jsdom/wiki/jsdom-vs.-PhantomJS). + +## Supporting jsdom + +jsdom is a community-driven project maintained by a team of [volunteers](https://github.com/orgs/jsdom/people). You could support jsdom by: + +- [Getting professional support for jsdom](https://tidelift.com/subscription/pkg/npm-jsdom?utm_source=npm-jsdom&utm_medium=referral&utm_campaign=readme) as part of a Tidelift subscription. Tidelift helps making open source sustainable for us while giving teams assurances for maintenance, licensing, and security. +- [Contributing](https://github.com/jsdom/jsdom/blob/master/Contributing.md) directly to the project. + +## Getting help + +If you need help with jsdom, please feel free to use any of the following venues: + +- The [mailing list](https://groups.google.com/group/jsdom) (best for "how do I" questions) +- The [issue tracker](https://github.com/jsdom/jsdom/issues) (best for bug reports) +- The Matrix room: [#jsdom:matrix.org](https://matrix.to/#/#jsdom:matrix.org) diff --git a/node_modules/jsdom/lib/api.js b/node_modules/jsdom/lib/api.js new file mode 100644 index 00000000..5227f945 --- /dev/null +++ b/node_modules/jsdom/lib/api.js @@ -0,0 +1,333 @@ +"use strict"; +const path = require("path"); +const fs = require("fs").promises; +const vm = require("vm"); +const toughCookie = require("tough-cookie"); +const sniffHTMLEncoding = require("html-encoding-sniffer"); +const whatwgURL = require("whatwg-url"); +const whatwgEncoding = require("whatwg-encoding"); +const { URL } = require("whatwg-url"); +const MIMEType = require("whatwg-mimetype"); +const idlUtils = require("./jsdom/living/generated/utils.js"); +const VirtualConsole = require("./jsdom/virtual-console.js"); +const { createWindow } = require("./jsdom/browser/Window.js"); +const { parseIntoDocument } = require("./jsdom/browser/parser"); +const { fragmentSerialization } = require("./jsdom/living/domparsing/serialization.js"); +const ResourceLoader = require("./jsdom/browser/resources/resource-loader.js"); +const NoOpResourceLoader = require("./jsdom/browser/resources/no-op-resource-loader.js"); + +class CookieJar extends toughCookie.CookieJar { + constructor(store, options) { + // jsdom cookie jars must be loose by default + super(store, { looseMode: true, ...options }); + } +} + +const window = Symbol("window"); +let sharedFragmentDocument = null; + +class JSDOM { + constructor(input = "", options = {}) { + const mimeType = new MIMEType(options.contentType === undefined ? "text/html" : options.contentType); + const { html, encoding } = normalizeHTML(input, mimeType); + + options = transformOptions(options, encoding, mimeType); + + this[window] = createWindow(options.windowOptions); + + const documentImpl = idlUtils.implForWrapper(this[window]._document); + + options.beforeParse(this[window]._globalProxy); + + parseIntoDocument(html, documentImpl); + + documentImpl.close(); + } + + get window() { + // It's important to grab the global proxy, instead of just the result of `createWindow(...)`, since otherwise + // things like `window.eval` don't exist. + return this[window]._globalProxy; + } + + get virtualConsole() { + return this[window]._virtualConsole; + } + + get cookieJar() { + // TODO NEWAPI move _cookieJar to window probably + return idlUtils.implForWrapper(this[window]._document)._cookieJar; + } + + serialize() { + return fragmentSerialization(idlUtils.implForWrapper(this[window]._document), { requireWellFormed: false }); + } + + nodeLocation(node) { + if (!idlUtils.implForWrapper(this[window]._document)._parseOptions.sourceCodeLocationInfo) { + throw new Error("Location information was not saved for this jsdom. Use includeNodeLocations during creation."); + } + + return idlUtils.implForWrapper(node).sourceCodeLocation; + } + + getInternalVMContext() { + if (!vm.isContext(this[window])) { + throw new TypeError("This jsdom was not configured to allow script running. " + + "Use the runScripts option during creation."); + } + + return this[window]; + } + + reconfigure(settings) { + if ("windowTop" in settings) { + this[window]._top = settings.windowTop; + } + + if ("url" in settings) { + const document = idlUtils.implForWrapper(this[window]._document); + + const url = whatwgURL.parseURL(settings.url); + if (url === null) { + throw new TypeError(`Could not parse "${settings.url}" as a URL`); + } + + document._URL = url; + document._origin = whatwgURL.serializeURLOrigin(document._URL); + } + } + + static fragment(string = "") { + if (!sharedFragmentDocument) { + sharedFragmentDocument = (new JSDOM()).window.document; + } + + const template = sharedFragmentDocument.createElement("template"); + template.innerHTML = string; + return template.content; + } + + static fromURL(url, options = {}) { + return Promise.resolve().then(() => { + // Remove the hash while sending this through the research loader fetch(). + // It gets added back a few lines down when constructing the JSDOM object. + const parsedURL = new URL(url); + const originalHash = parsedURL.hash; + parsedURL.hash = ""; + url = parsedURL.href; + + options = normalizeFromURLOptions(options); + + const resourceLoader = resourcesToResourceLoader(options.resources); + const resourceLoaderForInitialRequest = resourceLoader.constructor === NoOpResourceLoader ? + new ResourceLoader() : + resourceLoader; + + const req = resourceLoaderForInitialRequest.fetch(url, { + accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", + cookieJar: options.cookieJar, + referrer: options.referrer + }); + + return req.then(body => { + const res = req.response; + + options = Object.assign(options, { + url: req.href + originalHash, + contentType: res.headers["content-type"], + referrer: req.getHeader("referer") + }); + + return new JSDOM(body, options); + }); + }); + } + + static async fromFile(filename, options = {}) { + options = normalizeFromFileOptions(filename, options); + const buffer = await fs.readFile(filename); + + return new JSDOM(buffer, options); + } +} + +function normalizeFromURLOptions(options) { + // Checks on options that are invalid for `fromURL` + if (options.url !== undefined) { + throw new TypeError("Cannot supply a url option when using fromURL"); + } + if (options.contentType !== undefined) { + throw new TypeError("Cannot supply a contentType option when using fromURL"); + } + + // Normalization of options which must be done before the rest of the fromURL code can use them, because they are + // given to request() + const normalized = { ...options }; + + if (options.referrer !== undefined) { + normalized.referrer = (new URL(options.referrer)).href; + } + + if (options.cookieJar === undefined) { + normalized.cookieJar = new CookieJar(); + } + + return normalized; + + // All other options don't need to be processed yet, and can be taken care of in the normal course of things when + // `fromURL` calls `new JSDOM(html, options)`. +} + +function normalizeFromFileOptions(filename, options) { + const normalized = { ...options }; + + if (normalized.contentType === undefined) { + const extname = path.extname(filename); + if (extname === ".xhtml" || extname === ".xht" || extname === ".xml") { + normalized.contentType = "application/xhtml+xml"; + } + } + + if (normalized.url === undefined) { + normalized.url = new URL("file:" + path.resolve(filename)); + } + + return normalized; +} + +function transformOptions(options, encoding, mimeType) { + const transformed = { + windowOptions: { + // Defaults + url: "about:blank", + referrer: "", + contentType: "text/html", + parsingMode: "html", + parseOptions: { + sourceCodeLocationInfo: false, + scriptingEnabled: false + }, + runScripts: undefined, + encoding, + pretendToBeVisual: false, + storageQuota: 5000000, + + // Defaults filled in later + resourceLoader: undefined, + virtualConsole: undefined, + cookieJar: undefined + }, + + // Defaults + beforeParse() { } + }; + + // options.contentType was parsed into mimeType by the caller. + if (!mimeType.isHTML() && !mimeType.isXML()) { + throw new RangeError(`The given content type of "${options.contentType}" was not a HTML or XML content type`); + } + + transformed.windowOptions.contentType = mimeType.essence; + transformed.windowOptions.parsingMode = mimeType.isHTML() ? "html" : "xml"; + + if (options.url !== undefined) { + transformed.windowOptions.url = (new URL(options.url)).href; + } + + if (options.referrer !== undefined) { + transformed.windowOptions.referrer = (new URL(options.referrer)).href; + } + + if (options.includeNodeLocations) { + if (transformed.windowOptions.parsingMode === "xml") { + throw new TypeError("Cannot set includeNodeLocations to true with an XML content type"); + } + + transformed.windowOptions.parseOptions = { sourceCodeLocationInfo: true }; + } + + transformed.windowOptions.cookieJar = options.cookieJar === undefined ? + new CookieJar() : + options.cookieJar; + + transformed.windowOptions.virtualConsole = options.virtualConsole === undefined ? + (new VirtualConsole()).sendTo(console) : + options.virtualConsole; + + if (!(transformed.windowOptions.virtualConsole instanceof VirtualConsole)) { + throw new TypeError("virtualConsole must be an instance of VirtualConsole"); + } + + transformed.windowOptions.resourceLoader = resourcesToResourceLoader(options.resources); + + if (options.runScripts !== undefined) { + transformed.windowOptions.runScripts = String(options.runScripts); + if (transformed.windowOptions.runScripts === "dangerously") { + transformed.windowOptions.parseOptions.scriptingEnabled = true; + } else if (transformed.windowOptions.runScripts !== "outside-only") { + throw new RangeError(`runScripts must be undefined, "dangerously", or "outside-only"`); + } + } + + if (options.beforeParse !== undefined) { + transformed.beforeParse = options.beforeParse; + } + + if (options.pretendToBeVisual !== undefined) { + transformed.windowOptions.pretendToBeVisual = Boolean(options.pretendToBeVisual); + } + + if (options.storageQuota !== undefined) { + transformed.windowOptions.storageQuota = Number(options.storageQuota); + } + + return transformed; +} + +function normalizeHTML(html, mimeType) { + let encoding = "UTF-8"; + + if (ArrayBuffer.isView(html)) { + html = Buffer.from(html.buffer, html.byteOffset, html.byteLength); + } else if (html instanceof ArrayBuffer) { + html = Buffer.from(html); + } + + if (Buffer.isBuffer(html)) { + encoding = sniffHTMLEncoding(html, { + defaultEncoding: mimeType.isXML() ? "UTF-8" : "windows-1252", + transportLayerEncodingLabel: mimeType.parameters.get("charset") + }); + html = whatwgEncoding.decode(html, encoding); + } else { + html = String(html); + } + + return { html, encoding }; +} + +function resourcesToResourceLoader(resources) { + switch (resources) { + case undefined: { + return new NoOpResourceLoader(); + } + case "usable": { + return new ResourceLoader(); + } + default: { + if (!(resources instanceof ResourceLoader)) { + throw new TypeError("resources must be an instance of ResourceLoader"); + } + return resources; + } + } +} + +exports.JSDOM = JSDOM; + +exports.VirtualConsole = VirtualConsole; +exports.CookieJar = CookieJar; +exports.ResourceLoader = ResourceLoader; + +exports.toughCookie = toughCookie; diff --git a/node_modules/jsdom/lib/jsdom/browser/Window.js b/node_modules/jsdom/lib/jsdom/browser/Window.js new file mode 100644 index 00000000..a390e67a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/Window.js @@ -0,0 +1,939 @@ +"use strict"; +const vm = require("vm"); +const webIDLConversions = require("webidl-conversions"); +const { CSSStyleDeclaration } = require("cssstyle"); +const notImplemented = require("./not-implemented"); +const { installInterfaces } = require("../living/interfaces"); +const { define, mixin, performance } = require("../utils"); +const Element = require("../living/generated/Element"); +const EventTarget = require("../living/generated/EventTarget"); +const EventHandlerNonNull = require("../living/generated/EventHandlerNonNull"); +const IDLFunction = require("../living/generated/Function"); +const OnBeforeUnloadEventHandlerNonNull = require("../living/generated/OnBeforeUnloadEventHandlerNonNull"); +const OnErrorEventHandlerNonNull = require("../living/generated/OnErrorEventHandlerNonNull"); +const { fireAPageTransitionEvent } = require("../living/helpers/page-transition-event"); +const namedPropertiesWindow = require("../living/named-properties-window"); +const postMessage = require("../living/post-message"); +const DOMException = require("domexception/webidl2js-wrapper"); +const { btoa, atob } = require("abab"); +const idlUtils = require("../living/generated/utils"); +const WebSocketImpl = require("../living/websockets/WebSocket-impl").implementation; +const BarProp = require("../living/generated/BarProp"); +const documents = require("../living/documents.js"); +const External = require("../living/generated/External"); +const Navigator = require("../living/generated/Navigator"); +const Performance = require("../living/generated/Performance"); +const Screen = require("../living/generated/Screen"); +const Crypto = require("../living/generated/Crypto"); +const Storage = require("../living/generated/Storage"); +const Selection = require("../living/generated/Selection"); +const reportException = require("../living/helpers/runtime-script-errors"); +const { getCurrentEventHandlerValue } = require("../living/helpers/create-event-accessor.js"); +const { fireAnEvent } = require("../living/helpers/events"); +const SessionHistory = require("../living/window/SessionHistory"); +const { forEachMatchingSheetRuleOfElement, getResolvedValue, propertiesWithResolvedValueImplemented, + SHADOW_DOM_PSEUDO_REGEXP } = require("../living/helpers/style-rules.js"); +const CustomElementRegistry = require("../living/generated/CustomElementRegistry"); +const jsGlobals = require("./js-globals.json"); + +const GlobalEventHandlersImpl = require("../living/nodes/GlobalEventHandlers-impl").implementation; +const WindowEventHandlersImpl = require("../living/nodes/WindowEventHandlers-impl").implementation; + +const events = new Set([ + // GlobalEventHandlers + "abort", "autocomplete", + "autocompleteerror", "blur", + "cancel", "canplay", "canplaythrough", + "change", "click", + "close", "contextmenu", + "cuechange", "dblclick", + "drag", "dragend", + "dragenter", + "dragleave", "dragover", + "dragstart", "drop", + "durationchange", "emptied", + "ended", "focus", + "input", "invalid", + "keydown", "keypress", + "keyup", "load", "loadeddata", + "loadedmetadata", "loadstart", + "mousedown", "mouseenter", + "mouseleave", "mousemove", + "mouseout", "mouseover", + "mouseup", "wheel", + "pause", "play", + "playing", "progress", + "ratechange", "reset", + "resize", "scroll", + "securitypolicyviolation", + "seeked", "seeking", + "select", "sort", "stalled", + "submit", "suspend", + "timeupdate", "toggle", + "volumechange", "waiting", + + // WindowEventHandlers + "afterprint", + "beforeprint", + "hashchange", + "languagechange", + "message", + "messageerror", + "offline", + "online", + "pagehide", + "pageshow", + "popstate", + "rejectionhandled", + "storage", + "unhandledrejection", + "unload" + + // "error" and "beforeunload" are added separately +]); + +exports.createWindow = function (options) { + return new Window(options); +}; + +const jsGlobalEntriesToInstall = Object.entries(jsGlobals).filter(([name]) => name in global); + +// https://html.spec.whatwg.org/#the-window-object +function setupWindow(windowInstance, { runScripts }) { + if (runScripts === "outside-only" || runScripts === "dangerously") { + contextifyWindow(windowInstance); + + // Without this, these globals will only appear to scripts running inside the context using vm.runScript; they will + // not appear to scripts running from the outside, including to JSDOM implementation code. + for (const [globalName, globalPropDesc] of jsGlobalEntriesToInstall) { + const propDesc = { ...globalPropDesc, value: vm.runInContext(globalName, windowInstance) }; + Object.defineProperty(windowInstance, globalName, propDesc); + } + } else { + // Without contextifying the window, none of the globals will exist. So, let's at least alias them from the Node.js + // context. See https://github.com/jsdom/jsdom/issues/2727 for more background and discussion. + for (const [globalName, globalPropDesc] of jsGlobalEntriesToInstall) { + const propDesc = { ...globalPropDesc, value: global[globalName] }; + Object.defineProperty(windowInstance, globalName, propDesc); + } + } + + installInterfaces(windowInstance, ["Window"]); + + const EventTargetConstructor = windowInstance.EventTarget; + + // eslint-disable-next-line func-name-matching, func-style, no-shadow + const windowConstructor = function Window() { + throw new TypeError("Illegal constructor"); + }; + Object.setPrototypeOf(windowConstructor, EventTargetConstructor); + + Object.defineProperty(windowInstance, "Window", { + configurable: true, + writable: true, + value: windowConstructor + }); + + const windowPrototype = Object.create(EventTargetConstructor.prototype); + Object.defineProperties(windowPrototype, { + constructor: { + value: windowConstructor, + writable: true, + configurable: true + }, + [Symbol.toStringTag]: { + value: "Window", + configurable: true + } + }); + + windowConstructor.prototype = windowPrototype; + Object.setPrototypeOf(windowInstance, windowPrototype); + + EventTarget.setup(windowInstance, windowInstance); + mixin(windowInstance, WindowEventHandlersImpl.prototype); + mixin(windowInstance, GlobalEventHandlersImpl.prototype); + windowInstance._initGlobalEvents(); + + Object.defineProperty(windowInstance, "onbeforeunload", { + configurable: true, + enumerable: true, + get() { + return idlUtils.tryWrapperForImpl(getCurrentEventHandlerValue(this, "beforeunload")); + }, + set(V) { + if (!idlUtils.isObject(V)) { + V = null; + } else { + V = OnBeforeUnloadEventHandlerNonNull.convert(windowInstance, V, { + context: "Failed to set the 'onbeforeunload' property on 'Window': The provided value" + }); + } + this._setEventHandlerFor("beforeunload", V); + } + }); + + Object.defineProperty(windowInstance, "onerror", { + configurable: true, + enumerable: true, + get() { + return idlUtils.tryWrapperForImpl(getCurrentEventHandlerValue(this, "error")); + }, + set(V) { + if (!idlUtils.isObject(V)) { + V = null; + } else { + V = OnErrorEventHandlerNonNull.convert(windowInstance, V, { + context: "Failed to set the 'onerror' property on 'Window': The provided value" + }); + } + this._setEventHandlerFor("error", V); + } + }); + + for (const event of events) { + Object.defineProperty(windowInstance, `on${event}`, { + configurable: true, + enumerable: true, + get() { + return idlUtils.tryWrapperForImpl(getCurrentEventHandlerValue(this, event)); + }, + set(V) { + if (!idlUtils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(windowInstance, V, { + context: `Failed to set the 'on${event}' property on 'Window': The provided value` + }); + } + this._setEventHandlerFor(event, V); + } + }); + } + + windowInstance._globalObject = windowInstance; +} + +// 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) { + setupWindow(this, { runScripts: options.runScripts }); + + const windowInitialized = performance.now(); + + const window = this; + + // ### PRIVATE DATA PROPERTIES + + this._resourceLoader = options.resourceLoader; + + // vm initialization is deferred until script processing is activated + this._globalProxy = this; + Object.defineProperty(idlUtils.implForWrapper(this), idlUtils.wrapperSymbol, { get: () => this._globalProxy }); + + // List options explicitly to be clear which are passed through + this._document = documents.createWrapper(window, { + parsingMode: options.parsingMode, + contentType: options.contentType, + encoding: options.encoding, + cookieJar: options.cookieJar, + url: options.url, + lastModified: options.lastModified, + referrer: options.referrer, + parseOptions: options.parseOptions, + defaultView: this._globalProxy, + global: this, + parentOrigin: options.parentOrigin + }, { alwaysUseDocumentClass: true }); + + if (vm.isContext(window)) { + const documentImpl = idlUtils.implForWrapper(window._document); + documentImpl._defaultView = window._globalProxy = vm.runInContext("this", window); + } + + const documentOrigin = idlUtils.implForWrapper(this._document)._origin; + this._origin = documentOrigin; + + // https://html.spec.whatwg.org/#session-history + this._sessionHistory = new SessionHistory({ + document: idlUtils.implForWrapper(this._document), + url: idlUtils.implForWrapper(this._document)._URL, + stateObject: null + }, this); + + this._virtualConsole = options.virtualConsole; + + this._runScripts = options.runScripts; + + // 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._frameElement = null; + + // This implements window.frames.length, since window.frames returns a + // self reference to the window object. This value is incremented in the + // HTMLFrameElement implementation. + this._length = 0; + + // https://dom.spec.whatwg.org/#window-current-event + this._currentEvent = undefined; + + this._pretendToBeVisual = options.pretendToBeVisual; + this._storageQuota = options.storageQuota; + + // Some properties (such as localStorage and sessionStorage) share data + // between windows in the same origin. This object is intended + // to contain such data. + if (options.commonForOrigin && options.commonForOrigin[documentOrigin]) { + this._commonForOrigin = options.commonForOrigin; + } else { + this._commonForOrigin = { + [documentOrigin]: { + localStorageArea: new Map(), + sessionStorageArea: new Map(), + windowsInSameOrigin: [this] + } + }; + } + + this._currentOriginData = this._commonForOrigin[documentOrigin]; + + // ### WEB STORAGE + + this._localStorage = Storage.create(window, [], { + associatedWindow: this, + storageArea: this._currentOriginData.localStorageArea, + type: "localStorage", + url: this._document.documentURI, + storageQuota: this._storageQuota + }); + this._sessionStorage = Storage.create(window, [], { + associatedWindow: this, + storageArea: this._currentOriginData.sessionStorageArea, + type: "sessionStorage", + url: this._document.documentURI, + storageQuota: this._storageQuota + }); + + // ### SELECTION + + // https://w3c.github.io/selection-api/#dfn-selection + this._selection = Selection.createImpl(window); + + // https://w3c.github.io/selection-api/#dom-window + this.getSelection = function () { + return window._selection; + }; + + // ### GETTERS + + const locationbar = BarProp.create(window); + const menubar = BarProp.create(window); + const personalbar = BarProp.create(window); + const scrollbars = BarProp.create(window); + const statusbar = BarProp.create(window); + const toolbar = BarProp.create(window); + const external = External.create(window); + const navigator = Navigator.create(window, [], { userAgent: this._resourceLoader._userAgent }); + const performanceImpl = Performance.create(window, [], { + timeOrigin: performance.timeOrigin + windowInitialized, + nowAtTimeOrigin: windowInitialized + }); + const screen = Screen.create(window); + const crypto = Crypto.create(window); + const customElementRegistry = CustomElementRegistry.create(window); + + define(this, { + get length() { + return window._length; + }, + get window() { + return window._globalProxy; + }, + get frameElement() { + return idlUtils.wrapperForImpl(window._frameElement); + }, + 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 external() { + return external; + }, + get location() { + return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._location); + }, + get history() { + return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._history); + }, + get navigator() { + return navigator; + }, + get locationbar() { + return locationbar; + }, + get menubar() { + return menubar; + }, + get personalbar() { + return personalbar; + }, + get scrollbars() { + return scrollbars; + }, + get statusbar() { + return statusbar; + }, + get toolbar() { + return toolbar; + }, + get performance() { + return performanceImpl; + }, + get screen() { + return screen; + }, + get crypto() { + return crypto; + }, + get origin() { + return window._origin; + }, + // The origin IDL attribute is defined with [Replaceable]. + set origin(value) { + Object.defineProperty(this, "origin", { + value, + writable: true, + enumerable: true, + configurable: true + }); + }, + get localStorage() { + if (idlUtils.implForWrapper(this._document)._origin === "null") { + throw DOMException.create(window, [ + "localStorage is not available for opaque origins", + "SecurityError" + ]); + } + + return this._localStorage; + }, + get sessionStorage() { + if (idlUtils.implForWrapper(this._document)._origin === "null") { + throw DOMException.create(window, [ + "sessionStorage is not available for opaque origins", + "SecurityError" + ]); + } + + return this._sessionStorage; + }, + get customElements() { + return customElementRegistry; + }, + get event() { + return window._currentEvent ? idlUtils.wrapperForImpl(window._currentEvent) : undefined; + }, + set event(value) { + Object.defineProperty(window, "event", { configurable: true, enumerable: true, writable: true, value }); + } + }); + + namedPropertiesWindow.initializeWindow(this, this._globalProxy); + + // ### METHODS + + // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers + + // In the spec the list of active timers is a set of IDs. We make it a map of IDs to Node.js timer objects, so that + // we can call Node.js-side clearTimeout() when clearing, and thus allow process shutdown faster. + const listOfActiveTimers = new Map(); + let latestTimerId = 0; + + this.setTimeout = function (handler, timeout = 0, ...args) { + if (typeof handler !== "function") { + handler = webIDLConversions.DOMString(handler); + } + timeout = webIDLConversions.long(timeout); + + return timerInitializationSteps(handler, timeout, args, { methodContext: window, repeat: false }); + }; + this.setInterval = function (handler, timeout = 0, ...args) { + if (typeof handler !== "function") { + handler = webIDLConversions.DOMString(handler); + } + timeout = webIDLConversions.long(timeout); + + return timerInitializationSteps(handler, timeout, args, { methodContext: window, repeat: true }); + }; + + this.clearTimeout = function (handle = 0) { + handle = webIDLConversions.long(handle); + + const nodejsTimer = listOfActiveTimers.get(handle); + if (nodejsTimer) { + clearTimeout(nodejsTimer); + listOfActiveTimers.delete(handle); + } + }; + this.clearInterval = function (handle = 0) { + handle = webIDLConversions.long(handle); + + const nodejsTimer = listOfActiveTimers.get(handle); + if (nodejsTimer) { + // We use setTimeout() in timerInitializationSteps even for this.setInterval(). + clearTimeout(nodejsTimer); + listOfActiveTimers.delete(handle); + } + }; + + function timerInitializationSteps(handler, timeout, args, { methodContext, repeat, previousHandle }) { + // This appears to be unspecced, but matches browser behavior for close()ed windows. + if (!methodContext._document) { + return 0; + } + + // TODO: implement timer nesting level behavior. + + const methodContextProxy = methodContext._globalProxy; + const handle = previousHandle !== undefined ? previousHandle : ++latestTimerId; + + function task() { + if (!listOfActiveTimers.has(handle)) { + return; + } + + try { + if (typeof handler === "function") { + handler.apply(methodContextProxy, args); + } else if (window._runScripts === "dangerously") { + vm.runInContext(handler, window, { filename: window.location.href, displayErrors: false }); + } + } catch (e) { + reportException(window, e, window.location.href); + } + + if (listOfActiveTimers.has(handle)) { + if (repeat) { + timerInitializationSteps(handler, timeout, args, { methodContext, repeat: true, previousHandle: handle }); + } else { + listOfActiveTimers.delete(handle); + } + } + } + + if (timeout < 0) { + timeout = 0; + } + + const nodejsTimer = setTimeout(task, timeout); + listOfActiveTimers.set(handle, nodejsTimer); + + return handle; + } + + // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#microtask-queuing + + this.queueMicrotask = function (callback) { + callback = IDLFunction.convert(this, callback); + + queueMicrotask(() => { + try { + callback(); + } catch (e) { + reportException(window, e, window.location.href); + } + }); + }; + + // https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animation-frames + + let animationFrameCallbackId = 0; + const mapOfAnimationFrameCallbacks = new Map(); + let animationFrameNodejsInterval = null; + + // Unlike the spec, where an animation frame happens every 60 Hz regardless, we optimize so that if there are no + // requestAnimationFrame() calls outstanding, we don't fire the timer. This helps us track that. + let numberOfOngoingAnimationFrameCallbacks = 0; + + if (this._pretendToBeVisual) { + this.requestAnimationFrame = function (callback) { + callback = IDLFunction.convert(this, callback); + + const handle = ++animationFrameCallbackId; + mapOfAnimationFrameCallbacks.set(handle, callback); + + ++numberOfOngoingAnimationFrameCallbacks; + if (numberOfOngoingAnimationFrameCallbacks === 1) { + animationFrameNodejsInterval = setInterval(() => { + runAnimationFrameCallbacks(performance.now() - windowInitialized); + }, 1000 / 60); + } + + return handle; + }; + + this.cancelAnimationFrame = function (handle) { + handle = webIDLConversions["unsigned long"](handle); + + removeAnimationFrameCallback(handle); + }; + + function runAnimationFrameCallbacks(now) { + // Converting to an array is important to get a sync snapshot and thus match spec semantics. + const callbackHandles = [...mapOfAnimationFrameCallbacks.keys()]; + for (const handle of callbackHandles) { + // This has() can be false if a callback calls cancelAnimationFrame(). + if (mapOfAnimationFrameCallbacks.has(handle)) { + const callback = mapOfAnimationFrameCallbacks.get(handle); + removeAnimationFrameCallback(handle); + try { + callback(now); + } catch (e) { + reportException(window, e, window.location.href); + } + } + } + } + + function removeAnimationFrameCallback(handle) { + if (mapOfAnimationFrameCallbacks.has(handle)) { + --numberOfOngoingAnimationFrameCallbacks; + if (numberOfOngoingAnimationFrameCallbacks === 0) { + clearInterval(animationFrameNodejsInterval); + } + } + + mapOfAnimationFrameCallbacks.delete(handle); + } + } + + function stopAllTimers() { + for (const nodejsTimer of listOfActiveTimers.values()) { + clearTimeout(nodejsTimer); + } + listOfActiveTimers.clear(); + + clearInterval(animationFrameNodejsInterval); + } + + function Option(text, value, defaultSelected, selected) { + if (text === undefined) { + text = ""; + } + text = webIDLConversions.DOMString(text); + + if (value !== undefined) { + value = webIDLConversions.DOMString(value); + } + + defaultSelected = webIDLConversions.boolean(defaultSelected); + selected = webIDLConversions.boolean(selected); + + const option = window._document.createElement("option"); + const impl = idlUtils.implForWrapper(option); + + if (text !== "") { + impl.text = text; + } + if (value !== undefined) { + impl.setAttributeNS(null, "value", value); + } + if (defaultSelected) { + impl.setAttributeNS(null, "selected", ""); + } + impl._selectedness = selected; + + return option; + } + Object.defineProperty(Option, "prototype", { + value: this.HTMLOptionElement.prototype, + configurable: false, + enumerable: false, + writable: false + }); + Object.defineProperty(window, "Option", { + value: Option, + configurable: true, + enumerable: false, + writable: true + }); + + function Image(...args) { + const img = window._document.createElement("img"); + const impl = idlUtils.implForWrapper(img); + + if (args.length > 0) { + impl.setAttributeNS(null, "width", String(args[0])); + } + if (args.length > 1) { + impl.setAttributeNS(null, "height", String(args[1])); + } + + return img; + } + Object.defineProperty(Image, "prototype", { + value: this.HTMLImageElement.prototype, + configurable: false, + enumerable: false, + writable: false + }); + Object.defineProperty(window, "Image", { + value: Image, + configurable: true, + enumerable: false, + writable: true + }); + + function Audio(src) { + const audio = window._document.createElement("audio"); + const impl = idlUtils.implForWrapper(audio); + impl.setAttributeNS(null, "preload", "auto"); + + if (src !== undefined) { + impl.setAttributeNS(null, "src", String(src)); + } + + return audio; + } + Object.defineProperty(Audio, "prototype", { + value: this.HTMLAudioElement.prototype, + configurable: false, + enumerable: false, + writable: false + }); + Object.defineProperty(window, "Audio", { + value: Audio, + configurable: true, + enumerable: false, + writable: true + }); + + this.postMessage = postMessage(window); + + this.atob = function (str) { + const result = atob(str); + if (result === null) { + throw DOMException.create(window, [ + "The string to be decoded contains invalid characters.", + "InvalidCharacterError" + ]); + } + return result; + }; + + this.btoa = function (str) { + const result = btoa(str); + if (result === null) { + throw DOMException.create(window, [ + "The string to be encoded contains invalid characters.", + "InvalidCharacterError" + ]); + } + return result; + }; + + this.stop = function () { + const manager = idlUtils.implForWrapper(this._document)._requestManager; + if (manager) { + manager.close(); + } + }; + + this.close = function () { + // Recursively close child frame windows, then ourselves (depth-first). + for (let i = 0; i < this.length; ++i) { + this[i].close(); + } + + // 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. + idlUtils.implForWrapper(this._document)._eventListeners = Object.create(null); + this._document.close(); + } + const doc = idlUtils.implForWrapper(this._document); + if (doc._requestManager) { + doc._requestManager.close(); + } + delete this._document; + } + + stopAllTimers(); + WebSocketImpl.cleanUpWindow(this); + }; + + this.getComputedStyle = function (elt, pseudoElt = undefined) { + elt = Element.convert(this, elt); + if (pseudoElt !== undefined && pseudoElt !== null) { + pseudoElt = webIDLConversions.DOMString(pseudoElt); + } + + if (pseudoElt !== undefined && pseudoElt !== null && pseudoElt !== "") { + // TODO: Parse pseudoElt + + if (SHADOW_DOM_PSEUDO_REGEXP.test(pseudoElt)) { + throw new TypeError("Tried to get the computed style of a Shadow DOM pseudo-element."); + } + + notImplemented("window.computedStyle(elt, pseudoElt)", this); + } + + const declaration = new CSSStyleDeclaration(); + const { forEach } = Array.prototype; + const { style } = elt; + + forEachMatchingSheetRuleOfElement(elt, rule => { + forEach.call(rule.style, property => { + declaration.setProperty( + property, + rule.style.getPropertyValue(property), + rule.style.getPropertyPriority(property) + ); + }); + }); + + // https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle + const declarations = Object.keys(propertiesWithResolvedValueImplemented); + forEach.call(declarations, property => { + declaration.setProperty(property, getResolvedValue(elt, property)); + }); + + forEach.call(style, property => { + declaration.setProperty(property, style.getPropertyValue(property), style.getPropertyPriority(property)); + }); + + return declaration; + }; + + this.getSelection = function () { + return window._document.getSelection(); + }; + + // The captureEvents() and releaseEvents() methods must do nothing + this.captureEvents = function () {}; + + this.releaseEvents = function () {}; + + // ### PUBLIC DATA PROPERTIES (TODO: should be getters) + + function wrapConsoleMethod(method) { + return (...args) => { + window._virtualConsole.emit(method, ...args); + }; + } + + this.console = { + assert: wrapConsoleMethod("assert"), + clear: wrapConsoleMethod("clear"), + count: wrapConsoleMethod("count"), + countReset: wrapConsoleMethod("countReset"), + debug: wrapConsoleMethod("debug"), + dir: wrapConsoleMethod("dir"), + dirxml: wrapConsoleMethod("dirxml"), + error: wrapConsoleMethod("error"), + group: wrapConsoleMethod("group"), + groupCollapsed: wrapConsoleMethod("groupCollapsed"), + groupEnd: wrapConsoleMethod("groupEnd"), + info: wrapConsoleMethod("info"), + log: wrapConsoleMethod("log"), + table: wrapConsoleMethod("table"), + time: wrapConsoleMethod("time"), + timeLog: wrapConsoleMethod("timeLog"), + timeEnd: wrapConsoleMethod("timeEnd"), + trace: wrapConsoleMethod("trace"), + warn: wrapConsoleMethod("warn") + }; + + function notImplementedMethod(name) { + return function () { + notImplemented(name, window); + }; + } + + define(this, { + name: "", + status: "", + devicePixelRatio: 1, + innerWidth: 1024, + innerHeight: 768, + outerWidth: 1024, + outerHeight: 768, + pageXOffset: 0, + pageYOffset: 0, + screenX: 0, + screenLeft: 0, + screenY: 0, + screenTop: 0, + scrollX: 0, + scrollY: 0, + + alert: notImplementedMethod("window.alert"), + blur: notImplementedMethod("window.blur"), + confirm: notImplementedMethod("window.confirm"), + 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") + }); + + // ### INITIALIZATION + + process.nextTick(() => { + if (!window.document) { + return; // window might've been closed already + } + + if (window.document.readyState === "complete") { + fireAnEvent("load", window, undefined, {}, true); + } else { + window.document.addEventListener("load", () => { + fireAnEvent("load", window, undefined, {}, true); + if (!window._document) { + return; // window might've been closed already + } + + const documentImpl = idlUtils.implForWrapper(window._document); + if (!documentImpl._pageShowingFlag) { + documentImpl._pageShowingFlag = true; + fireAPageTransitionEvent("pageshow", window, false); + } + }); + } + }); +} + +function contextifyWindow(window) { + if (vm.isContext(window)) { + return; + } + + vm.createContext(window); +} diff --git a/node_modules/jsdom/lib/jsdom/browser/default-stylesheet.js b/node_modules/jsdom/lib/jsdom/browser/default-stylesheet.js new file mode 100644 index 00000000..78f69bb9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/default-stylesheet.js @@ -0,0 +1,789 @@ +// Ideally, we would use +// https://html.spec.whatwg.org/multipage/rendering.html#the-css-user-agent-style-sheet-and-presentational-hints +// but for now, just use the version from blink. This file is copied from +// https://chromium.googlesource.com/chromium/blink/+/96aa3a280ab7d67178c8f122a04949ce5f8579e0/Source/core/css/html.css +// (removed a line which had octal literals inside since octal literals are not allowed in template strings) + +// We use a .js file because otherwise we can't browserify this. (brfs is unusable due to lack of ES2015 support) + +module.exports = ` +/* + * The default style sheet used to render HTML. + * + * Copyright (C) 2000 Lars Knoll (knoll@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +@namespace "http://www.w3.org/1999/xhtml"; + +html { + display: block +} + +:root { + scroll-blocks-on: start-touch wheel-event +} + +/* children of the element all have display:none */ +head { + display: none +} + +meta { + display: none +} + +title { + display: none +} + +link { + display: none +} + +style { + display: none +} + +script { + display: none +} + +/* generic block-level elements */ + +body { + display: block; + margin: 8px +} + +p { + display: block; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1__qem; + -webkit-margin-start: 0; + -webkit-margin-end: 0; +} + +div { + display: block +} + +layer { + display: block +} + +article, aside, footer, header, hgroup, main, nav, section { + display: block +} + +marquee { + display: inline-block; +} + +address { + display: block +} + +blockquote { + display: block; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1em; + -webkit-margin-start: 40px; + -webkit-margin-end: 40px; +} + +figcaption { + display: block +} + +figure { + display: block; + -webkit-margin-before: 1em; + -webkit-margin-after: 1em; + -webkit-margin-start: 40px; + -webkit-margin-end: 40px; +} + +q { + display: inline +} + +/* nwmatcher does not support ::before and ::after, so we can't render q +correctly: https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3 +TODO: add q::before and q::after selectors +*/ + +center { + display: block; + /* special centering to be able to emulate the html4/netscape behaviour */ + text-align: -webkit-center +} + +hr { + display: block; + -webkit-margin-before: 0.5em; + -webkit-margin-after: 0.5em; + -webkit-margin-start: auto; + -webkit-margin-end: auto; + border-style: inset; + border-width: 1px; + box-sizing: border-box +} + +map { + display: inline +} + +video { + object-fit: contain; +} + +/* heading elements */ + +h1 { + display: block; + font-size: 2em; + -webkit-margin-before: 0.67__qem; + -webkit-margin-after: 0.67em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + font-weight: bold +} + +article h1, +aside h1, +nav h1, +section h1 { + font-size: 1.5em; + -webkit-margin-before: 0.83__qem; + -webkit-margin-after: 0.83em; +} + +article article h1, +article aside h1, +article nav h1, +article section h1, +aside article h1, +aside aside h1, +aside nav h1, +aside section h1, +nav article h1, +nav aside h1, +nav nav h1, +nav section h1, +section article h1, +section aside h1, +section nav h1, +section section h1 { + font-size: 1.17em; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1em; +} + +/* Remaining selectors are deleted because nwmatcher does not support +:matches() and expanding the selectors manually would be far too verbose. +Also see https://html.spec.whatwg.org/multipage/rendering.html#sections-and-headings +TODO: rewrite to use :matches() when nwmatcher supports it. +*/ + +h2 { + display: block; + font-size: 1.5em; + -webkit-margin-before: 0.83__qem; + -webkit-margin-after: 0.83em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + font-weight: bold +} + +h3 { + display: block; + font-size: 1.17em; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + font-weight: bold +} + +h4 { + display: block; + -webkit-margin-before: 1.33__qem; + -webkit-margin-after: 1.33em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + font-weight: bold +} + +h5 { + display: block; + font-size: .83em; + -webkit-margin-before: 1.67__qem; + -webkit-margin-after: 1.67em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + font-weight: bold +} + +h6 { + display: block; + font-size: .67em; + -webkit-margin-before: 2.33__qem; + -webkit-margin-after: 2.33em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + font-weight: bold +} + +/* tables */ + +table { + display: table; + border-collapse: separate; + border-spacing: 2px; + border-color: gray +} + +thead { + display: table-header-group; + vertical-align: middle; + border-color: inherit +} + +tbody { + display: table-row-group; + vertical-align: middle; + border-color: inherit +} + +tfoot { + display: table-footer-group; + vertical-align: middle; + border-color: inherit +} + +/* for tables without table section elements (can happen with XHTML or dynamically created tables) */ +table > tr { + vertical-align: middle; +} + +col { + display: table-column +} + +colgroup { + display: table-column-group +} + +tr { + display: table-row; + vertical-align: inherit; + border-color: inherit +} + +td, th { + display: table-cell; + vertical-align: inherit +} + +th { + font-weight: bold +} + +caption { + display: table-caption; + text-align: -webkit-center +} + +/* lists */ + +ul, menu, dir { + display: block; + list-style-type: disc; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + -webkit-padding-start: 40px +} + +ol { + display: block; + list-style-type: decimal; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; + -webkit-padding-start: 40px +} + +li { + display: list-item; + text-align: -webkit-match-parent; +} + +ul ul, ol ul { + list-style-type: circle +} + +ol ol ul, ol ul ul, ul ol ul, ul ul ul { + list-style-type: square +} + +dd { + display: block; + -webkit-margin-start: 40px +} + +dl { + display: block; + -webkit-margin-before: 1__qem; + -webkit-margin-after: 1em; + -webkit-margin-start: 0; + -webkit-margin-end: 0; +} + +dt { + display: block +} + +ol ul, ul ol, ul ul, ol ol { + -webkit-margin-before: 0; + -webkit-margin-after: 0 +} + +/* form elements */ + +form { + display: block; + margin-top: 0__qem; +} + +label { + cursor: default; +} + +legend { + display: block; + -webkit-padding-start: 2px; + -webkit-padding-end: 2px; + border: none +} + +fieldset { + display: block; + -webkit-margin-start: 2px; + -webkit-margin-end: 2px; + -webkit-padding-before: 0.35em; + -webkit-padding-start: 0.75em; + -webkit-padding-end: 0.75em; + -webkit-padding-after: 0.625em; + border: 2px groove ThreeDFace; + min-width: -webkit-min-content; +} + +button { + -webkit-appearance: button; +} + +/* Form controls don't go vertical. */ +input, textarea, select, button, meter, progress { + -webkit-writing-mode: horizontal-tb !important; +} + +input, textarea, select, button { + margin: 0__qem; + font: -webkit-small-control; + text-rendering: auto; /* FIXME: Remove when tabs work with optimizeLegibility. */ + color: initial; + letter-spacing: normal; + word-spacing: normal; + line-height: normal; + text-transform: none; + text-indent: 0; + text-shadow: none; + display: inline-block; + text-align: start; +} + +/* TODO: Add " i" to attribute matchers to support case-insensitive matching */ +input[type="hidden"] { + display: none +} + +input { + -webkit-appearance: textfield; + padding: 1px; + background-color: white; + border: 2px inset; + -webkit-rtl-ordering: logical; + -webkit-user-select: text; + cursor: auto; +} + +input[type="search"] { + -webkit-appearance: searchfield; + box-sizing: border-box; +} + +select { + border-radius: 5px; +} + +textarea { + -webkit-appearance: textarea; + background-color: white; + border: 1px solid; + -webkit-rtl-ordering: logical; + -webkit-user-select: text; + flex-direction: column; + resize: auto; + cursor: auto; + padding: 2px; + white-space: pre-wrap; + word-wrap: break-word; +} + +input[type="password"] { + -webkit-text-security: disc !important; +} + +input[type="hidden"], input[type="image"], input[type="file"] { + -webkit-appearance: initial; + padding: initial; + background-color: initial; + border: initial; +} + +input[type="file"] { + align-items: baseline; + color: inherit; + text-align: start !important; +} + +input[type="radio"], input[type="checkbox"] { + margin: 3px 0.5ex; + padding: initial; + background-color: initial; + border: initial; +} + +input[type="button"], input[type="submit"], input[type="reset"] { + -webkit-appearance: push-button; + -webkit-user-select: none; + white-space: pre +} + +input[type="button"], input[type="submit"], input[type="reset"], button { + align-items: flex-start; + text-align: center; + cursor: default; + color: ButtonText; + padding: 2px 6px 3px 6px; + border: 2px outset ButtonFace; + background-color: ButtonFace; + box-sizing: border-box +} + +input[type="range"] { + -webkit-appearance: slider-horizontal; + padding: initial; + border: initial; + margin: 2px; + color: #909090; +} + +input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, +button:disabled, select:disabled, optgroup:disabled, option:disabled, +select[disabled]>option { + color: GrayText +} + +input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active, button:active { + border-style: inset +} + +input[type="button"]:active:disabled, input[type="submit"]:active:disabled, input[type="reset"]:active:disabled, button:active:disabled { + border-style: outset +} + +datalist { + display: none +} + +area { + display: inline; + cursor: pointer; +} + +param { + display: none +} + +input[type="checkbox"] { + -webkit-appearance: checkbox; + box-sizing: border-box; +} + +input[type="radio"] { + -webkit-appearance: radio; + box-sizing: border-box; +} + +input[type="color"] { + -webkit-appearance: square-button; + width: 44px; + height: 23px; + background-color: ButtonFace; + /* Same as native_theme_base. */ + border: 1px #a9a9a9 solid; + padding: 1px 2px; +} + +input[type="color"][list] { + -webkit-appearance: menulist; + width: 88px; + height: 23px +} + +select { + -webkit-appearance: menulist; + box-sizing: border-box; + align-items: center; + border: 1px solid; + white-space: pre; + -webkit-rtl-ordering: logical; + color: black; + background-color: white; + cursor: default; +} + +optgroup { + font-weight: bolder; + display: block; +} + +option { + font-weight: normal; + display: block; + padding: 0 2px 1px 2px; + white-space: pre; + min-height: 1.2em; +} + +output { + display: inline; +} + +/* meter */ + +meter { + -webkit-appearance: meter; + box-sizing: border-box; + display: inline-block; + height: 1em; + width: 5em; + vertical-align: -0.2em; +} + +/* progress */ + +progress { + -webkit-appearance: progress-bar; + box-sizing: border-box; + display: inline-block; + height: 1em; + width: 10em; + vertical-align: -0.2em; +} + +/* inline elements */ + +u, ins { + text-decoration: underline +} + +strong, b { + font-weight: bold +} + +i, cite, em, var, address, dfn { + font-style: italic +} + +tt, code, kbd, samp { + font-family: monospace +} + +pre, xmp, plaintext, listing { + display: block; + font-family: monospace; + white-space: pre; + margin: 1__qem 0 +} + +mark { + background-color: yellow; + color: black +} + +big { + font-size: larger +} + +small { + font-size: smaller +} + +s, strike, del { + text-decoration: line-through +} + +sub { + vertical-align: sub; + font-size: smaller +} + +sup { + vertical-align: super; + font-size: smaller +} + +nobr { + white-space: nowrap +} + +/* states */ + +:focus { + outline: auto 5px -webkit-focus-ring-color +} + +/* Read-only text fields do not show a focus ring but do still receive focus */ +html:focus, body:focus, input[readonly]:focus { + outline: none +} + +embed:focus, iframe:focus, object:focus { + outline: none +} + +input:focus, textarea:focus, select:focus { + outline-offset: -2px +} + +input[type="button"]:focus, +input[type="checkbox"]:focus, +input[type="file"]:focus, +input[type="hidden"]:focus, +input[type="image"]:focus, +input[type="radio"]:focus, +input[type="reset"]:focus, +input[type="search"]:focus, +input[type="submit"]:focus { + outline-offset: 0 +} + +/* HTML5 ruby elements */ + +ruby, rt { + text-indent: 0; /* blocks used for ruby rendering should not trigger this */ +} + +rt { + line-height: normal; + -webkit-text-emphasis: none; +} + +ruby > rt { + display: block; + font-size: 50%; + text-align: start; +} + +ruby > rp { + display: none; +} + +/* other elements */ + +noframes { + display: none +} + +frameset, frame { + display: block +} + +frameset { + border-color: inherit +} + +iframe { + border: 2px inset +} + +details { + display: block +} + +summary { + display: block +} + +template { + display: none +} + +bdi, output { + unicode-bidi: -webkit-isolate; +} + +bdo { + unicode-bidi: bidi-override; +} + +textarea[dir=auto] { + unicode-bidi: -webkit-plaintext; +} + +dialog:not([open]) { + display: none +} + +dialog { + position: absolute; + left: 0; + right: 0; + width: -webkit-fit-content; + height: -webkit-fit-content; + margin: auto; + border: solid; + padding: 1em; + background: white; + color: black +} + +[hidden] { + display: none +} + +/* noscript is handled internally, as it depends on settings. */ + +`; diff --git a/node_modules/jsdom/lib/jsdom/browser/js-globals.json b/node_modules/jsdom/lib/jsdom/browser/js-globals.json new file mode 100644 index 00000000..c4de05fa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/js-globals.json @@ -0,0 +1,307 @@ +{ + "Object": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Function": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Number": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "parseFloat": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "parseInt": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Infinity": { + "writable": false, + "enumerable": false, + "configurable": false + }, + "NaN": { + "writable": false, + "enumerable": false, + "configurable": false + }, + "undefined": { + "writable": false, + "enumerable": false, + "configurable": false + }, + "Boolean": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "String": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Symbol": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Date": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Promise": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "RegExp": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Error": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "AggregateError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "EvalError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "RangeError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "ReferenceError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "SyntaxError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "TypeError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "URIError": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "globalThis": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "JSON": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Math": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Intl": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "ArrayBuffer": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Uint8Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Int8Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Uint16Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Int16Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Uint32Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Int32Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Float32Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Float64Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Uint8ClampedArray": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "BigUint64Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "BigInt64Array": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "DataView": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Map": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "BigInt": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Set": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "WeakMap": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "WeakSet": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Proxy": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Reflect": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "FinalizationRegistry": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "WeakRef": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "decodeURI": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "decodeURIComponent": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "encodeURI": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "encodeURIComponent": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "escape": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "unescape": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "eval": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "isFinite": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "isNaN": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "SharedArrayBuffer": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "Atomics": { + "writable": true, + "enumerable": false, + "configurable": true + }, + "WebAssembly": { + "writable": true, + "enumerable": false, + "configurable": true + } +} diff --git a/node_modules/jsdom/lib/jsdom/browser/not-implemented.js b/node_modules/jsdom/lib/jsdom/browser/not-implemented.js new file mode 100644 index 00000000..a87cc95c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/not-implemented.js @@ -0,0 +1,13 @@ +"use strict"; + +module.exports = function (nameForErrorMessage, window) { + if (!window) { + // Do nothing for window-less documents. + return; + } + + const error = new Error(`Not implemented: ${nameForErrorMessage}`); + error.type = "not implemented"; + + window._virtualConsole.emit("jsdomError", error); +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/parser/html.js b/node_modules/jsdom/lib/jsdom/browser/parser/html.js new file mode 100644 index 00000000..f41bf02e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/parser/html.js @@ -0,0 +1,208 @@ +"use strict"; + +const parse5 = require("parse5"); + +const { createElement } = require("../../living/helpers/create-element"); +const { HTML_NS } = require("../../living/helpers/namespaces"); + +const DocumentType = require("../../living/generated/DocumentType"); +const DocumentFragment = require("../../living/generated/DocumentFragment"); +const Text = require("../../living/generated/Text"); +const Comment = require("../../living/generated/Comment"); + +const attributes = require("../../living/attributes"); +const nodeTypes = require("../../living/node-type"); + +const serializationAdapter = require("../../living/domparsing/parse5-adapter-serialization"); +const { + customElementReactionsStack, invokeCEReactions, lookupCEDefinition +} = require("../../living/helpers/custom-elements"); + + +class JSDOMParse5Adapter { + constructor(documentImpl, options = {}) { + this._documentImpl = documentImpl; + this._globalObject = documentImpl._globalObject; + this._fragment = options.fragment || false; + + // Since the createElement hook doesn't provide the parent element, we keep track of this using _currentElement: + // https://github.com/inikulin/parse5/issues/285. + this._currentElement = undefined; + } + + _ownerDocument() { + const { _currentElement } = this; + + // The _currentElement is undefined when parsing elements at the root of the document. + if (_currentElement) { + return _currentElement.localName === "template" && _currentElement.namespaceURI === HTML_NS ? + _currentElement.content._ownerDocument : + _currentElement._ownerDocument; + } + + return this._documentImpl; + } + + createDocument() { + // parse5's model assumes that parse(html) will call into here to create the new Document, then return it. However, + // jsdom's model assumes we can create a Window (and through that create an empty Document), do some other setup + // stuff, and then parse, stuffing nodes into that Document as we go. So to adapt between these two models, we just + // return the already-created Document when asked by parse5 to "create" a Document. + return this._documentImpl; + } + + createDocumentFragment() { + const ownerDocument = this._ownerDocument(); + return DocumentFragment.createImpl(this._globalObject, [], { ownerDocument }); + } + + // https://html.spec.whatwg.org/#create-an-element-for-the-token + createElement(localName, namespace, attrs) { + const ownerDocument = this._ownerDocument(); + + const isAttribute = attrs.find(attr => attr.name === "is"); + const isValue = isAttribute ? isAttribute.value : null; + + const definition = lookupCEDefinition(ownerDocument, namespace, localName); + + let willExecuteScript = false; + if (definition !== null && !this._fragment) { + willExecuteScript = true; + } + + if (willExecuteScript) { + ownerDocument._throwOnDynamicMarkupInsertionCounter++; + customElementReactionsStack.push([]); + } + + const element = createElement(ownerDocument, localName, namespace, null, isValue, willExecuteScript); + this.adoptAttributes(element, attrs); + + if (willExecuteScript) { + const queue = customElementReactionsStack.pop(); + invokeCEReactions(queue); + ownerDocument._throwOnDynamicMarkupInsertionCounter--; + } + + if ("_parserInserted" in element) { + element._parserInserted = true; + } + + return element; + } + + createCommentNode(data) { + const ownerDocument = this._ownerDocument(); + return Comment.createImpl(this._globalObject, [], { data, ownerDocument }); + } + + appendChild(parentNode, newNode) { + parentNode._append(newNode); + } + + insertBefore(parentNode, newNode, referenceNode) { + parentNode._insert(newNode, referenceNode); + } + + setTemplateContent(templateElement, contentFragment) { + // This code makes the glue between jsdom and parse5 HTMLTemplateElement parsing: + // + // * jsdom during the construction of the HTMLTemplateElement (for example when create via + // `document.createElement("template")`), creates a DocumentFragment and set it into _templateContents. + // * parse5 when parsing a tag creates an HTMLTemplateElement (`createElement` adapter hook) and also + // create a DocumentFragment (`createDocumentFragment` adapter hook). + // + // At this point we now have to replace the one created in jsdom with one created by parse5. + const { _ownerDocument, _host } = templateElement._templateContents; + contentFragment._ownerDocument = _ownerDocument; + contentFragment._host = _host; + + templateElement._templateContents = contentFragment; + } + + setDocumentType(document, name, publicId, systemId) { + const ownerDocument = this._ownerDocument(); + const documentType = DocumentType.createImpl(this._globalObject, [], { name, publicId, systemId, ownerDocument }); + + document._append(documentType); + } + + setDocumentMode(document, mode) { + // TODO: the rest of jsdom ignores this + document._mode = mode; + } + + detachNode(node) { + node.remove(); + } + + insertText(parentNode, text) { + const { lastChild } = parentNode; + if (lastChild && lastChild.nodeType === nodeTypes.TEXT_NODE) { + lastChild.data += text; + } else { + const ownerDocument = this._ownerDocument(); + const textNode = Text.createImpl(this._globalObject, [], { data: text, ownerDocument }); + parentNode._append(textNode); + } + } + + insertTextBefore(parentNode, text, referenceNode) { + const { previousSibling } = referenceNode; + if (previousSibling && previousSibling.nodeType === nodeTypes.TEXT_NODE) { + previousSibling.data += text; + } else { + const ownerDocument = this._ownerDocument(); + const textNode = Text.createImpl(this._globalObject, [], { data: text, ownerDocument }); + parentNode._append(textNode, referenceNode); + } + } + + adoptAttributes(element, attrs) { + for (const attr of attrs) { + const prefix = attr.prefix === "" ? null : attr.prefix; + attributes.setAttributeValue(element, attr.name, attr.value, prefix, attr.namespace); + } + } + + onItemPush(after) { + this._currentElement = after; + after._pushedOnStackOfOpenElements?.(); + } + + onItemPop(before, newTop) { + this._currentElement = newTop; + before._poppedOffStackOfOpenElements?.(); + } +} + +// Assign shared adapters with serializer. +Object.assign(JSDOMParse5Adapter.prototype, serializationAdapter); + +function parseFragment(markup, contextElement) { + const ownerDocument = contextElement.localName === "template" && contextElement.namespaceURI === HTML_NS ? + contextElement.content._ownerDocument : + contextElement._ownerDocument; + + const config = { + ...ownerDocument._parseOptions, + sourceCodeLocationInfo: false, + treeAdapter: new JSDOMParse5Adapter(ownerDocument, { fragment: true }) + }; + + return parse5.parseFragment(contextElement, markup, config); +} + +function parseIntoDocument(markup, ownerDocument) { + const config = { + ...ownerDocument._parseOptions, + treeAdapter: new JSDOMParse5Adapter(ownerDocument) + }; + + return parse5.parse(markup, config); +} + +module.exports = { + parseFragment, + parseIntoDocument +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/parser/index.js b/node_modules/jsdom/lib/jsdom/browser/parser/index.js new file mode 100644 index 00000000..e09df956 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/parser/index.js @@ -0,0 +1,37 @@ +"use strict"; + +const xmlParser = require("./xml"); +const htmlParser = require("./html"); + +// https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm +function parseFragment(markup, contextElement) { + const { _parsingMode } = contextElement._ownerDocument; + + let parseAlgorithm; + if (_parsingMode === "html") { + parseAlgorithm = htmlParser.parseFragment; + } else if (_parsingMode === "xml") { + parseAlgorithm = xmlParser.parseFragment; + } + + // Note: HTML and XML fragment parsing algorithm already return a document fragments; no need to do steps 3 and 4 + return parseAlgorithm(markup, contextElement); +} + +function parseIntoDocument(markup, ownerDocument) { + const { _parsingMode } = ownerDocument; + + let parseAlgorithm; + if (_parsingMode === "html") { + parseAlgorithm = htmlParser.parseIntoDocument; + } else if (_parsingMode === "xml") { + parseAlgorithm = xmlParser.parseIntoDocument; + } + + return parseAlgorithm(markup, ownerDocument); +} + +module.exports = { + parseFragment, + parseIntoDocument +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/parser/xml.js b/node_modules/jsdom/lib/jsdom/browser/parser/xml.js new file mode 100644 index 00000000..f5f13c31 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/parser/xml.js @@ -0,0 +1,202 @@ +"use strict"; + +const { SaxesParser } = require("saxes"); +const DOMException = require("domexception/webidl2js-wrapper"); + +const { createElement } = require("../../living/helpers/create-element"); + +const DocumentFragment = require("../../living/generated/DocumentFragment"); +const DocumentType = require("../../living/generated/DocumentType"); +const CDATASection = require("../../living/generated/CDATASection"); +const Comment = require("../../living/generated/Comment"); +const ProcessingInstruction = require("../../living/generated/ProcessingInstruction"); +const Text = require("../../living/generated/Text"); + +const attributes = require("../../living/attributes"); +const { HTML_NS } = require("../../living/helpers/namespaces"); + +const HTML5_DOCTYPE = //i; +const PUBLIC_DOCTYPE = /]+)/i; + +function parseDocType(globalObject, ownerDocument, html) { + if (HTML5_DOCTYPE.test(html)) { + return createDocumentType(globalObject, ownerDocument, "html", "", ""); + } + + const publicPieces = PUBLIC_DOCTYPE.exec(html); + if (publicPieces) { + return createDocumentType(globalObject, ownerDocument, publicPieces[1], publicPieces[2], publicPieces[3]); + } + + const systemPieces = SYSTEM_DOCTYPE.exec(html); + if (systemPieces) { + return createDocumentType(globalObject, ownerDocument, systemPieces[1], "", systemPieces[2]); + } + + const namePiece = CUSTOM_NAME_DOCTYPE.exec(html)[1] || "html"; + return createDocumentType(globalObject, ownerDocument, namePiece, "", ""); +} + +function createDocumentType(globalObject, ownerDocument, name, publicId, systemId) { + return DocumentType.createImpl(globalObject, [], { ownerDocument, name, publicId, systemId }); +} + +function isHTMLTemplateElement(element) { + return element.tagName === "template" && element.namespaceURI === HTML_NS; +} + + +function createParser(rootNode, globalObject, saxesOptions) { + const parser = new SaxesParser({ + ...saxesOptions, + // Browsers always have namespace support. + xmlns: true, + // We force the parser to treat all documents (even documents declaring themselves to be XML 1.1 documents) as XML + // 1.0 documents. See https://github.com/jsdom/jsdom/issues/2677 for a discussion of the stakes. + defaultXMLVersion: "1.0", + forceXMLVersion: true + }); + const openStack = [rootNode]; + + function getOwnerDocument() { + const currentElement = openStack[openStack.length - 1]; + + return isHTMLTemplateElement(currentElement) ? + currentElement._templateContents._ownerDocument : + currentElement._ownerDocument; + } + + function appendChild(child) { + const parentElement = openStack[openStack.length - 1]; + + if (isHTMLTemplateElement(parentElement)) { + parentElement._templateContents._insert(child, null); + } else { + parentElement._insert(child, null); + } + } + + parser.on("text", saxesOptions.fragment ? + // In a fragment, all text events produced by saxes must result in a text + // node. + data => { + const ownerDocument = getOwnerDocument(); + appendChild(Text.createImpl(globalObject, [], { data, ownerDocument })); + } : + // When parsing a whole document, we must ignore those text nodes that are + // produced outside the root element. Saxes produces events for them, + // but DOM trees do not record text outside the root element. + data => { + if (openStack.length > 1) { + const ownerDocument = getOwnerDocument(); + appendChild(Text.createImpl(globalObject, [], { data, ownerDocument })); + } + }); + + parser.on("cdata", data => { + const ownerDocument = getOwnerDocument(); + appendChild(CDATASection.createImpl(globalObject, [], { data, ownerDocument })); + }); + + parser.on("opentag", tag => { + const { local: tagLocal, attributes: tagAttributes } = tag; + + const ownerDocument = getOwnerDocument(); + const tagNamespace = tag.uri === "" ? null : tag.uri; + const tagPrefix = tag.prefix === "" ? null : tag.prefix; + const isValue = tagAttributes.is === undefined ? null : tagAttributes.is.value; + + const elem = createElement(ownerDocument, tagLocal, tagNamespace, tagPrefix, isValue, true); + + // We mark a script element as "parser-inserted", which prevents it from + // being immediately executed. + if (tagLocal === "script" && tagNamespace === HTML_NS) { + elem._parserInserted = true; + } + + for (const key of Object.keys(tagAttributes)) { + const { prefix, local, uri, value } = tagAttributes[key]; + attributes.setAttributeValue(elem, local, value, prefix === "" ? null : prefix, uri === "" ? null : uri); + } + + appendChild(elem); + openStack.push(elem); + }); + + parser.on("closetag", () => { + const elem = openStack.pop(); + // Once a script is populated, we can execute it. + if (elem.localName === "script" && elem.namespaceURI === HTML_NS) { + elem._eval(); + } + }); + + parser.on("comment", data => { + const ownerDocument = getOwnerDocument(); + appendChild(Comment.createImpl(globalObject, [], { data, ownerDocument })); + }); + + parser.on("processinginstruction", ({ target, body }) => { + const ownerDocument = getOwnerDocument(); + appendChild(ProcessingInstruction.createImpl(globalObject, [], { target, data: body, ownerDocument })); + }); + + parser.on("doctype", dt => { + const ownerDocument = getOwnerDocument(); + appendChild(parseDocType(globalObject, ownerDocument, ``)); + + const entityMatcher = //g; + let result; + while ((result = entityMatcher.exec(dt))) { + const [, name, value] = result; + if (!(name in parser.ENTITIES)) { + parser.ENTITIES[name] = value; + } + } + }); + + parser.on("error", err => { + throw DOMException.create(globalObject, [err.message, "SyntaxError"]); + }); + + return parser; +} + +function parseFragment(markup, contextElement) { + const { _globalObject, _ownerDocument } = contextElement; + + const fragment = DocumentFragment.createImpl(_globalObject, [], { ownerDocument: _ownerDocument }); + + // Only parseFragment needs resolvePrefix per the saxes documentation: + // https://github.com/lddubeau/saxes#parsing-xml-fragments + const parser = createParser(fragment, _globalObject, { + fragment: true, + resolvePrefix(prefix) { + // saxes wants undefined as the return value if the prefix is not defined, not null. + return contextElement.lookupNamespaceURI(prefix) || undefined; + } + }); + + parser.write(markup).close(); + + return fragment; +} + +function parseIntoDocument(markup, ownerDocument) { + const { _globalObject } = ownerDocument; + + const parser = createParser(ownerDocument, _globalObject, { + fileName: ownerDocument.location && ownerDocument.location.href + }); + + parser.write(markup).close(); + + return ownerDocument; +} + +module.exports = { + parseFragment, + parseIntoDocument +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/resources/async-resource-queue.js b/node_modules/jsdom/lib/jsdom/browser/resources/async-resource-queue.js new file mode 100644 index 00000000..51c7bb71 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/resources/async-resource-queue.js @@ -0,0 +1,114 @@ +"use strict"; + +class QueueItem { + constructor(onLoad, onError, dependentItem) { + this.onLoad = onLoad; + this.onError = onError; + this.data = null; + this.error = null; + this.dependentItem = dependentItem; + } +} + +/** + * AsyncResourceQueue is the queue in charge of run the async scripts + * and notify when they finish. + */ +module.exports = class AsyncResourceQueue { + constructor() { + this.items = new Set(); + this.dependentItems = new Set(); + } + + count() { + return this.items.size + this.dependentItems.size; + } + + _notify() { + if (this._listener) { + this._listener(); + } + } + + _check(item) { + let promise; + + if (item.onError && item.error) { + promise = item.onError(item.error); + } else if (item.onLoad && item.data) { + promise = item.onLoad(item.data); + } + + promise + .then(() => { + this.items.delete(item); + this.dependentItems.delete(item); + + if (this.count() === 0) { + this._notify(); + } + }); + } + + setListener(listener) { + this._listener = listener; + } + + push(request, onLoad, onError, dependentItem) { + const q = this; + + const item = new QueueItem(onLoad, onError, dependentItem); + + q.items.add(item); + + return request + .then(data => { + item.data = data; + + if (dependentItem && !dependentItem.finished) { + q.dependentItems.add(item); + return q.items.delete(item); + } + + if (onLoad) { + return q._check(item); + } + + q.items.delete(item); + + if (q.count() === 0) { + q._notify(); + } + + return null; + }) + .catch(err => { + item.error = err; + + if (dependentItem && !dependentItem.finished) { + q.dependentItems.add(item); + return q.items.delete(item); + } + + if (onError) { + return q._check(item); + } + + q.items.delete(item); + + if (q.count() === 0) { + q._notify(); + } + + return null; + }); + } + + notifyItem(syncItem) { + for (const item of this.dependentItems) { + if (item.dependentItem === syncItem) { + this._check(item); + } + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/resources/no-op-resource-loader.js b/node_modules/jsdom/lib/jsdom/browser/resources/no-op-resource-loader.js new file mode 100644 index 00000000..985509c4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/resources/no-op-resource-loader.js @@ -0,0 +1,8 @@ +"use strict"; +const ResourceLoader = require("./resource-loader.js"); + +module.exports = class NoOpResourceLoader extends ResourceLoader { + fetch() { + return null; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js b/node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js new file mode 100644 index 00000000..8a106139 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js @@ -0,0 +1,95 @@ +"use strict"; +const idlUtils = require("../../living/generated/utils"); +const { fireAnEvent } = require("../../living/helpers/events"); + +module.exports = class PerDocumentResourceLoader { + constructor(document) { + this._document = document; + this._defaultEncoding = document._encoding; + this._resourceLoader = document._defaultView ? document._defaultView._resourceLoader : null; + this._requestManager = document._requestManager; + this._queue = document._queue; + this._deferQueue = document._deferQueue; + this._asyncQueue = document._asyncQueue; + } + + fetch(url, { element, onLoad, onError }) { + const request = this._resourceLoader.fetch(url, { + cookieJar: this._document._cookieJar, + element: idlUtils.wrapperForImpl(element), + referrer: this._document.URL + }); + + if (request === null) { + return null; + } + + this._requestManager.add(request); + + const onErrorWrapped = error => { + this._requestManager.remove(request); + + if (onError) { + onError(error); + } + + fireAnEvent("error", element); + + const err = new Error(`Could not load ${element.localName}: "${url}"`); + err.type = "resource loading"; + err.detail = error; + + this._document._defaultView._virtualConsole.emit("jsdomError", err); + + return Promise.resolve(); + }; + + const onLoadWrapped = data => { + this._requestManager.remove(request); + + this._addCookies(url, request.response ? request.response.headers : {}); + + try { + const result = onLoad ? onLoad(data) : undefined; + + return Promise.resolve(result) + .then(() => { + fireAnEvent("load", element); + + return Promise.resolve(); + }) + .catch(err => { + return onErrorWrapped(err); + }); + } catch (err) { + return onErrorWrapped(err); + } + }; + + if (element.localName === "script" && element.hasAttributeNS(null, "async")) { + this._asyncQueue.push(request, onLoadWrapped, onErrorWrapped, this._queue.getLastScript()); + } else if (element.localName === "script" && element.hasAttributeNS(null, "defer")) { + this._deferQueue.push(request, onLoadWrapped, onErrorWrapped, false, element); + } else { + this._queue.push(request, onLoadWrapped, onErrorWrapped, false, element); + } + + return request; + } + + _addCookies(url, headers) { + let cookies = headers["set-cookie"]; + + if (!cookies) { + return; + } + + if (!Array.isArray(cookies)) { + cookies = [cookies]; + } + + cookies.forEach(cookie => { + this._document._cookieJar.setCookieSync(cookie, url, { http: true, ignoreError: true }); + }); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/resources/request-manager.js b/node_modules/jsdom/lib/jsdom/browser/resources/request-manager.js new file mode 100644 index 00000000..dbf6ccb5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/resources/request-manager.js @@ -0,0 +1,33 @@ +"use strict"; + +/** + * Manage all the request and it is able to abort + * all pending request. + */ +module.exports = class RequestManager { + constructor() { + this.openedRequests = []; + } + + add(req) { + this.openedRequests.push(req); + } + + remove(req) { + const idx = this.openedRequests.indexOf(req); + if (idx !== -1) { + this.openedRequests.splice(idx, 1); + } + } + + close() { + for (const openedRequest of this.openedRequests) { + openedRequest.abort(); + } + this.openedRequests = []; + } + + size() { + return this.openedRequests.length; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js b/node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js new file mode 100644 index 00000000..0751b2cc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/resources/resource-loader.js @@ -0,0 +1,142 @@ +"use strict"; +const fs = require("fs"); +const { fileURLToPath } = require("url"); +const { parseURL } = require("whatwg-url"); +const dataURLFromRecord = require("data-urls").fromURLRecord; +const packageVersion = require("../../../../package.json").version; +const agentFactory = require("../../living/helpers/agent-factory"); +const Request = require("../../living/helpers/http-request"); + +const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]"; + +module.exports = class ResourceLoader { + constructor({ + strictSSL = true, + proxy = undefined, + userAgent = `Mozilla/5.0 (${process.platform || "unknown OS"}) AppleWebKit/537.36 ` + + `(KHTML, like Gecko) jsdom/${packageVersion}` + } = {}) { + this._strictSSL = strictSSL; + this._proxy = proxy; + this._userAgent = userAgent; + } + + _readDataURL(urlRecord) { + const dataURL = dataURLFromRecord(urlRecord); + let timeoutId; + const promise = new Promise(resolve => { + timeoutId = setTimeout(resolve, 0, Buffer.from(dataURL.body)); + }); + promise.abort = () => { + if (timeoutId !== undefined) { + clearTimeout(timeoutId); + } + }; + return promise; + } + + _readFile(filePath) { + let readableStream, abort; // Native Promises doesn't have an "abort" method. + + // Creating a promise for two reason: + // 1. fetch always return a promise. + // 2. We need to add an abort handler. + const promise = new Promise((resolve, reject) => { + readableStream = fs.createReadStream(filePath); + let data = Buffer.alloc(0); + + abort = reject; + + readableStream.on("error", reject); + + readableStream.on("data", chunk => { + data = Buffer.concat([data, chunk]); + }); + + readableStream.on("end", () => { + resolve(data); + }); + }); + + promise.abort = () => { + readableStream.destroy(); + const error = new Error("request canceled by user"); + error.isAbortError = true; + abort(error); + }; + + return promise; + } + + fetch(urlString, { accept, cookieJar, referrer } = {}) { + const url = parseURL(urlString); + + if (!url) { + return Promise.reject(new Error(`Tried to fetch invalid URL ${urlString}`)); + } + + switch (url.scheme) { + case "data": { + return this._readDataURL(url); + } + + case "http": + case "https": { + const agents = agentFactory(this._proxy, this._strictSSL); + const headers = { + "User-Agent": this._userAgent, + "Accept-Language": "en", + "Accept-Encoding": "gzip", + "Accept": accept || "*/*" + }; + if (referrer && !IS_BROWSER) { + headers.Referer = referrer; + } + const requestClient = new Request( + urlString, + { followRedirects: true, cookieJar, agents }, + { headers } + ); + const promise = new Promise((resolve, reject) => { + const accumulated = []; + requestClient.once("response", res => { + promise.response = res; + const { statusCode } = res; + // TODO This deviates from the spec when it comes to + // loading resources such as images + if (statusCode < 200 || statusCode > 299) { + requestClient.abort(); + reject(new Error(`Resource was not loaded. Status: ${statusCode}`)); + } + }); + requestClient.on("data", chunk => { + accumulated.push(chunk); + }); + requestClient.on("end", () => resolve(Buffer.concat(accumulated))); + requestClient.on("error", reject); + }); + // The method fromURL in lib/api.js crashes without the following four + // properties defined on the Promise instance, causing the test suite to halt + requestClient.on("end", () => { + promise.href = requestClient.currentURL; + }); + promise.abort = requestClient.abort.bind(requestClient); + promise.getHeader = name => headers[name] || requestClient.getHeader(name); + requestClient.end(); + return promise; + } + + case "file": { + try { + return this._readFile(fileURLToPath(urlString)); + } catch (e) { + return Promise.reject(e); + } + } + + default: { + return Promise.reject(new Error(`Tried to fetch URL ${urlString} with invalid scheme ${url.scheme}`)); + } + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js b/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js new file mode 100644 index 00000000..c7d8f0fc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js @@ -0,0 +1,142 @@ +"use strict"; + +/** + * Queue for all the resources to be download except async scripts. + * Async scripts have their own queue AsyncResourceQueue. + */ +module.exports = class ResourceQueue { + constructor({ paused, asyncQueue } = {}) { + this.paused = Boolean(paused); + this._asyncQueue = asyncQueue; + } + + getLastScript() { + let head = this.tail; + + while (head) { + if (head.isScript) { + return head; + } + head = head.prev; + } + + return null; + } + + _moreScripts() { + let found = false; + + let head = this.tail; + while (head && !found) { + found = head.isScript; + head = head.prev; + } + + return found; + } + + _notify() { + if (this._listener) { + this._listener(); + } + } + + setListener(listener) { + this._listener = listener; + } + + push(request, onLoad, onError, keepLast, element) { + const isScript = element ? element.localName === "script" : false; + + if (!request) { + if (isScript && !this._moreScripts()) { + return onLoad(); + } + + request = Promise.resolve(); + } + const q = this; + const item = { + isScript, + err: null, + element, + fired: false, + data: null, + keepLast, + prev: q.tail, + check() { + if (!q.paused && !this.prev && this.fired) { + let promise; + + if (this.err && onError) { + promise = onError(this.err); + } + + if (!this.err && onLoad) { + promise = onLoad(this.data); + } + + Promise.resolve(promise) + .then(() => { + if (this.next) { + this.next.prev = null; + this.next.check(); + } else { // q.tail===this + q.tail = null; + q._notify(); + } + + this.finished = true; + + if (q._asyncQueue) { + q._asyncQueue.notifyItem(this); + } + }); + } + } + }; + if (q.tail) { + if (q.tail.keepLast) { + // if the tail is the load event in document and we receive a new element to load + // we should add this new request before the load event. + if (q.tail.prev) { + q.tail.prev.next = item; + } + item.prev = q.tail.prev; + q.tail.prev = item; + item.next = q.tail; + } else { + q.tail.next = item; + q.tail = item; + } + } else { + q.tail = item; + } + return request + .then(data => { + item.fired = 1; + item.data = data; + item.check(); + }) + .catch(err => { + item.fired = true; + item.err = err; + item.check(); + }); + } + + resume() { + if (!this.paused) { + return; + } + this.paused = false; + + let head = this.tail; + while (head && head.prev) { + head = head.prev; + } + if (head) { + head.check(); + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/level2/style.js b/node_modules/jsdom/lib/jsdom/level2/style.js new file mode 100644 index 00000000..bf236b90 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/level2/style.js @@ -0,0 +1,57 @@ +"use strict"; +const cssom = require("cssom"); +const cssstyle = require("cssstyle"); + +exports.addToCore = core => { + // 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; + + // Relevant 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 +}; diff --git a/node_modules/jsdom/lib/jsdom/level3/xpath.js b/node_modules/jsdom/lib/jsdom/level3/xpath.js new file mode 100644 index 00000000..28648c44 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/level3/xpath.js @@ -0,0 +1,1874 @@ +/** Here is yet another implementation of XPath 1.0 in Javascript. + * + * My goal was to make it relatively compact, but as I fixed all the axis bugs + * the axes became more and more complicated. :-(. + * + * I have not implemented namespaces or case-sensitive axes for XML yet. + * + * How to test it in Chrome: You can make a Chrome extension that replaces + * the WebKit XPath parser with this one. But it takes a bit of effort to + * get around isolated world and same-origin restrictions: + * manifest.json: + { + "name": "XPathTest", + "version": "0.1", + "content_scripts": [{ + "matches": ["http://localhost/*"], // or wildcard host + "js": ["xpath.js", "injection.js"], + "all_frames": true, "run_at": "document_start" + }] + } + * injection.js: + // goal: give my xpath object to the website's JS context. + var script = document.createElement('script'); + script.textContent = + "document.addEventListener('xpathextend', function(e) {\n" + + " console.log('extending document with xpath...');\n" + + " e.detail(window);" + + "});"; + document.documentElement.appendChild(script); + document.documentElement.removeChild(script); + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent('xpathextend', true, true, this.xpath.extend); + document.dispatchEvent(evt); + */ +module.exports = core => { + var xpath = {}; + + // Helper function to deal with the migration of Attr to no longer have a nodeName property despite this codebase + // assuming it does. + function getNodeName(nodeOrAttr) { + return nodeOrAttr.constructor.name === 'Attr' ? nodeOrAttr.name : nodeOrAttr.nodeName; + } + + /*************************************************************************** + * Tokenization * + ***************************************************************************/ + /** + * The XPath lexer is basically a single regular expression, along with + * some helper functions to pop different types. + */ + var Stream = xpath.Stream = function Stream(str) { + this.original = this.str = str; + this.peeked = null; + // TODO: not really needed, but supposedly tokenizer also disambiguates + // a * b vs. node test * + this.prev = null; // for debugging + this.prevprev = null; + } + Stream.prototype = { + peek: function() { + if (this.peeked) return this.peeked; + var m = this.re.exec(this.str); + if (!m) return null; + this.str = this.str.substr(m[0].length); + return this.peeked = m[1]; + }, + /** Peek 2 tokens ahead. */ + peek2: function() { + this.peek(); // make sure this.peeked is set + var m = this.re.exec(this.str); + if (!m) return null; + return m[1]; + }, + pop: function() { + var r = this.peek(); + this.peeked = null; + this.prevprev = this.prev; + this.prev = r; + return r; + }, + trypop: function(tokens) { + var tok = this.peek(); + if (tok === tokens) return this.pop(); + if (Array.isArray(tokens)) { + for (var i = 0; i < tokens.length; ++i) { + var t = tokens[i]; + if (t == tok) return this.pop();; + } + } + }, + trypopfuncname: function() { + var tok = this.peek(); + if (!this.isQnameRe.test(tok)) + return null; + switch (tok) { + case 'comment': case 'text': case 'processing-instruction': case 'node': + return null; + } + if ('(' != this.peek2()) return null; + return this.pop(); + }, + trypopaxisname: function() { + var tok = this.peek(); + switch (tok) { + case 'ancestor': case 'ancestor-or-self': case 'attribute': + case 'child': case 'descendant': case 'descendant-or-self': + case 'following': case 'following-sibling': case 'namespace': + case 'parent': case 'preceding': case 'preceding-sibling': case 'self': + if ('::' == this.peek2()) return this.pop(); + } + return null; + }, + trypopnametest: function() { + var tok = this.peek(); + if ('*' === tok || this.startsWithNcNameRe.test(tok)) return this.pop(); + return null; + }, + trypopliteral: function() { + var tok = this.peek(); + if (null == tok) return null; + var first = tok.charAt(0); + var last = tok.charAt(tok.length - 1); + if ('"' === first && '"' === last || + "'" === first && "'" === last) { + this.pop(); + return tok.substr(1, tok.length - 2); + } + }, + trypopnumber: function() { + var tok = this.peek(); + if (this.isNumberRe.test(tok)) return parseFloat(this.pop()); + else return null; + }, + trypopvarref: function() { + var tok = this.peek(); + if (null == tok) return null; + if ('$' === tok.charAt(0)) return this.pop().substr(1); + else return null; + }, + position: function() { + return this.original.length - this.str.length; + } + }; + (function() { + // http://www.w3.org/TR/REC-xml-names/#NT-NCName + var nameStartCharsExceptColon = + 'A-Z_a-z\xc0-\xd6\xd8-\xf6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF' + + '\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF' + + '\uFDF0-\uFFFD'; // JS doesn't support [#x10000-#xEFFFF] + var nameCharExceptColon = nameStartCharsExceptColon + + '\\-\\.0-9\xb7\u0300-\u036F\u203F-\u2040'; + var ncNameChars = '[' + nameStartCharsExceptColon + + '][' + nameCharExceptColon + ']*' + // http://www.w3.org/TR/REC-xml-names/#NT-QName + var qNameChars = ncNameChars + '(?::' + ncNameChars + ')?'; + var otherChars = '\\.\\.|[\\(\\)\\[\\].@,]|::'; // .. must come before [.] + var operatorChars = + 'and|or|mod|div|' + + '//|!=|<=|>=|[*/|+\\-=<>]'; // //, !=, <=, >= before individual ones. + var literal = '"[^"]*"|' + "'[^']*'"; + var numberChars = '[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+'; + var variableReference = '\\$' + qNameChars; + var nameTestChars = '\\*|' + ncNameChars + ':\\*|' + qNameChars; + var optionalSpace = '[ \t\r\n]*'; // stricter than regexp \s. + var nodeType = 'comment|text|processing-instruction|node'; + var re = new RegExp( + // numberChars before otherChars so that leading-decimal doesn't become . + '^' + optionalSpace + '(' + numberChars + '|' + otherChars + '|' + + nameTestChars + '|' + operatorChars + '|' + literal + '|' + + variableReference + ')' + // operatorName | nodeType | functionName | axisName are lumped into + // qName for now; we'll check them on pop. + ); + Stream.prototype.re = re; + Stream.prototype.startsWithNcNameRe = new RegExp('^' + ncNameChars); + Stream.prototype.isQnameRe = new RegExp('^' + qNameChars + '$'); + Stream.prototype.isNumberRe = new RegExp('^' + numberChars + '$'); + })(); + + /*************************************************************************** + * Parsing * + ***************************************************************************/ + var parse = xpath.parse = function parse(stream, a) { + var r = orExpr(stream,a); + var x, unparsed = []; + while (x = stream.pop()) { + unparsed.push(x); + } + if (unparsed.length) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Unparsed tokens: ' + unparsed.join(' ')); + return r; + } + + /** + * binaryL ::= subExpr + * | binaryL op subExpr + * so a op b op c becomes ((a op b) op c) + */ + function binaryL(subExpr, stream, a, ops) { + var lhs = subExpr(stream, a); + if (lhs == null) return null; + var op; + while (op = stream.trypop(ops)) { + var rhs = subExpr(stream, a); + if (rhs == null) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected something after ' + op); + lhs = a.node(op, lhs, rhs); + } + return lhs; + } + /** + * Too bad this is never used. If they made a ** operator (raise to power), + ( we would use it. + * binaryR ::= subExpr + * | subExpr op binaryR + * so a op b op c becomes (a op (b op c)) + */ + function binaryR(subExpr, stream, a, ops) { + var lhs = subExpr(stream, a); + if (lhs == null) return null; + var op = stream.trypop(ops); + if (op) { + var rhs = binaryR(stream, a); + if (rhs == null) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected something after ' + op); + return a.node(op, lhs, rhs); + } else { + return lhs;// TODO + } + } + /** [1] LocationPath::= RelativeLocationPath | AbsoluteLocationPath + * e.g. a, a/b, //a/b + */ + function locationPath(stream, a) { + return absoluteLocationPath(stream, a) || + relativeLocationPath(null, stream, a); + } + /** [2] AbsoluteLocationPath::= '/' RelativeLocationPath? | AbbreviatedAbsoluteLocationPath + * [10] AbbreviatedAbsoluteLocationPath::= '//' RelativeLocationPath + */ + function absoluteLocationPath(stream, a) { + var op = stream.peek(); + if ('/' === op || '//' === op) { + var lhs = a.node('Root'); + return relativeLocationPath(lhs, stream, a, true); + } else { + return null; + } + } + /** [3] RelativeLocationPath::= Step | RelativeLocationPath '/' Step | + * | AbbreviatedRelativeLocationPath + * [11] AbbreviatedRelativeLocationPath::= RelativeLocationPath '//' Step + * e.g. p/a, etc. + */ + function relativeLocationPath(lhs, stream, a, isOnlyRootOk) { + if (null == lhs) { + lhs = step(stream, a); + if (null == lhs) return lhs; + } + var op; + while (op = stream.trypop(['/', '//'])) { + if ('//' === op) { + lhs = a.node('/', lhs, + a.node('Axis', 'descendant-or-self', 'node', undefined)); + } + var rhs = step(stream, a); + if (null == rhs && '/' === op && isOnlyRootOk) return lhs; + else isOnlyRootOk = false; + if (null == rhs) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected step after ' + op); + lhs = a.node('/', lhs, rhs); + } + return lhs; + } + /** [4] Step::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep + * [12] AbbreviatedStep::= '.' | '..' + * e.g. @href, self::p, p, a[@href], ., .. + */ + function step(stream, a) { + var abbrStep = stream.trypop(['.', '..']); + if ('.' === abbrStep) // A location step of . is short for self::node(). + return a.node('Axis', 'self', 'node'); + if ('..' === abbrStep) // A location step of .. is short for parent::node() + return a.node('Axis', 'parent', 'node'); + + var axis = axisSpecifier(stream, a); + var nodeType = nodeTypeTest(stream, a); + var nodeName; + if (null == nodeType) nodeName = nodeNameTest(stream, a); + if (null == axis && null == nodeType && null == nodeName) return null; + if (null == nodeType && null == nodeName) + throw new XPathException( + XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected nodeTest after axisSpecifier ' + axis); + if (null == axis) axis = 'child'; + if (null == nodeType) { + // When there's only a node name, then the node type is forced to be the + // principal node type of the axis. + // see http://www.w3.org/TR/xpath/#dt-principal-node-type + if ('attribute' === axis) nodeType = 'attribute'; + else if ('namespace' === axis) nodeType = 'namespace'; + else nodeType = 'element'; + } + var lhs = a.node('Axis', axis, nodeType, nodeName); + var pred; + while (null != (pred = predicate(lhs, stream, a))) { + lhs = pred; + } + return lhs; + } + /** [5] AxisSpecifier::= AxisName '::' | AbbreviatedAxisSpecifier + * [6] AxisName::= 'ancestor' | 'ancestor-or-self' | 'attribute' | 'child' + * | 'descendant' | 'descendant-or-self' | 'following' + * | 'following-sibling' | 'namespace' | 'parent' | + * | 'preceding' | 'preceding-sibling' | 'self' + * [13] AbbreviatedAxisSpecifier::= '@'? + */ + function axisSpecifier(stream, a) { + var attr = stream.trypop('@'); + if (null != attr) return 'attribute'; + var axisName = stream.trypopaxisname(); + if (null != axisName) { + var coloncolon = stream.trypop('::'); + if (null == coloncolon) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Should not happen. Should be ::.'); + return axisName; + } + } + /** [7] NodeTest::= NameTest | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' + * [38] NodeType::= 'comment' | 'text' | 'processing-instruction' | 'node' + * I've split nodeTypeTest from nodeNameTest for convenience. + */ + function nodeTypeTest(stream, a) { + if ('(' !== stream.peek2()) { + return null; + } + var type = stream.trypop(['comment', 'text', 'processing-instruction', 'node']); + if (null != type) { + if (null == stream.trypop('(')) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Should not happen.'); + var param = undefined; + if (type == 'processing-instruction') { + param = stream.trypopliteral(); + } + if (null == stream.trypop(')')) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected close parens.'); + return type + } + } + function nodeNameTest(stream, a) { + var name = stream.trypopnametest(); + if (name != null) return name; + else return null; + } + /** [8] Predicate::= '[' PredicateExpr ']' + * [9] PredicateExpr::= Expr + */ + function predicate(lhs, stream, a) { + if (null == stream.trypop('[')) return null; + var expr = orExpr(stream, a); + if (null == expr) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected expression after ['); + if (null == stream.trypop(']')) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected ] after expression.'); + return a.node('Predicate', lhs, expr); + } + /** [14] Expr::= OrExpr + */ + /** [15] PrimaryExpr::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall + * e.g. $x, (3+4), "hi", 32, f(x) + */ + function primaryExpr(stream, a) { + var x = stream.trypopliteral(); + if (null == x) + x = stream.trypopnumber(); + if (null != x) { + return x; + } + var varRef = stream.trypopvarref(); + if (null != varRef) return a.node('VariableReference', varRef); + var funCall = functionCall(stream, a); + if (null != funCall) { + return funCall; + } + if (stream.trypop('(')) { + var e = orExpr(stream, a); + if (null == e) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected expression after (.'); + if (null == stream.trypop(')')) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected ) after expression.'); + return e; + } + return null; + } + /** [16] FunctionCall::= FunctionName '(' ( Argument ( ',' Argument )* )? ')' + * [17] Argument::= Expr + */ + function functionCall(stream, a) { + var name = stream.trypopfuncname(stream, a); + if (null == name) return null; + if (null == stream.trypop('(')) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected ( ) after function name.'); + var params = []; + var first = true; + while (null == stream.trypop(')')) { + if (!first && null == stream.trypop(',')) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected , between arguments of the function.'); + first = false; + var param = orExpr(stream, a); + if (param == null) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected expression as argument of function.'); + params.push(param); + } + return a.node('FunctionCall', name, params); + } + + /** [18] UnionExpr::= PathExpr | UnionExpr '|' PathExpr + */ + function unionExpr(stream, a) { return binaryL(pathExpr, stream, a, '|'); } + /** [19] PathExpr ::= LocationPath + * | FilterExpr + * | FilterExpr '/' RelativeLocationPath + * | FilterExpr '//' RelativeLocationPath + * Unlike most other nodes, this one always generates a node because + * at this point all reverse nodesets must turn into a forward nodeset + */ + function pathExpr(stream, a) { + // We have to do FilterExpr before LocationPath because otherwise + // LocationPath will eat up the name from a function call. + var filter = filterExpr(stream, a); + if (null == filter) { + var loc = locationPath(stream, a); + if (null == loc) { + throw new Error + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': The expression shouldn\'t be empty...'); + } + return a.node('PathExpr', loc); + } + var rel = relativeLocationPath(filter, stream, a, false); + if (filter === rel) return rel; + else return a.node('PathExpr', rel); + } + /** [20] FilterExpr::= PrimaryExpr | FilterExpr Predicate + * aka. FilterExpr ::= PrimaryExpr Predicate* + */ + function filterExpr(stream, a) { + var primary = primaryExpr(stream, a); + if (primary == null) return null; + var pred, lhs = primary; + while (null != (pred = predicate(lhs, stream, a))) { + lhs = pred; + } + return lhs; + } + + /** [21] OrExpr::= AndExpr | OrExpr 'or' AndExpr + */ + function orExpr(stream, a) { + var orig = (stream.peeked || '') + stream.str + var r = binaryL(andExpr, stream, a, 'or'); + var now = (stream.peeked || '') + stream.str; + return r; + } + /** [22] AndExpr::= EqualityExpr | AndExpr 'and' EqualityExpr + */ + function andExpr(stream, a) { return binaryL(equalityExpr, stream, a, 'and'); } + /** [23] EqualityExpr::= RelationalExpr | EqualityExpr '=' RelationalExpr + * | EqualityExpr '!=' RelationalExpr + */ + function equalityExpr(stream, a) { return binaryL(relationalExpr, stream, a, ['=','!=']); } + /** [24] RelationalExpr::= AdditiveExpr | RelationalExpr '<' AdditiveExpr + * | RelationalExpr '>' AdditiveExpr + * | RelationalExpr '<=' AdditiveExpr + * | RelationalExpr '>=' AdditiveExpr + */ + function relationalExpr(stream, a) { return binaryL(additiveExpr, stream, a, ['<','>','<=','>=']); } + /** [25] AdditiveExpr::= MultiplicativeExpr + * | AdditiveExpr '+' MultiplicativeExpr + * | AdditiveExpr '-' MultiplicativeExpr + */ + function additiveExpr(stream, a) { return binaryL(multiplicativeExpr, stream, a, ['+','-']); } + /** [26] MultiplicativeExpr::= UnaryExpr + * | MultiplicativeExpr MultiplyOperator UnaryExpr + * | MultiplicativeExpr 'div' UnaryExpr + * | MultiplicativeExpr 'mod' UnaryExpr + */ + function multiplicativeExpr(stream, a) { return binaryL(unaryExpr, stream, a, ['*','div','mod']); } + /** [27] UnaryExpr::= UnionExpr | '-' UnaryExpr + */ + function unaryExpr(stream, a) { + if (stream.trypop('-')) { + var e = unaryExpr(stream, a); + if (null == e) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Expected unary expression after -'); + return a.node('UnaryMinus', e); + } + else return unionExpr(stream, a); + } + var astFactory = { + node: function() {return Array.prototype.slice.call(arguments);} + }; + + + /*************************************************************************** + * Optimizations (TODO) * + ***************************************************************************/ + /** + * Some things I've been considering: + * 1) a//b becomes a/descendant::b if there's no predicate that uses + * position() or last() + * 2) axis[pred]: when pred doesn't use position, evaluate it just once per + * node in the node-set rather than once per (node, position, last). + * For more optimizations, look up Gecko's optimizer: + * http://mxr.mozilla.org/mozilla-central/source/content/xslt/src/xpath/txXPathOptimizer.cpp + */ + // TODO + function optimize(ast) { + } + + /*************************************************************************** + * Evaluation: axes * + ***************************************************************************/ + + /** + * Data types: For string, number, boolean, we just use Javascript types. + * Node-sets have the form + * {nodes: [node, ...]} + * or {nodes: [node, ...], pos: [[1], [2], ...], lasts: [[1], [2], ...]} + * + * Most of the time, only the node is used and the position information is + * discarded. But if you use a predicate, we need to try every value of + * position and last in case the predicate calls position() or last(). + */ + + /** + * The NodeMultiSet is a helper class to help generate + * {nodes:[], pos:[], lasts:[]} structures. It is useful for the + * descendant, descendant-or-self, following-sibling, and + * preceding-sibling axes for which we can use a stack to organize things. + */ + function NodeMultiSet(isReverseAxis) { + this.nodes = []; + this.pos = []; + this.lasts = []; + this.nextPos = []; + this.seriesIndexes = []; // index within nodes that each series begins. + this.isReverseAxis = isReverseAxis; + this._pushToNodes = isReverseAxis ? Array.prototype.unshift : Array.prototype.push; + } + NodeMultiSet.prototype = { + pushSeries: function pushSeries() { + this.nextPos.push(1); + this.seriesIndexes.push(this.nodes.length); + }, + popSeries: function popSeries() { + console.assert(0 < this.nextPos.length, this.nextPos); + var last = this.nextPos.pop() - 1, + indexInPos = this.nextPos.length, + seriesBeginIndex = this.seriesIndexes.pop(), + seriesEndIndex = this.nodes.length; + for (var i = seriesBeginIndex; i < seriesEndIndex; ++i) { + console.assert(indexInPos < this.lasts[i].length); + console.assert(undefined === this.lasts[i][indexInPos]); + this.lasts[i][indexInPos] = last; + } + }, + finalize: function() { + if (null == this.nextPos) return this; + console.assert(0 === this.nextPos.length); + var lastsJSON = JSON.stringify(this.lasts); + for (var i = 0; i < this.lasts.length; ++i) { + for (var j = 0; j < this.lasts[i].length; ++j) { + console.assert(null != this.lasts[i][j], i + ',' + j + ':' + lastsJSON); + } + } + this.pushSeries = this.popSeries = this.addNode = function() { + throw new Error('Already finalized.'); + }; + return this; + }, + addNode: function addNode(node) { + console.assert(node); + this._pushToNodes.call(this.nodes, node) + this._pushToNodes.call(this.pos, this.nextPos.slice()); + this._pushToNodes.call(this.lasts, new Array(this.nextPos.length)); + for (var i = 0; i < this.nextPos.length; ++i) this.nextPos[i]++; + }, + simplify: function() { + this.finalize(); + return {nodes:this.nodes, pos:this.pos, lasts:this.lasts}; + } + }; + function eachContext(nodeMultiSet) { + var r = []; + for (var i = 0; i < nodeMultiSet.nodes.length; i++) { + var node = nodeMultiSet.nodes[i]; + if (!nodeMultiSet.pos) { + r.push({nodes:[node], pos: [[i + 1]], lasts: [[nodeMultiSet.nodes.length]]}); + } else { + for (var j = 0; j < nodeMultiSet.pos[i].length; ++j) { + r.push({nodes:[node], pos: [[nodeMultiSet.pos[i][j]]], lasts: [[nodeMultiSet.lasts[i][j]]]}); + } + } + } + return r; + } + /** Matcher used in the axes. + */ + function NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase) { + this.nodeTypeNum = nodeTypeNum; + this.nodeName = nodeName; + this.shouldLowerCase = shouldLowerCase; + this.nodeNameTest = + null == nodeName ? this._alwaysTrue : + shouldLowerCase ? this._nodeNameLowerCaseEquals : + this._nodeNameEquals; + } + NodeMatcher.prototype = { + matches: function matches(node) { + if (0 === this.nodeTypeNum || this._nodeTypeMatches(node)) { + return this.nodeNameTest(getNodeName(node)); + } + + return false; + }, + _nodeTypeMatches(nodeOrAttr) { + if (nodeOrAttr.constructor.name === 'Attr' && this.nodeTypeNum === 2) { + return true; + } + return nodeOrAttr.nodeType === this.nodeTypeNum; + }, + _alwaysTrue: function(name) {return true;}, + _nodeNameEquals: function _nodeNameEquals(name) { + return this.nodeName === name; + }, + _nodeNameLowerCaseEquals: function _nodeNameLowerCaseEquals(name) { + return this.nodeName === name.toLowerCase(); + } + }; + + function followingSiblingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, shift, peek, followingNode, andSelf, isReverseAxis) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var nodeMultiSet = new NodeMultiSet(isReverseAxis); + while (0 < nodeList.length) { // can be if for following, preceding + var node = shift.call(nodeList); + console.assert(node != null); + node = followingNode(node); + nodeMultiSet.pushSeries(); + var numPushed = 1; + while (null != node) { + if (! andSelf && matcher.matches(node)) + nodeMultiSet.addNode(node); + if (node === peek.call(nodeList)) { + shift.call(nodeList); + nodeMultiSet.pushSeries(); + numPushed++; + } + if (andSelf && matcher.matches(node)) + nodeMultiSet.addNode(node); + node = followingNode(node); + } + while (0 < numPushed--) + nodeMultiSet.popSeries(); + } + return nodeMultiSet; + } + + /** Returns the next non-descendant node in document order. + * This is the first node in following::node(), if node is the context. + */ + function followingNonDescendantNode(node) { + if (node.ownerElement) { + if (node.ownerElement.firstChild) + return node.ownerElement.firstChild; + node = node.ownerElement; + } + do { + if (node.nextSibling) return node.nextSibling; + } while (node = node.parentNode); + return null; + } + + /** Returns the next node in a document-order depth-first search. + * See the definition of document order[1]: + * 1) element + * 2) namespace nodes + * 3) attributes + * 4) children + * [1]: http://www.w3.org/TR/xpath/#dt-document-order + */ + function followingNode(node) { + if (node.ownerElement) // attributes: following node of element. + node = node.ownerElement; + if (null != node.firstChild) + return node.firstChild; + do { + if (null != node.nextSibling) { + return node.nextSibling; + } + node = node.parentNode; + } while (node); + return null; + } + /** Returns the previous node in document order (excluding attributes + * and namespace nodes). + */ + function precedingNode(node) { + if (node.ownerElement) + return node.ownerElement; + if (null != node.previousSibling) { + node = node.previousSibling; + while (null != node.lastChild) { + node = node.lastChild; + } + return node; + } + if (null != node.parentNode) { + return node.parentNode; + } + return null; + } + /** This axis is inefficient if there are many nodes in the nodeList. + * But I think it's a pretty useless axis so it's ok. */ + function followingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var nodeMultiSet = new NodeMultiSet(false); + var cursor = nodeList[0]; + var unorderedFollowingStarts = []; + for (var i = 0; i < nodeList.length; i++) { + var node = nodeList[i]; + var start = followingNonDescendantNode(node); + if (start) + unorderedFollowingStarts.push(start); + } + if (0 === unorderedFollowingStarts.length) + return {nodes:[]}; + var pos = [], nextPos = []; + var started = 0; + while (cursor = followingNode(cursor)) { + for (var i = unorderedFollowingStarts.length - 1; i >= 0; i--){ + if (cursor === unorderedFollowingStarts[i]) { + nodeMultiSet.pushSeries(); + unorderedFollowingStarts.splice(i,i+1); + started++; + } + } + if (started && matcher.matches(cursor)) { + nodeMultiSet.addNode(cursor); + } + } + console.assert(0 === unorderedFollowingStarts.length); + for (var i = 0; i < started; i++) + nodeMultiSet.popSeries(); + return nodeMultiSet.finalize(); + } + function precedingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var cursor = nodeList.pop(); + if (null == cursor) return {nodes:{}}; + var r = {nodes:[], pos:[], lasts:[]}; + var nextParents = [cursor.parentNode || cursor.ownerElement], nextPos = [1]; + while (cursor = precedingNode(cursor)) { + if (cursor === nodeList[nodeList.length - 1]) { + nextParents.push(nodeList.pop()); + nextPos.push(1); + } + var matches = matcher.matches(cursor); + var pos, someoneUsed = false; + if (matches) + pos = nextPos.slice(); + + for (var i = 0; i < nextParents.length; ++i) { + if (cursor === nextParents[i]) { + nextParents[i] = cursor.parentNode || cursor.ownerElement; + if (matches) { + pos[i] = null; + } + } else { + if (matches) { + pos[i] = nextPos[i]++; + someoneUsed = true; + } + } + } + if (someoneUsed) { + r.nodes.unshift(cursor); + r.pos.unshift(pos); + } + } + for (var i = 0; i < r.pos.length; ++i) { + var lasts = []; + r.lasts.push(lasts); + for (var j = r.pos[i].length - 1; j >= 0; j--) { + if (null == r.pos[i][j]) { + r.pos[i].splice(j, j+1); + } else { + lasts.unshift(nextPos[j] - 1); + } + } + } + return r; + } + + /** node-set, axis -> node-set */ + function descendantDfs(nodeMultiSet, node, remaining, matcher, andSelf, attrIndices, attrNodes) { + while (0 < remaining.length && null != remaining[0].ownerElement) { + var attr = remaining.shift(); + if (andSelf && matcher.matches(attr)) { + attrNodes.push(attr); + attrIndices.push(nodeMultiSet.nodes.length); + } + } + if (null != node && !andSelf) { + if (matcher.matches(node)) + nodeMultiSet.addNode(node); + } + var pushed = false; + if (null == node) { + if (0 === remaining.length) return; + node = remaining.shift(); + nodeMultiSet.pushSeries(); + pushed = true; + } else if (0 < remaining.length && node === remaining[0]) { + nodeMultiSet.pushSeries(); + pushed = true; + remaining.shift(); + } + if (andSelf) { + if (matcher.matches(node)) + nodeMultiSet.addNode(node); + } + // TODO: use optimization. Also try element.getElementsByTagName + // var nodeList = 1 === nodeTypeNum && null != node.children ? node.children : node.childNodes; + var nodeList = node.childNodes; + for (var j = 0; j < nodeList.length; ++j) { + var child = nodeList[j]; + descendantDfs(nodeMultiSet, child, remaining, matcher, andSelf, attrIndices, attrNodes); + } + if (pushed) { + nodeMultiSet.popSeries(); + } + } + function descenantHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, andSelf) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var nodeMultiSet = new NodeMultiSet(false); + var attrIndices = [], attrNodes = []; + while (0 < nodeList.length) { + // var node = nodeList.shift(); + descendantDfs(nodeMultiSet, null, nodeList, matcher, andSelf, attrIndices, attrNodes); + } + nodeMultiSet.finalize(); + for (var i = attrNodes.length-1; i >= 0; --i) { + nodeMultiSet.nodes.splice(attrIndices[i], attrIndices[i], attrNodes[i]); + nodeMultiSet.pos.splice(attrIndices[i], attrIndices[i], [1]); + nodeMultiSet.lasts.splice(attrIndices[i], attrIndices[i], [1]); + } + return nodeMultiSet; + } + /** + */ + function ancestorHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, andSelf) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var ancestors = []; // array of non-empty arrays of matching ancestors + for (var i = 0; i < nodeList.length; ++i) { + var node = nodeList[i]; + var isFirst = true; + var a = []; + while (null != node) { + if (!isFirst || andSelf) { + if (matcher.matches(node)) + a.push(node); + } + isFirst = false; + node = node.parentNode || node.ownerElement; + } + if (0 < a.length) + ancestors.push(a); + } + var lasts = []; + for (var i = 0; i < ancestors.length; ++i) lasts.push(ancestors[i].length); + var nodeMultiSet = new NodeMultiSet(true); + var newCtx = {nodes:[], pos:[], lasts:[]}; + while (0 < ancestors.length) { + var pos = [ancestors[0].length]; + var last = [lasts[0]]; + var node = ancestors[0].pop(); + for (var i = ancestors.length - 1; i > 0; --i) { + if (node === ancestors[i][ancestors[i].length - 1]) { + pos.push(ancestors[i].length); + last.push(lasts[i]); + ancestors[i].pop(); + if (0 === ancestors[i].length) { + ancestors.splice(i, i+1); + lasts.splice(i, i+1); + } + } + } + if (0 === ancestors[0].length) { + ancestors.shift(); + lasts.shift(); + } + newCtx.nodes.push(node); + newCtx.pos.push(pos); + newCtx.lasts.push(last); + } + return newCtx; + } + /** Helper function for sortDocumentOrder. Returns a list of indices, from the + * node to the root, of positions within parent. + * For convenience, the node is the first element of the array. + */ + function addressVector(node) { + var r = [node]; + if (null != node.ownerElement) { + node = node.ownerElement; + r.push(-1); + } + while (null != node) { + var i = 0; + while (null != node.previousSibling) { + node = node.previousSibling; + i++; + } + r.push(i); + node = node.parentNode + } + return r; + } + function addressComparator(a, b) { + var minlen = Math.min(a.length - 1, b.length - 1), // not including [0]=node + alen = a.length, + blen = b.length; + if (a[0] === b[0]) return 0; + var c; + for (var i = 0; i < minlen; ++i) { + c = a[alen - i - 1] - b[blen - i - 1]; + if (0 !== c) + break; + } + if (null == c || 0 === c) { + // All equal until one of the nodes. The longer one is the descendant. + c = alen - blen; + } + if (0 === c) + c = getNodeName(a) - getNodeName(b); + if (0 === c) + c = 1; + return c; + } + var sortUniqDocumentOrder = xpath.sortUniqDocumentOrder = function(nodes) { + var a = []; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var v = addressVector(node); + a.push(v); + } + a.sort(addressComparator); + var b = []; + for (var i = 0; i < a.length; i++) { + if (0 < i && a[i][0] === a[i - 1][0]) + continue; + b.push(a[i][0]); + } + return b; + } + /** Sort node multiset. Does not do any de-duping. */ + function sortNodeMultiSet(nodeMultiSet) { + var a = []; + for (var i = 0; i < nodeMultiSet.nodes.length; i++) { + var v = addressVector(nodeMultiSet.nodes[i]); + a.push({v:v, n:nodeMultiSet.nodes[i], + p:nodeMultiSet.pos[i], l:nodeMultiSet.lasts[i]}); + } + a.sort(compare); + var r = {nodes:[], pos:[], lasts:[]}; + for (var i = 0; i < a.length; ++i) { + r.nodes.push(a[i].n); + r.pos.push(a[i].p); + r.lasts.push(a[i].l); + } + function compare(x, y) { + return addressComparator(x.v, y.v); + } + return r; + } + /** Returns an array containing all the ancestors down to a node. + * The array starts with document. + */ + function nodeAndAncestors(node) { + var ancestors = [node]; + var p = node; + while (p = p.parentNode || p.ownerElement) { + ancestors.unshift(p); + } + return ancestors; + } + function compareSiblings(a, b) { + if (a === b) return 0; + var c = a; + while (c = c.previousSibling) { + if (c === b) + return 1; // b < a + } + c = b; + while (c = c.previousSibling) { + if (c === a) + return -1; // a < b + } + throw new Error('a and b are not siblings: ' + xpath.stringifyObject(a) + ' vs ' + xpath.stringifyObject(b)); + } + /** The merge in merge-sort.*/ + function mergeNodeLists(x, y) { + var a, b, aanc, banc, r = []; + if ('object' !== typeof x) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Invalid LHS for | operator ' + + '(expected node-set): ' + x); + if ('object' !== typeof y) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Invalid LHS for | operator ' + + '(expected node-set): ' + y); + while (true) { + if (null == a) { + a = x.shift(); + if (null != a) + aanc = addressVector(a); + } + if (null == b) { + b = y.shift(); + if (null != b) + banc = addressVector(b); + } + if (null == a || null == b) break; + var c = addressComparator(aanc, banc); + if (c < 0) { + r.push(a); + a = null; + aanc = null; + } else if (c > 0) { + r.push(b); + b = null; + banc = null; + } else if (getNodeName(a) < getNodeName(b)) { // attributes + r.push(a); + a = null; + aanc = null; + } else if (getNodeName(a) > getNodeName(b)) { // attributes + r.push(b); + b = null; + banc = null; + } else if (a !== b) { + // choose b arbitrarily + r.push(b); + b = null; + banc = null; + } else { + console.assert(a === b, c); + // just skip b without pushing it. + b = null; + banc = null; + } + } + while (a) { + r.push(a); + a = x.shift(); + } + while (b) { + r.push(b); + b = y.shift(); + } + return r; + } + function comparisonHelper(test, x, y, isNumericComparison) { + var coersion; + if (isNumericComparison) + coersion = fn.number; + else coersion = + 'boolean' === typeof x || 'boolean' === typeof y ? fn['boolean'] : + 'number' === typeof x || 'number' === typeof y ? fn.number : + fn.string; + if ('object' === typeof x && 'object' === typeof y) { + var aMap = {}; + for (var i = 0; i < x.nodes.length; ++i) { + var xi = coersion({nodes:[x.nodes[i]]}); + for (var j = 0; j < y.nodes.length; ++j) { + var yj = coersion({nodes:[y.nodes[j]]}); + if (test(xi, yj)) return true; + } + } + return false; + } else if ('object' === typeof x && x.nodes && x.nodes.length) { + for (var i = 0; i < x.nodes.length; ++i) { + var xi = coersion({nodes:[x.nodes[i]]}), yc = coersion(y); + if (test(xi, yc)) + return true; + } + return false; + } else if ('object' === typeof y && x.nodes && x.nodes.length) { + for (var i = 0; i < x.nodes.length; ++i) { + var yi = coersion({nodes:[y.nodes[i]]}), xc = coersion(x); + if (test(xc, yi)) + return true; + } + return false; + } else { + var xc = coersion(x), yc = coersion(y); + return test(xc, yc); + } + } + var axes = xpath.axes = { + 'ancestor': + function ancestor(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return ancestorHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, false); + }, + 'ancestor-or-self': + function ancestorOrSelf(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return ancestorHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, true); + }, + 'attribute': + function attribute(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + // TODO: figure out whether positions should be undefined here. + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var nodeMultiSet = new NodeMultiSet(false); + if (null != nodeName) { + // TODO: with namespace + for (var i = 0; i < nodeList.length; ++i) { + var node = nodeList[i]; + if (null == node.getAttributeNode) + continue; // only Element has .getAttributeNode + var attr = node.getAttributeNode(nodeName); + if (null != attr && matcher.matches(attr)) { + nodeMultiSet.pushSeries(); + nodeMultiSet.addNode(attr); + nodeMultiSet.popSeries(); + } + } + } else { + for (var i = 0; i < nodeList.length; ++i) { + var node = nodeList[i]; + if (null != node.attributes) { + nodeMultiSet.pushSeries(); + for (var j = 0; j < node.attributes.length; j++) { // all nodes have .attributes + var attr = node.attributes[j]; + if (matcher.matches(attr)) // TODO: I think this check is unnecessary + nodeMultiSet.addNode(attr); + } + nodeMultiSet.popSeries(); + } + } + } + return nodeMultiSet.finalize(); + }, + 'child': + function child(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var nodeMultiSet = new NodeMultiSet(false); + for (var i = 0; i < nodeList.length; ++i) { + var n = nodeList[i]; + if (n.ownerElement) // skip attribute nodes' text child. + continue; + if (n.childNodes) { + nodeMultiSet.pushSeries(); + var childList = 1 === nodeTypeNum && null != n.children ? + n.children : n.childNodes; + for (var j = 0; j < childList.length; ++j) { + var child = childList[j]; + if (matcher.matches(child)) { + nodeMultiSet.addNode(child); + } + // don't have to do de-duping because children have parent, + // which are current context. + } + nodeMultiSet.popSeries(); + } + } + nodeMultiSet.finalize(); + return sortNodeMultiSet(nodeMultiSet); + }, + 'descendant': + function descenant(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return descenantHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, false); + }, + 'descendant-or-self': + function descenantOrSelf(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return descenantHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, true); + }, + 'following': + function following(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return followingHelper(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase); + }, + 'following-sibling': + function followingSibling(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return followingSiblingHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, + Array.prototype.shift, function() {return this[0];}, + function(node) {return node.nextSibling;}); + }, + 'namespace': + function namespace(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + // TODO + }, + 'parent': + function parent(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + var nodes = [], pos = []; + for (var i = 0; i < nodeList.length; ++i) { + var parent = nodeList[i].parentNode || nodeList[i].ownerElement; + if (null == parent) + continue; + if (!matcher.matches(parent)) + continue; + if (nodes.length > 0 && parent === nodes[nodes.length-1]) + continue; + nodes.push(parent); + pos.push([1]); + } + return {nodes:nodes, pos:pos, lasts:pos}; + }, + 'preceding': + function preceding(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return precedingHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase); + }, + 'preceding-sibling': + function precedingSibling(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + return followingSiblingHelper( + nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase, + Array.prototype.pop, function() {return this[this.length-1];}, + function(node) {return node.previousSibling}, + false, true); + }, + 'self': + function self(nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase) { + var nodes = [], pos = []; + var matcher = new NodeMatcher(nodeTypeNum, nodeName, shouldLowerCase); + for (var i = 0; i < nodeList.length; ++i) { + if (matcher.matches(nodeList[i])) { + nodes.push(nodeList[i]); + pos.push([1]); + } + } + return {nodes: nodes, pos: pos, lasts: pos} + } + }; + + /*************************************************************************** + * Evaluation: functions * + ***************************************************************************/ + var fn = { + 'number': function number(optObject) { + if ('number' === typeof optObject) + return optObject; + if ('string' === typeof optObject) + return parseFloat(optObject); // note: parseFloat(' ') -> NaN, unlike +' ' -> 0. + if ('boolean' === typeof optObject) + return +optObject; + return fn.number(fn.string.call(this, optObject)); // for node-sets + }, + 'string': function string(optObject) { + if (null == optObject) + return fn.string(this); + if ('string' === typeof optObject || 'boolean' === typeof optObject || + 'number' === typeof optObject) + return '' + optObject; + if (0 == optObject.nodes.length) return ''; + if (null != optObject.nodes[0].textContent) + return optObject.nodes[0].textContent; + return optObject.nodes[0].nodeValue; + }, + 'boolean': function booleanVal(x) { + return 'object' === typeof x ? x.nodes.length > 0 : !!x; + }, + 'last': function last() { + console.assert(Array.isArray(this.pos)); + console.assert(Array.isArray(this.lasts)); + console.assert(1 === this.pos.length); + console.assert(1 === this.lasts.length); + console.assert(1 === this.lasts[0].length); + return this.lasts[0][0]; + }, + 'position': function position() { + console.assert(Array.isArray(this.pos)); + console.assert(Array.isArray(this.lasts)); + console.assert(1 === this.pos.length); + console.assert(1 === this.lasts.length); + console.assert(1 === this.pos[0].length); + return this.pos[0][0]; + }, + 'count': function count(nodeSet) { + if ('object' !== typeof nodeSet) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Position ' + stream.position() + + ': Function count(node-set) ' + + 'got wrong argument type: ' + nodeSet); + return nodeSet.nodes.length; + }, + 'id': function id(object) { + var r = {nodes: []}; + var doc = this.nodes[0].ownerDocument || this.nodes[0]; + console.assert(doc); + var ids; + if ('object' === typeof object) { + // for node-sets, map id over each node value. + ids = []; + for (var i = 0; i < object.nodes.length; ++i) { + var idNode = object.nodes[i]; + var idsString = fn.string({nodes:[idNode]}); + var a = idsString.split(/[ \t\r\n]+/g); + Array.prototype.push.apply(ids, a); + } + } else { + var idsString = fn.string(object); + var a = idsString.split(/[ \t\r\n]+/g); + ids = a; + } + for (var i = 0; i < ids.length; ++i) { + var id = ids[i]; + if (0 === id.length) + continue; + var node = doc.getElementById(id); + if (null != node) + r.nodes.push(node); + } + r.nodes = sortUniqDocumentOrder(r.nodes); + return r; + }, + 'local-name': function(nodeSet) { + if (null == nodeSet) + return fn.name(this); + if (null == nodeSet.nodes) { + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'argument to name() must be a node-set. got ' + nodeSet); + } + // TODO: namespaced version + return nodeSet.nodes[0].localName; + }, + 'namespace-uri': function(nodeSet) { + // TODO + throw new Error('not implemented yet'); + }, + 'name': function(nodeSet) { + if (null == nodeSet) + return fn.name(this); + if (null == nodeSet.nodes) { + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'argument to name() must be a node-set. got ' + nodeSet); + } + return nodeSet.nodes[0].name; + }, + 'concat': function concat(x) { + var l = []; + for (var i = 0; i < arguments.length; ++i) { + l.push(fn.string(arguments[i])); + } + return l.join(''); + }, + 'starts-with': function startsWith(a, b) { + var as = fn.string(a), bs = fn.string(b); + return as.substr(0, bs.length) === bs; + }, + 'contains': function contains(a, b) { + var as = fn.string(a), bs = fn.string(b); + var i = as.indexOf(bs); + if (-1 === i) return false; + return true; + }, + 'substring-before': function substringBefore(a, b) { + var as = fn.string(a), bs = fn.string(b); + var i = as.indexOf(bs); + if (-1 === i) return ''; + return as.substr(0, i); + }, + 'substring-after': function substringBefore(a, b) { + var as = fn.string(a), bs = fn.string(b); + var i = as.indexOf(bs); + if (-1 === i) return ''; + return as.substr(i + bs.length); + }, + 'substring': function substring(string, start, optEnd) { + if (null == string || null == start) { + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Must be at least 2 arguments to string()'); + } + var sString = fn.string(string), + iStart = fn.round(start), + iEnd = optEnd == null ? null : fn.round(optEnd); + // Note that xpath string positions user 1-based index + if (iEnd == null) + return sString.substr(iStart - 1); + else + return sString.substr(iStart - 1, iEnd); + }, + 'string-length': function stringLength(optString) { + return fn.string.call(this, optString).length; + }, + 'normalize-space': function normalizeSpace(optString) { + var s = fn.string.call(this, optString); + return s.replace(/[ \t\r\n]+/g, ' ').replace(/^ | $/g, ''); + }, + 'translate': function translate(string, from, to) { + var sString = fn.string.call(this, string), + sFrom = fn.string(from), + sTo = fn.string(to); + var eachCharRe = []; + var map = {}; + for (var i = 0; i < sFrom.length; ++i) { + var c = sFrom.charAt(i); + map[c] = sTo.charAt(i); // returns '' if beyond length of sTo. + // copied from goog.string.regExpEscape in the Closure library. + eachCharRe.push( + c.replace(/([-()\[\]{}+?*.$\^|,:#': function(x, y) { + return comparisonHelper(function(x, y) { return fn.number(x) > fn.number(y);}, x, y, true); + }, + '>=': function(x, y) { + return comparisonHelper(function(x, y) { return fn.number(x) >= fn.number(y);}, x, y, true); + }, + 'and': function(x, y) { return fn['boolean'](x) && fn['boolean'](y); }, + 'or': function(x, y) { return fn['boolean'](x) || fn['boolean'](y); }, + '|': function(x, y) { return {nodes: mergeNodeLists(x.nodes, y.nodes)}; }, + '=': function(x, y) { + // optimization for two node-sets case: avoid n^2 comparisons. + if ('object' === typeof x && 'object' === typeof y) { + var aMap = {}; + for (var i = 0; i < x.nodes.length; ++i) { + var s = fn.string({nodes:[x.nodes[i]]}); + aMap[s] = true; + } + for (var i = 0; i < y.nodes.length; ++i) { + var s = fn.string({nodes:[y.nodes[i]]}); + if (aMap[s]) return true; + } + return false; + } else { + return comparisonHelper(function(x, y) {return x === y;}, x, y); + } + }, + '!=': function(x, y) { + // optimization for two node-sets case: avoid n^2 comparisons. + if ('object' === typeof x && 'object' === typeof y) { + if (0 === x.nodes.length || 0 === y.nodes.length) return false; + var aMap = {}; + for (var i = 0; i < x.nodes.length; ++i) { + var s = fn.string({nodes:[x.nodes[i]]}); + aMap[s] = true; + } + for (var i = 0; i < y.nodes.length; ++i) { + var s = fn.string({nodes:[y.nodes[i]]}); + if (!aMap[s]) return true; + } + return false; + } else { + return comparisonHelper(function(x, y) {return x !== y;}, x, y); + } + } + }; + var nodeTypes = xpath.nodeTypes = { + 'node': 0, + 'attribute': 2, + 'comment': 8, // this.doc.COMMENT_NODE, + 'text': 3, // this.doc.TEXT_NODE, + 'processing-instruction': 7, // this.doc.PROCESSING_INSTRUCTION_NODE, + 'element': 1 //this.doc.ELEMENT_NODE + }; + /** For debugging and unit tests: returnjs a stringified version of the + * argument. */ + var stringifyObject = xpath.stringifyObject = function stringifyObject(ctx) { + var seenKey = 'seen' + Math.floor(Math.random()*1000000000); + return JSON.stringify(helper(ctx)); + + function helper(ctx) { + if (Array.isArray(ctx)) { + return ctx.map(function(x) {return helper(x);}); + } + if ('object' !== typeof ctx) return ctx; + if (null == ctx) return ctx; + // if (ctx.toString) return ctx.toString(); + if (null != ctx.outerHTML) return ctx.outerHTML; + if (null != ctx.nodeValue) return ctx.nodeName + '=' + ctx.nodeValue; + if (ctx[seenKey]) return '[circular]'; + ctx[seenKey] = true; + var nicer = {}; + for (var key in ctx) { + if (seenKey === key) + continue; + try { + nicer[key] = helper(ctx[key]); + } catch (e) { + nicer[key] = '[exception: ' + e.message + ']'; + } + } + delete ctx[seenKey]; + return nicer; + } + } + var Evaluator = xpath.Evaluator = function Evaluator(doc) { + this.doc = doc; + } + Evaluator.prototype = { + val: function val(ast, ctx) { + console.assert(ctx.nodes); + + if ('number' === typeof ast || 'string' === typeof ast) return ast; + if (more[ast[0]]) { + var evaluatedParams = []; + for (var i = 1; i < ast.length; ++i) { + evaluatedParams.push(this.val(ast[i], ctx)); + } + var r = more[ast[0]].apply(ctx, evaluatedParams); + return r; + } + switch (ast[0]) { + case 'Root': return {nodes: [this.doc]}; + case 'FunctionCall': + var functionName = ast[1], functionParams = ast[2]; + if (null == fn[functionName]) + throw new XPathException(XPathException.INVALID_EXPRESSION_ERR, + 'Unknown function: ' + functionName); + var evaluatedParams = []; + for (var i = 0; i < functionParams.length; ++i) { + evaluatedParams.push(this.val(functionParams[i], ctx)); + } + var r = fn[functionName].apply(ctx, evaluatedParams); + return r; + case 'Predicate': + var lhs = this.val(ast[1], ctx); + var ret = {nodes: []}; + var contexts = eachContext(lhs); + for (var i = 0; i < contexts.length; ++i) { + var singleNodeSet = contexts[i]; + var rhs = this.val(ast[2], singleNodeSet); + var success; + if ('number' === typeof rhs) { + success = rhs === singleNodeSet.pos[0][0]; + } else { + success = fn['boolean'](rhs); + } + if (success) { + var node = singleNodeSet.nodes[0]; + ret.nodes.push(node); + // skip over all the rest of the same node. + while (i+1 < contexts.length && node === contexts[i+1].nodes[0]) { + i++; + } + } + } + return ret; + case 'PathExpr': + // turn the path into an expressoin; i.e., remove the position + // information of the last axis. + var x = this.val(ast[1], ctx); + // Make the nodeset a forward-direction-only one. + if (x.finalize) { // it is a NodeMultiSet + return {nodes: x.nodes}; + } else { + return x; + } + case '/': + // TODO: don't generate '/' nodes, just Axis nodes. + var lhs = this.val(ast[1], ctx); + console.assert(null != lhs); + var r = this.val(ast[2], lhs); + console.assert(null != r); + return r; + case 'Axis': + // All the axis tests from Step. We only get AxisSpecifier NodeTest, + // not the predicate (which is applied later) + var axis = ast[1], + nodeType = ast[2], + nodeTypeNum = nodeTypes[nodeType], + shouldLowerCase = true, // TODO: give option + nodeName = ast[3] && shouldLowerCase ? ast[3].toLowerCase() : ast[3]; + nodeName = nodeName === '*' ? null : nodeName; + if ('object' !== typeof ctx) return {nodes:[], pos:[]}; + var nodeList = ctx.nodes.slice(); // TODO: is copy needed? + var r = axes[axis](nodeList /*destructive!*/, nodeTypeNum, nodeName, shouldLowerCase); + return r; + } + } + }; + var evaluate = xpath.evaluate = function evaluate(expr, doc, context) { + //var astFactory = new AstEvaluatorFactory(doc, context); + var stream = new Stream(expr); + var ast = parse(stream, astFactory); + var val = new Evaluator(doc).val(ast, {nodes: [context]}); + return val; + } + + /*************************************************************************** + * DOM interface * + ***************************************************************************/ + var XPathException = xpath.XPathException = function XPathException(code, message) { + var e = new Error(message); + e.name = 'XPathException'; + e.code = code; + return e; + } + XPathException.INVALID_EXPRESSION_ERR = 51; + XPathException.TYPE_ERR = 52; + + + var XPathEvaluator = xpath.XPathEvaluator = function XPathEvaluator() {} + XPathEvaluator.prototype = { + createExpression: function(expression, resolver) { + return new XPathExpression(expression, resolver); + }, + createNSResolver: function(nodeResolver) { + // TODO + }, + evaluate: function evaluate(expression, contextNode, resolver, type, result) { + var expr = new XPathExpression(expression, resolver); + return expr.evaluate(contextNode, type, result); + } + }; + + + var XPathExpression = xpath.XPathExpression = function XPathExpression(expression, resolver, optDoc) { + var stream = new Stream(expression); + this._ast = parse(stream, astFactory); + this._doc = optDoc; + } + XPathExpression.prototype = { + evaluate: function evaluate(contextNode, type, result) { + if (null == contextNode.nodeType) + throw new Error('bad argument (expected context node): ' + contextNode); + var doc = contextNode.ownerDocument || contextNode; + if (null != this._doc && this._doc !== doc) { + throw new core.DOMException( + core.DOMException.WRONG_DOCUMENT_ERR, + 'The document must be the same as the context node\'s document.'); + } + var evaluator = new Evaluator(doc); + var value = evaluator.val(this._ast, {nodes: [contextNode]}); + if (XPathResult.NUMBER_TYPE === type) + value = fn.number(value); + else if (XPathResult.STRING_TYPE === type) + value = fn.string(value); + else if (XPathResult.BOOLEAN_TYPE === type) + value = fn['boolean'](value); + else if (XPathResult.ANY_TYPE !== type && + XPathResult.UNORDERED_NODE_ITERATOR_TYPE !== type && + XPathResult.ORDERED_NODE_ITERATOR_TYPE !== type && + XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE !== type && + XPathResult.ORDERED_NODE_SNAPSHOT_TYPE !== type && + XPathResult.ANY_UNORDERED_NODE_TYPE !== type && + XPathResult.FIRST_ORDERED_NODE_TYPE !== type) + throw new core.DOMException( + core.DOMException.NOT_SUPPORTED_ERR, + 'You must provide an XPath result type (0=any).'); + else if (XPathResult.ANY_TYPE !== type && + 'object' !== typeof value) + throw new XPathException( + XPathException.TYPE_ERR, + 'Value should be a node-set: ' + value); + return new XPathResult(doc, value, type); + } + } + + var XPathResult = xpath.XPathResult = function XPathResult(doc, value, resultType) { + this._value = value; + this._resultType = resultType; + this._i = 0; + + // TODO: we removed mutation events but didn't take care of this. No tests fail, so that's nice, but eventually we + // should fix this, preferably by entirely replacing our XPath implementation. + // this._invalidated = false; + // if (this.resultType === XPathResult.UNORDERED_NODE_ITERATOR_TYPE || + // this.resultType === XPathResult.ORDERED_NODE_ITERATOR_TYPE) { + // doc.addEventListener('DOMSubtreeModified', invalidate, true); + // var self = this; + // function invalidate() { + // self._invalidated = true; + // doc.removeEventListener('DOMSubtreeModified', invalidate, true); + // } + // } + } + XPathResult.ANY_TYPE = 0; + XPathResult.NUMBER_TYPE = 1; + XPathResult.STRING_TYPE = 2; + XPathResult.BOOLEAN_TYPE = 3; + XPathResult.UNORDERED_NODE_ITERATOR_TYPE = 4; + XPathResult.ORDERED_NODE_ITERATOR_TYPE = 5; + XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE = 6; + XPathResult.ORDERED_NODE_SNAPSHOT_TYPE = 7; + XPathResult.ANY_UNORDERED_NODE_TYPE = 8; + XPathResult.FIRST_ORDERED_NODE_TYPE = 9; + var proto = { + // XPathResultType + get resultType() { + if (this._resultType) return this._resultType; + switch (typeof this._value) { + case 'number': return XPathResult.NUMBER_TYPE; + case 'string': return XPathResult.STRING_TYPE; + case 'boolean': return XPathResult.BOOLEAN_TYPE; + default: return XPathResult.UNORDERED_NODE_ITERATOR_TYPE; + } + }, + get numberValue() { + if (XPathResult.NUMBER_TYPE !== this.resultType) + throw new XPathException(XPathException.TYPE_ERR, + 'You should have asked for a NUMBER_TYPE.'); + return this._value; + }, + get stringValue() { + if (XPathResult.STRING_TYPE !== this.resultType) + throw new XPathException(XPathException.TYPE_ERR, + 'You should have asked for a STRING_TYPE.'); + return this._value; + }, + get booleanValue() { + if (XPathResult.BOOLEAN_TYPE !== this.resultType) + throw new XPathException(XPathException.TYPE_ERR, + 'You should have asked for a BOOLEAN_TYPE.'); + return this._value; + }, + get singleNodeValue() { + if (XPathResult.ANY_UNORDERED_NODE_TYPE !== this.resultType && + XPathResult.FIRST_ORDERED_NODE_TYPE !== this.resultType) + throw new XPathException( + XPathException.TYPE_ERR, + 'You should have asked for a FIRST_ORDERED_NODE_TYPE.'); + return this._value.nodes[0] || null; + }, + get invalidIteratorState() { + if (XPathResult.UNORDERED_NODE_ITERATOR_TYPE !== this.resultType && + XPathResult.ORDERED_NODE_ITERATOR_TYPE !== this.resultType) + return false; + return !!this._invalidated; + }, + get snapshotLength() { + if (XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE !== this.resultType && + XPathResult.ORDERED_NODE_SNAPSHOT_TYPE !== this.resultType) + throw new XPathException( + XPathException.TYPE_ERR, + 'You should have asked for a ORDERED_NODE_SNAPSHOT_TYPE.'); + return this._value.nodes.length; + }, + iterateNext: function iterateNext() { + if (XPathResult.UNORDERED_NODE_ITERATOR_TYPE !== this.resultType && + XPathResult.ORDERED_NODE_ITERATOR_TYPE !== this.resultType) + throw new XPathException( + XPathException.TYPE_ERR, + 'You should have asked for a ORDERED_NODE_ITERATOR_TYPE.'); + if (this.invalidIteratorState) + throw new core.DOMException( + core.DOMException.INVALID_STATE_ERR, + 'The document has been mutated since the result was returned'); + return this._value.nodes[this._i++] || null; + }, + snapshotItem: function snapshotItem(index) { + if (XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE !== this.resultType && + XPathResult.ORDERED_NODE_SNAPSHOT_TYPE !== this.resultType) + throw new XPathException( + XPathException.TYPE_ERR, + 'You should have asked for a ORDERED_NODE_SNAPSHOT_TYPE.'); + return this._value.nodes[index] || null; + } + }; + // so you can access ANY_TYPE etc. from the instances: + XPathResult.prototype = Object.create(XPathResult, + Object.keys(proto).reduce(function (descriptors, name) { + descriptors[name] = Object.getOwnPropertyDescriptor(proto, name); + return descriptors; + }, { + constructor: { + value: XPathResult, + writable: true, + configurable: true + } + })); + + core.XPathException = XPathException; + core.XPathExpression = XPathExpression; + core.XPathResult = XPathResult; + core.XPathEvaluator = XPathEvaluator; + + core.Document.prototype.createExpression = + XPathEvaluator.prototype.createExpression; + + core.Document.prototype.createNSResolver = + XPathEvaluator.prototype.createNSResolver; + + core.Document.prototype.evaluate = XPathEvaluator.prototype.evaluate; + + return xpath; // for tests +}; diff --git a/node_modules/jsdom/lib/jsdom/living/aborting/AbortController-impl.js b/node_modules/jsdom/lib/jsdom/living/aborting/AbortController-impl.js new file mode 100644 index 00000000..491f76f3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/aborting/AbortController-impl.js @@ -0,0 +1,17 @@ +"use strict"; + +const AbortSignal = require("../generated/AbortSignal"); + +class AbortControllerImpl { + constructor(globalObject) { + this.signal = AbortSignal.createImpl(globalObject, []); + } + + abort(reason) { + this.signal._signalAbort(reason); + } +} + +module.exports = { + implementation: AbortControllerImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/aborting/AbortSignal-impl.js b/node_modules/jsdom/lib/jsdom/living/aborting/AbortSignal-impl.js new file mode 100644 index 00000000..25b29e1f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/aborting/AbortSignal-impl.js @@ -0,0 +1,69 @@ +"use strict"; + +const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor"); +const { fireAnEvent } = require("../helpers/events"); +const EventTargetImpl = require("../events/EventTarget-impl").implementation; +const AbortSignal = require("../generated/AbortSignal"); +const DOMException = require("domexception/webidl2js-wrapper"); + +class AbortSignalImpl extends EventTargetImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + // make event firing possible + this._ownerDocument = globalObject.document; + + this.reason = undefined; + this.abortAlgorithms = new Set(); + } + + get aborted() { + return this.reason !== undefined; + } + + static abort(globalObject, reason) { + const abortSignal = AbortSignal.createImpl(globalObject, []); + if (reason !== undefined) { + abortSignal.reason = reason; + } else { + abortSignal.reason = DOMException.create(globalObject, ["The operation was aborted.", "AbortError"]); + } + return abortSignal; + } + + _signalAbort(reason) { + if (this.aborted) { + return; + } + + if (reason !== undefined) { + this.reason = reason; + } else { + this.reason = DOMException.create(this._globalObject, ["The operation was aborted.", "AbortError"]); + } + + for (const algorithm of this.abortAlgorithms) { + algorithm(); + } + this.abortAlgorithms.clear(); + + fireAnEvent("abort", this); + } + + _addAlgorithm(algorithm) { + if (this.aborted) { + return; + } + this.abortAlgorithms.add(algorithm); + } + + _removeAlgorithm(algorithm) { + this.abortAlgorithms.delete(algorithm); + } +} + +setupForSimpleEventAccessors(AbortSignalImpl.prototype, ["abort"]); + +module.exports = { + implementation: AbortSignalImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/attributes.js b/node_modules/jsdom/lib/jsdom/living/attributes.js new file mode 100644 index 00000000..295dbe0c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/attributes.js @@ -0,0 +1,312 @@ +"use strict"; +const DOMException = require("domexception/webidl2js-wrapper"); + +const { HTML_NS } = require("./helpers/namespaces"); +const { asciiLowercase } = require("./helpers/strings"); +const { queueAttributeMutationRecord } = require("./helpers/mutation-observers"); +const { enqueueCECallbackReaction } = require("./helpers/custom-elements"); + +// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a +// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations. + +/* eslint-disable no-restricted-properties */ + +exports.hasAttribute = function (element, A) { + return element._attributeList.includes(A); +}; + +exports.hasAttributeByName = function (element, name) { + return element._attributesByNameMap.has(name); +}; + +exports.hasAttributeByNameNS = function (element, namespace, localName) { + return element._attributeList.some(attribute => { + return attribute._localName === localName && attribute._namespace === namespace; + }); +}; + +// https://dom.spec.whatwg.org/#concept-element-attributes-change +exports.changeAttribute = (element, attribute, value) => { + const { _localName, _namespace, _value } = attribute; + + queueAttributeMutationRecord(element, _localName, _namespace, _value); + + if (element._ceState === "custom") { + enqueueCECallbackReaction(element, "attributeChangedCallback", [ + _localName, + _value, + value, + _namespace + ]); + } + + attribute._value = value; + + // Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed." + element._attrModified(attribute._qualifiedName, value, _value); +}; + +// https://dom.spec.whatwg.org/#concept-element-attributes-append +exports.appendAttribute = function (element, attribute) { + const { _localName, _namespace, _value } = attribute; + queueAttributeMutationRecord(element, _localName, _namespace, null); + + if (element._ceState === "custom") { + enqueueCECallbackReaction(element, "attributeChangedCallback", [ + _localName, + null, + _value, + _namespace + ]); + } + + const attributeList = element._attributeList; + + attributeList.push(attribute); + attribute._element = element; + + // Sync name cache + const name = attribute._qualifiedName; + const cache = element._attributesByNameMap; + let entry = cache.get(name); + if (!entry) { + entry = []; + cache.set(name, entry); + } + entry.push(attribute); + + // Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added." + element._attrModified(name, _value, null); +}; + +exports.removeAttribute = function (element, attribute) { + // https://dom.spec.whatwg.org/#concept-element-attributes-remove + + const { _localName, _namespace, _value } = attribute; + + queueAttributeMutationRecord(element, _localName, _namespace, _value); + + if (element._ceState === "custom") { + enqueueCECallbackReaction(element, "attributeChangedCallback", [ + _localName, + _value, + null, + _namespace + ]); + } + + const attributeList = element._attributeList; + + for (let i = 0; i < attributeList.length; ++i) { + if (attributeList[i] === attribute) { + attributeList.splice(i, 1); + attribute._element = null; + + // Sync name cache + const name = attribute._qualifiedName; + const cache = element._attributesByNameMap; + const entry = cache.get(name); + entry.splice(entry.indexOf(attribute), 1); + if (entry.length === 0) { + cache.delete(name); + } + + // Run jsdom hooks; roughly correspond to spec's "An attribute is removed." + element._attrModified(name, null, attribute._value); + + return; + } + } +}; + +exports.replaceAttribute = function (element, oldAttr, newAttr) { + // https://dom.spec.whatwg.org/#concept-element-attributes-replace + + const { _localName, _namespace, _value } = oldAttr; + + queueAttributeMutationRecord(element, _localName, _namespace, _value); + + if (element._ceState === "custom") { + enqueueCECallbackReaction(element, "attributeChangedCallback", [ + _localName, + _value, + newAttr._value, + _namespace + ]); + } + + const attributeList = element._attributeList; + + for (let i = 0; i < attributeList.length; ++i) { + if (attributeList[i] === oldAttr) { + attributeList.splice(i, 1, newAttr); + oldAttr._element = null; + newAttr._element = element; + + // Sync name cache + const name = newAttr._qualifiedName; + const cache = element._attributesByNameMap; + let entry = cache.get(name); + if (!entry) { + entry = []; + cache.set(name, entry); + } + entry.splice(entry.indexOf(oldAttr), 1, newAttr); + + // Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed." + element._attrModified(name, newAttr._value, oldAttr._value); + + return; + } + } +}; + +exports.getAttributeByName = function (element, name) { + // https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name + + if (element._namespaceURI === HTML_NS && + element._ownerDocument._parsingMode === "html") { + name = asciiLowercase(name); + } + + const cache = element._attributesByNameMap; + const entry = cache.get(name); + if (!entry) { + return null; + } + + return entry[0]; +}; + +exports.getAttributeByNameNS = function (element, namespace, localName) { + // https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace + + if (namespace === "") { + namespace = null; + } + + const attributeList = element._attributeList; + for (let i = 0; i < attributeList.length; ++i) { + const attr = attributeList[i]; + if (attr._namespace === namespace && attr._localName === localName) { + return attr; + } + } + + return null; +}; + +// Both of the following functions implement https://dom.spec.whatwg.org/#concept-element-attributes-get-value. +// Separated them into two to keep symmetry with other functions. +exports.getAttributeValue = function (element, localName) { + const attr = exports.getAttributeByNameNS(element, null, localName); + + if (!attr) { + return ""; + } + + return attr._value; +}; + +exports.getAttributeValueNS = function (element, namespace, localName) { + const attr = exports.getAttributeByNameNS(element, namespace, localName); + + if (!attr) { + return ""; + } + + return attr._value; +}; + +exports.setAttribute = function (element, attr) { + // https://dom.spec.whatwg.org/#concept-element-attributes-set + + if (attr._element !== null && attr._element !== element) { + throw DOMException.create(element._globalObject, ["The attribute is in use.", "InUseAttributeError"]); + } + + const oldAttr = exports.getAttributeByNameNS(element, attr._namespace, attr._localName); + if (oldAttr === attr) { + return attr; + } + + if (oldAttr !== null) { + exports.replaceAttribute(element, oldAttr, attr); + } else { + exports.appendAttribute(element, attr); + } + + return oldAttr; +}; + +exports.setAttributeValue = function (element, localName, value, prefix, namespace) { + // https://dom.spec.whatwg.org/#concept-element-attributes-set-value + + if (prefix === undefined) { + prefix = null; + } + if (namespace === undefined) { + namespace = null; + } + + const attribute = exports.getAttributeByNameNS(element, namespace, localName); + if (attribute === null) { + const newAttribute = element._ownerDocument._createAttribute({ + namespace, + namespacePrefix: prefix, + localName, + value + }); + exports.appendAttribute(element, newAttribute); + + return; + } + + exports.changeAttribute(element, attribute, value); +}; + +// https://dom.spec.whatwg.org/#set-an-existing-attribute-value +exports.setAnExistingAttributeValue = (attribute, value) => { + const element = attribute._element; + if (element === null) { + attribute._value = value; + } else { + exports.changeAttribute(element, attribute, value); + } +}; + +exports.removeAttributeByName = function (element, name) { + // https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name + + const attr = exports.getAttributeByName(element, name); + + if (attr !== null) { + exports.removeAttribute(element, attr); + } + + return attr; +}; + +exports.removeAttributeByNameNS = function (element, namespace, localName) { + // https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace + + const attr = exports.getAttributeByNameNS(element, namespace, localName); + + if (attr !== null) { + exports.removeAttribute(element, attr); + } + + return attr; +}; + +exports.attributeNames = function (element) { + // Needed by https://dom.spec.whatwg.org/#dom-element-getattributenames + + return element._attributeList.map(a => a._qualifiedName); +}; + +exports.hasAttributes = function (element) { + // Needed by https://dom.spec.whatwg.org/#dom-element-hasattributes + + return element._attributeList.length > 0; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js b/node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js new file mode 100644 index 00000000..e5d4daa2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/attributes/Attr-impl.js @@ -0,0 +1,60 @@ +"use strict"; + +const { setAnExistingAttributeValue } = require("../attributes.js"); +const NodeImpl = require("../nodes/Node-impl.js").implementation; +const { ATTRIBUTE_NODE } = require("../node-type.js"); + +exports.implementation = class AttrImpl extends NodeImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._namespace = privateData.namespace !== undefined ? privateData.namespace : null; + this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null; + this._localName = privateData.localName; + this._value = privateData.value !== undefined ? privateData.value : ""; + this._element = privateData.element !== undefined ? privateData.element : null; + + this.nodeType = ATTRIBUTE_NODE; + this.specified = true; + } + + get namespaceURI() { + return this._namespace; + } + + get prefix() { + return this._namespacePrefix; + } + + get localName() { + return this._localName; + } + + get name() { + return this._qualifiedName; + } + + get nodeName() { + return this._qualifiedName; + } + + get value() { + return this._value; + } + set value(value) { + setAnExistingAttributeValue(this, value); + } + + get ownerElement() { + return this._element; + } + + get _qualifiedName() { + // https://dom.spec.whatwg.org/#concept-attribute-qualified-name + if (this._namespacePrefix === null) { + return this._localName; + } + + return this._namespacePrefix + ":" + this._localName; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/attributes/NamedNodeMap-impl.js b/node_modules/jsdom/lib/jsdom/living/attributes/NamedNodeMap-impl.js new file mode 100644 index 00000000..f2440772 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/attributes/NamedNodeMap-impl.js @@ -0,0 +1,78 @@ +"use strict"; + +const DOMException = require("domexception/webidl2js-wrapper"); +const idlUtils = require("../generated/utils.js"); +const attributes = require("../attributes.js"); +const { HTML_NS } = require("../helpers/namespaces"); + +exports.implementation = class NamedNodeMapImpl { + constructor(globalObject, args, privateData) { + this._element = privateData.element; + + this._globalObject = globalObject; + } + get _attributeList() { + return this._element._attributeList; + } + + get [idlUtils.supportedPropertyIndices]() { + return this._attributeList.keys(); + } + get length() { + return this._attributeList.length; + } + item(index) { + if (index >= this._attributeList.length) { + return null; + } + return this._attributeList[index]; + } + + get [idlUtils.supportedPropertyNames]() { + const names = new Set(this._attributeList.map(a => a._qualifiedName)); + const el = this._element; + if (el._namespaceURI === HTML_NS && el._ownerDocument._parsingMode === "html") { + for (const name of names) { + const lowercaseName = name.toLowerCase(); + if (lowercaseName !== name) { + names.delete(name); + } + } + } + return names; + } + getNamedItem(qualifiedName) { + return attributes.getAttributeByName(this._element, qualifiedName); + } + getNamedItemNS(namespace, localName) { + return attributes.getAttributeByNameNS(this._element, namespace, localName); + } + setNamedItem(attr) { + // eslint-disable-next-line no-restricted-properties + return attributes.setAttribute(this._element, attr); + } + setNamedItemNS(attr) { + // eslint-disable-next-line no-restricted-properties + return attributes.setAttribute(this._element, attr); + } + removeNamedItem(qualifiedName) { + const attr = attributes.removeAttributeByName(this._element, qualifiedName); + if (attr === null) { + throw DOMException.create(this._globalObject, [ + "Tried to remove an attribute that was not present", + "NotFoundError" + ]); + } + return attr; + } + removeNamedItemNS(namespace, localName) { + const attr = attributes.removeAttributeByNameNS(this._element, namespace, localName); + if (attr === null) { + throw DOMException.create(this._globalObject, [ + "Tried to remove an attribute that was not present", + "NotFoundError" + ]); + } + return attr; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/constraint-validation/DefaultConstraintValidation-impl.js b/node_modules/jsdom/lib/jsdom/living/constraint-validation/DefaultConstraintValidation-impl.js new file mode 100644 index 00000000..189533a7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/constraint-validation/DefaultConstraintValidation-impl.js @@ -0,0 +1,75 @@ +"use strict"; + +const ValidityState = require("../generated/ValidityState"); +const { isDisabled } = require("../helpers/form-controls"); +const { closest } = require("../helpers/traversal"); +const { fireAnEvent } = require("../helpers/events"); + +exports.implementation = class DefaultConstraintValidationImpl { + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate + get willValidate() { + return this._isCandidateForConstraintValidation(); + } + + get validity() { + if (!this._validity) { + this._validity = ValidityState.createImpl(this._globalObject, [], { + element: this + }); + } + return this._validity; + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity + checkValidity() { + if (!this._isCandidateForConstraintValidation()) { + return true; + } + if (this._satisfiesConstraints()) { + return true; + } + fireAnEvent("invalid", this, undefined, { cancelable: true }); + return false; + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-setcustomvalidity + setCustomValidity(message) { + this._customValidityErrorMessage = message; + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity + // Since jsdom has no user interaction, it's the same as #checkValidity + reportValidity() { + return this.checkValidity(); + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validationmessage + get validationMessage() { + const { validity } = this; + if (!this._isCandidateForConstraintValidation() || this._satisfiesConstraints()) { + return ""; + } + const isSufferingFromCustomError = validity.customError; + if (isSufferingFromCustomError) { + return this._customValidityErrorMessage; + } + return "Constraints not satisfied"; + } + + _isCandidateForConstraintValidation() { + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-disabled + return !isDisabled(this) && + // If an element has a datalist element ancestor, + // it is barred from constraint validation. + closest(this, "datalist") === null && + !this._barredFromConstraintValidationSpecialization(); + } + + _isBarredFromConstraintValidation() { + return !this._isCandidateForConstraintValidation(); + } + + _satisfiesConstraints() { + return this.validity.valid; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/constraint-validation/ValidityState-impl.js b/node_modules/jsdom/lib/jsdom/living/constraint-validation/ValidityState-impl.js new file mode 100644 index 00000000..c5bd355c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/constraint-validation/ValidityState-impl.js @@ -0,0 +1,66 @@ +"use strict"; + +exports.implementation = class ValidityStateImpl { + constructor(globalObject, args, privateData) { + const { element, state = {} } = privateData; + + this._element = element; + this._state = state; + } + + get badInput() { + return this._failsConstraint("badInput"); + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-custom-error + get customError() { + return this._element._customValidityErrorMessage !== ""; + } + + get patternMismatch() { + return this._failsConstraint("patternMismatch"); + } + + get rangeOverflow() { + return this._failsConstraint("rangeOverflow"); + } + + get rangeUnderflow() { + return this._failsConstraint("rangeUnderflow"); + } + + get stepMismatch() { + return this._failsConstraint("stepMismatch"); + } + + get tooLong() { + return this._failsConstraint("tooLong"); + } + + get tooShort() { + return this._failsConstraint("tooShort"); + } + + get typeMismatch() { + return this._failsConstraint("typeMismatch"); + } + + get valueMissing() { + return this._failsConstraint("valueMissing"); + } + + _failsConstraint(method) { + const validationMethod = this._state[method]; + if (validationMethod) { + return validationMethod(); + } + + return false; + } + + get valid() { + return !(this.badInput || this.valueMissing || this.customError || + this.patternMismatch || this.rangeOverflow || this.rangeUnderflow || + this.stepMismatch || this.tooLong || this.tooShort || this.typeMismatch); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/crypto/Crypto-impl.js b/node_modules/jsdom/lib/jsdom/living/crypto/Crypto-impl.js new file mode 100644 index 00000000..61406c19 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/crypto/Crypto-impl.js @@ -0,0 +1,63 @@ +"use strict"; + +const nodeCrypto = require("crypto"); +const DOMException = require("domexception/webidl2js-wrapper"); + +// https://w3c.github.io/webcrypto/#crypto-interface +class CryptoImpl { + constructor(globalObject) { + this._globalObject = globalObject; + } + + // https://w3c.github.io/webcrypto/#Crypto-method-getRandomValues + getRandomValues(array) { + const typeName = getTypedArrayTypeName(array); + if (!(typeName === "Int8Array" || + typeName === "Uint8Array" || + typeName === "Uint8ClampedArray" || + typeName === "Int16Array" || + typeName === "Uint16Array" || + typeName === "Int32Array" || + typeName === "Uint32Array" || + typeName === "BigInt64Array" || + typeName === "BigUint64Array")) { + throw DOMException.create(this._globalObject, [ + `getRandomValues() only accepts integer typed arrays`, + "TypeMismatchError" + ]); + } + + if (array.byteLength > 65536) { + throw DOMException.create(this._globalObject, [ + `getRandomValues() cannot generate more than 65536 bytes of random values; ` + + `${array.byteLength} bytes were requested`, + "QuotaExceededError" + ]); + } + nodeCrypto.randomFillSync(array); + return array; + } +} + +exports.implementation = CryptoImpl; + +// See #3395. Subclasses of TypedArrays should properly work, but we can't rely +// on instanceof because Uint8Array may be different across different windows - +// which can happen in JSDOM when running { runScripts: "dangerously" }. As a +// solution, we imitate the behavior of instanceof by walking the proottype +// chain. +function getTypedArrayTypeName(array) { + const target = array.constructor; + const chain = [target.name]; + let proto = Object.getPrototypeOf(target); + while (proto) { + chain.push(proto.name); + proto = Object.getPrototypeOf(proto); + } + + while (chain.length > 0 && chain[chain.length - 1] !== "TypedArray") { + chain.pop(); + } + chain.reverse(); + return chain[1]; +} diff --git a/node_modules/jsdom/lib/jsdom/living/cssom/StyleSheetList-impl.js b/node_modules/jsdom/lib/jsdom/living/cssom/StyleSheetList-impl.js new file mode 100644 index 00000000..c786c91b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/cssom/StyleSheetList-impl.js @@ -0,0 +1,38 @@ +"use strict"; + +const idlUtils = require("../generated/utils.js"); + +exports.implementation = class StyleSheetList { + constructor() { + this._list = []; + } + + get length() { + return this._list.length; + } + + item(index) { + const result = this._list[index]; + return result !== undefined ? result : null; + } + + get [idlUtils.supportedPropertyIndices]() { + return this._list.keys(); + } + + _add(sheet) { + const { _list } = this; + if (!_list.includes(sheet)) { + _list.push(sheet); + } + } + + _remove(sheet) { + const { _list } = this; + + const index = _list.indexOf(sheet); + if (index >= 0) { + _list.splice(index, 1); + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js b/node_modules/jsdom/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js new file mode 100644 index 00000000..642a0bbb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js @@ -0,0 +1,265 @@ +"use strict"; + +const webIDLConversions = require("webidl-conversions"); +const DOMException = require("domexception/webidl2js-wrapper"); + +const NODE_TYPE = require("../node-type"); + +const { HTML_NS } = require("../helpers/namespaces"); +const { getHTMLElementInterface } = require("../helpers/create-element"); +const { shadowIncludingInclusiveDescendantsIterator } = require("../helpers/shadow-dom"); +const { isValidCustomElementName, tryUpgradeElement, enqueueCEUpgradeReaction } = require("../helpers/custom-elements"); + +const idlUtils = require("../generated/utils"); +const IDLFunction = require("../generated/Function.js"); +const HTMLUnknownElement = require("../generated/HTMLUnknownElement"); + +const LIFECYCLE_CALLBACKS = [ + "connectedCallback", + "disconnectedCallback", + "adoptedCallback", + "attributeChangedCallback" +]; + +function convertToSequenceDOMString(obj) { + if (!obj || !obj[Symbol.iterator]) { + throw new TypeError("Invalid Sequence"); + } + + return Array.from(obj).map(webIDLConversions.DOMString); +} + +// Returns true is the passed value is a valid constructor. +// Borrowed from: https://stackoverflow.com/a/39336206/3832710 +function isConstructor(value) { + if (typeof value !== "function") { + return false; + } + + try { + const P = new Proxy(value, { + construct() { + return {}; + } + }); + + // eslint-disable-next-line no-new + new P(); + + return true; + } catch { + return false; + } +} + +// https://html.spec.whatwg.org/#customelementregistry +class CustomElementRegistryImpl { + constructor(globalObject) { + this._customElementDefinitions = []; + this._elementDefinitionIsRunning = false; + this._whenDefinedPromiseMap = Object.create(null); + + this._globalObject = globalObject; + } + + // https://html.spec.whatwg.org/#dom-customelementregistry-define + define(name, constructor, options) { + const { _globalObject } = this; + const ctor = constructor.objectReference; + + if (!isConstructor(ctor)) { + throw new TypeError("Constructor argument is not a constructor."); + } + + if (!isValidCustomElementName(name)) { + throw DOMException.create(_globalObject, ["Name argument is not a valid custom element name.", "SyntaxError"]); + } + + const nameAlreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name); + if (nameAlreadyRegistered) { + throw DOMException.create(_globalObject, [ + "This name has already been registered in the registry.", + "NotSupportedError" + ]); + } + + const ctorAlreadyRegistered = this._customElementDefinitions.some(entry => entry.objectReference === ctor); + if (ctorAlreadyRegistered) { + throw DOMException.create(_globalObject, [ + "This constructor has already been registered in the registry.", + "NotSupportedError" + ]); + } + + let localName = name; + + let extendsOption = null; + if (options !== undefined && options.extends) { + extendsOption = options.extends; + } + + if (extendsOption !== null) { + if (isValidCustomElementName(extendsOption)) { + throw DOMException.create(_globalObject, [ + "Option extends value can't be a valid custom element name.", + "NotSupportedError" + ]); + } + + const extendsInterface = getHTMLElementInterface(extendsOption); + if (extendsInterface === HTMLUnknownElement) { + throw DOMException.create(_globalObject, [ + `${extendsOption} is an HTMLUnknownElement.`, + "NotSupportedError" + ]); + } + + localName = extendsOption; + } + + if (this._elementDefinitionIsRunning) { + throw DOMException.create(_globalObject, [ + "Invalid nested custom element definition.", + "NotSupportedError" + ]); + } + + this._elementDefinitionIsRunning = true; + + let disableShadow = false; + let observedAttributes = []; + const lifecycleCallbacks = { + connectedCallback: null, + disconnectedCallback: null, + adoptedCallback: null, + attributeChangedCallback: null + }; + + let caughtError; + try { + const { prototype } = ctor; + + if (typeof prototype !== "object") { + throw new TypeError("Invalid constructor prototype."); + } + + for (const callbackName of LIFECYCLE_CALLBACKS) { + const callbackValue = prototype[callbackName]; + + if (callbackValue !== undefined) { + lifecycleCallbacks[callbackName] = IDLFunction.convert(_globalObject, callbackValue, { + context: `The lifecycle callback "${callbackName}"` + }); + } + } + + if (lifecycleCallbacks.attributeChangedCallback !== null) { + const observedAttributesIterable = ctor.observedAttributes; + + if (observedAttributesIterable !== undefined) { + observedAttributes = convertToSequenceDOMString(observedAttributesIterable); + } + } + + let disabledFeatures = []; + const disabledFeaturesIterable = ctor.disabledFeatures; + if (disabledFeaturesIterable) { + disabledFeatures = convertToSequenceDOMString(disabledFeaturesIterable); + } + + disableShadow = disabledFeatures.includes("shadow"); + } catch (err) { + caughtError = err; + } finally { + this._elementDefinitionIsRunning = false; + } + + if (caughtError !== undefined) { + throw caughtError; + } + + const definition = { + name, + localName, + constructor, + objectReference: ctor, + observedAttributes, + lifecycleCallbacks, + disableShadow, + constructionStack: [] + }; + + this._customElementDefinitions.push(definition); + + const document = idlUtils.implForWrapper(this._globalObject._document); + + const upgradeCandidates = []; + for (const candidate of shadowIncludingInclusiveDescendantsIterator(document)) { + if ( + (candidate._namespaceURI === HTML_NS && candidate._localName === localName) && + (extendsOption === null || candidate._isValue === name) + ) { + upgradeCandidates.push(candidate); + } + } + + for (const upgradeCandidate of upgradeCandidates) { + enqueueCEUpgradeReaction(upgradeCandidate, definition); + } + + if (this._whenDefinedPromiseMap[name] !== undefined) { + this._whenDefinedPromiseMap[name].resolve(ctor); + delete this._whenDefinedPromiseMap[name]; + } + } + + // https://html.spec.whatwg.org/#dom-customelementregistry-get + get(name) { + const definition = this._customElementDefinitions.find(entry => entry.name === name); + return definition && definition.objectReference; + } + + // https://html.spec.whatwg.org/#dom-customelementregistry-whendefined + whenDefined(name) { + if (!isValidCustomElementName(name)) { + return Promise.reject(DOMException.create( + this._globalObject, + ["Name argument is not a valid custom element name.", "SyntaxError"] + )); + } + + const alreadyRegistered = this._customElementDefinitions.find(entry => entry.name === name); + if (alreadyRegistered) { + return Promise.resolve(alreadyRegistered.objectReference); + } + + if (this._whenDefinedPromiseMap[name] === undefined) { + let resolve; + const promise = new Promise(r => { + resolve = r; + }); + + // Store the pending Promise along with the extracted resolve callback to actually resolve the returned Promise, + // once the custom element is registered. + this._whenDefinedPromiseMap[name] = { + promise, + resolve + }; + } + + return this._whenDefinedPromiseMap[name].promise; + } + + // https://html.spec.whatwg.org/#dom-customelementregistry-upgrade + upgrade(root) { + for (const candidate of shadowIncludingInclusiveDescendantsIterator(root)) { + if (candidate.nodeType === NODE_TYPE.ELEMENT_NODE) { + tryUpgradeElement(candidate); + } + } + } +} + +module.exports = { + implementation: CustomElementRegistryImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/documents.js b/node_modules/jsdom/lib/jsdom/living/documents.js new file mode 100644 index 00000000..a9ad0ce5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/documents.js @@ -0,0 +1,15 @@ +"use strict"; +const XMLDocument = require("../living/generated/XMLDocument.js"); +const Document = require("../living/generated/Document.js"); +const { wrapperForImpl } = require("./generated/utils.js"); + +exports.createImpl = (globalObject, options, { alwaysUseDocumentClass = false } = {}) => { + if (options.parsingMode === "xml" && !alwaysUseDocumentClass) { + return XMLDocument.createImpl(globalObject, [], { options }); + } + return Document.createImpl(globalObject, [], { options }); +}; + +exports.createWrapper = (...args) => { + return wrapperForImpl(exports.createImpl(...args)); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/domparsing/DOMParser-impl.js b/node_modules/jsdom/lib/jsdom/living/domparsing/DOMParser-impl.js new file mode 100644 index 00000000..3877d2b7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/domparsing/DOMParser-impl.js @@ -0,0 +1,58 @@ +"use strict"; + +const { parseIntoDocument } = require("../../browser/parser"); + +const Document = require("../generated/Document"); + +exports.implementation = class DOMParserImpl { + constructor(globalObject) { + this._globalObject = globalObject; + } + + parseFromString(string, contentType) { + switch (String(contentType)) { + case "text/html": { + return this.createScriptingDisabledDocument("html", contentType, string); + } + + case "text/xml": + case "application/xml": + case "application/xhtml+xml": + case "image/svg+xml": { + try { + return this.createScriptingDisabledDocument("xml", contentType, string); + } catch (error) { + const document = this.createScriptingDisabledDocument("xml", contentType); + const element = document.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror"); + + element.textContent = error.message; + + document.appendChild(element); + return document; + } + } + + default: + throw new TypeError("Invalid contentType"); + } + } + + createScriptingDisabledDocument(parsingMode, contentType, string) { + const document = Document.createImpl(this._globalObject, [], { + options: { + parsingMode, + encoding: "UTF-8", + contentType, + readyState: "complete", + scriptingDisabled: true + // TODO: somehow set URL to active document's URL + } + }); + + if (string !== undefined) { + parseIntoDocument(string, document); + } + + return document; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/domparsing/InnerHTML-impl.js b/node_modules/jsdom/lib/jsdom/living/domparsing/InnerHTML-impl.js new file mode 100644 index 00000000..bdbd7b37 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/domparsing/InnerHTML-impl.js @@ -0,0 +1,30 @@ +"use strict"; + +const { parseFragment } = require("../../browser/parser"); +const { HTML_NS } = require("../helpers/namespaces.js"); +const { isShadowRoot } = require("../helpers/shadow-dom.js"); +const NODE_TYPE = require("../node-type.js"); +const { fragmentSerialization } = require("./serialization.js"); + +// https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin +exports.implementation = class InnerHTMLImpl { + // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml + get innerHTML() { + return fragmentSerialization(this, { + outer: false, + requireWellFormed: true, + globalObject: this._globalObject + }); + } + set innerHTML(markup) { + const contextElement = isShadowRoot(this) ? this.host : this; + const fragment = parseFragment(markup, contextElement); + + let contextObject = this; + if (this.nodeType === NODE_TYPE.ELEMENT_NODE && this.localName === "template" && this.namespaceURI === HTML_NS) { + contextObject = this._templateContents; + } + + contextObject._replaceAll(fragment); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/domparsing/XMLSerializer-impl.js b/node_modules/jsdom/lib/jsdom/living/domparsing/XMLSerializer-impl.js new file mode 100644 index 00000000..5170de81 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/domparsing/XMLSerializer-impl.js @@ -0,0 +1,18 @@ +"use strict"; +const serialize = require("w3c-xmlserializer"); +const DOMException = require("domexception/webidl2js-wrapper"); +const utils = require("../generated/utils"); + +exports.implementation = class XMLSerializerImpl { + constructor(globalObject) { + this._globalObject = globalObject; + } + + serializeToString(root) { + try { + return serialize(utils.wrapperForImpl(root), { requireWellFormed: false }); + } catch (e) { + throw DOMException.create(this._globalObject, [e.message, "InvalidStateError"]); + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js b/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js new file mode 100644 index 00000000..4d8eff08 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/domparsing/parse5-adapter-serialization.js @@ -0,0 +1,63 @@ +"use strict"; +const nodeTypes = require("../node-type"); +const { domSymbolTree } = require("../helpers/internal-constants"); +// Serialization only requires a subset of the tree adapter interface. + +// Tree traversing +exports.getFirstChild = node => node.firstChild; + +exports.getChildNodes = node => domSymbolTree.childrenToArray(node); + +exports.getParentNode = node => node.parentNode; + +exports.getAttrList = element => { + const attributeList = [...element._attributeList]; + + if (element._isValue && attributeList.every(attr => attr.name !== "is")) { + attributeList.unshift({ + name: "is", + namespace: null, + prefix: null, + value: element._isValue + }); + } + + return attributeList; +}; + +// Node data +exports.getTagName = element => element._qualifiedName; // https://github.com/inikulin/parse5/issues/231 + +exports.getNamespaceURI = element => element.namespaceURI; + +exports.getTextNodeContent = exports.getCommentNodeContent = node => node.data; + +exports.getDocumentTypeNodeName = node => node.name; + +exports.getDocumentTypeNodePublicId = node => node.publicId; + +exports.getDocumentTypeNodeSystemId = node => node.systemId; + +exports.getTemplateContent = templateElement => templateElement._templateContents; + +exports.getDocumentMode = document => document._mode; + +// Node types +exports.isTextNode = node => node.nodeType === nodeTypes.TEXT_NODE; + +exports.isCommentNode = node => node.nodeType === nodeTypes.COMMENT_NODE; + +exports.isDocumentTypeNode = node => node.nodeType === nodeTypes.DOCUMENT_TYPE_NODE; + +exports.isElementNode = node => node.nodeType === nodeTypes.ELEMENT_NODE; + +// Source code location +exports.setNodeSourceCodeLocation = (node, location) => { + node.sourceCodeLocation = location; +}; + +exports.getNodeSourceCodeLocation = node => node.sourceCodeLocation; + +exports.updateNodeSourceCodeLocation = (node, endLocation) => { + Object.assign(node.sourceCodeLocation, endLocation); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/domparsing/serialization.js b/node_modules/jsdom/lib/jsdom/living/domparsing/serialization.js new file mode 100644 index 00000000..8808a0a7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/domparsing/serialization.js @@ -0,0 +1,36 @@ +"use strict"; + +const produceXMLSerialization = require("w3c-xmlserializer"); +const parse5 = require("parse5"); +const DOMException = require("domexception/webidl2js-wrapper"); + +const utils = require("../generated/utils"); +const treeAdapter = require("./parse5-adapter-serialization"); +const NODE_TYPE = require("../node-type"); + +module.exports.fragmentSerialization = (node, { outer, requireWellFormed, globalObject }) => { + const contextDocument = + node.nodeType === NODE_TYPE.DOCUMENT_NODE ? node : node._ownerDocument; + if (contextDocument._parsingMode === "html") { + const config = { + ...contextDocument._parseOptions, + treeAdapter + }; + return outer ? parse5.serializeOuter(node, config) : parse5.serialize(node, config); + } + + const childNodes = outer ? [node] : node.childNodes; + + try { + let serialized = ""; + for (let i = 0; i < childNodes.length; ++i) { + serialized += produceXMLSerialization( + utils.wrapperForImpl(childNodes[i] || childNodes.item(i)), + { requireWellFormed } + ); + } + return serialized; + } catch (e) { + throw DOMException.create(globalObject, [e.message, "InvalidStateError"]); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/CloseEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/CloseEvent-impl.js new file mode 100644 index 00000000..c52b0094 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/CloseEvent-impl.js @@ -0,0 +1,10 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const CloseEventInit = require("../generated/CloseEventInit"); + +class CloseEventImpl extends EventImpl {} +CloseEventImpl.defaultInit = CloseEventInit.convert(undefined, undefined); + +exports.implementation = CloseEventImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/events/CompositionEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/CompositionEvent-impl.js new file mode 100644 index 00000000..b087e814 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/CompositionEvent-impl.js @@ -0,0 +1,20 @@ +"use strict"; + +const UIEventImpl = require("./UIEvent-impl").implementation; +const CompositionEventInit = require("../generated/CompositionEventInit"); + +class CompositionEventImpl extends UIEventImpl { + initCompositionEvent(type, bubbles, cancelable, view, data) { + if (this._dispatchFlag) { + return; + } + + this.initUIEvent(type, bubbles, cancelable, view, 0); + this.data = data; + } +} +CompositionEventImpl.defaultInit = CompositionEventInit.convert(undefined, undefined); + +module.exports = { + implementation: CompositionEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js new file mode 100644 index 00000000..626b117a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js @@ -0,0 +1,21 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const CustomEventInit = require("../generated/CustomEventInit"); + +class CustomEventImpl extends EventImpl { + initCustomEvent(type, bubbles, cancelable, detail) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.detail = detail; + } +} +CustomEventImpl.defaultInit = CustomEventInit.convert(undefined, undefined); + +module.exports = { + implementation: CustomEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js new file mode 100644 index 00000000..5bd26561 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const ErrorEventInit = require("../generated/ErrorEventInit"); + +class ErrorEventImpl extends EventImpl { + +} +ErrorEventImpl.defaultInit = ErrorEventInit.convert(undefined, undefined); + +module.exports = { + implementation: ErrorEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js b/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js new file mode 100644 index 00000000..0a4867f7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js @@ -0,0 +1,197 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); +const EventInit = require("../generated/EventInit"); + +class EventImpl { + constructor(globalObject, args, privateData) { + const [type, eventInitDict = this.constructor.defaultInit] = args; + + this.type = type; + + this.bubbles = false; + this.cancelable = false; + for (const key in eventInitDict) { + if (key in this.constructor.defaultInit) { + this[key] = eventInitDict[key]; + } + } + for (const key in this.constructor.defaultInit) { + if (!(key in this)) { + this[key] = this.constructor.defaultInit[key]; + } + } + + this.target = null; + this.currentTarget = null; + this.eventPhase = 0; + + this._globalObject = globalObject; + this._initializedFlag = true; + this._stopPropagationFlag = false; + this._stopImmediatePropagationFlag = false; + this._canceledFlag = false; + this._inPassiveListenerFlag = false; + this._dispatchFlag = false; + this._path = []; + + this.isTrusted = privateData.isTrusted || false; + this.timeStamp = Date.now(); + } + + // https://dom.spec.whatwg.org/#set-the-canceled-flag + _setTheCanceledFlag() { + if (this.cancelable && !this._inPassiveListenerFlag) { + this._canceledFlag = true; + } + } + + get srcElement() { + return this.target; + } + + get returnValue() { + return !this._canceledFlag; + } + + set returnValue(v) { + if (v === false) { + this._setTheCanceledFlag(); + } + } + + get defaultPrevented() { + return this._canceledFlag; + } + + stopPropagation() { + this._stopPropagationFlag = true; + } + + get cancelBubble() { + return this._stopPropagationFlag; + } + + set cancelBubble(v) { + if (v) { + this._stopPropagationFlag = true; + } + } + + stopImmediatePropagation() { + this._stopPropagationFlag = true; + this._stopImmediatePropagationFlag = true; + } + + preventDefault() { + this._setTheCanceledFlag(); + } + + // https://dom.spec.whatwg.org/#dom-event-composedpath + // Current implementation is based of https://whatpr.org/dom/699.html#dom-event-composedpath + // due to a bug in composed path implementation https://github.com/whatwg/dom/issues/684 + composedPath() { + const composedPath = []; + + const { currentTarget, _path: path } = this; + + if (path.length === 0) { + return composedPath; + } + + composedPath.push(currentTarget); + + let currentTargetIndex = 0; + let currentTargetHiddenSubtreeLevel = 0; + + for (let index = path.length - 1; index >= 0; index--) { + const { item, rootOfClosedTree, slotInClosedTree } = path[index]; + + if (rootOfClosedTree) { + currentTargetHiddenSubtreeLevel++; + } + + if (item === idlUtils.implForWrapper(currentTarget)) { + currentTargetIndex = index; + break; + } + + if (slotInClosedTree) { + currentTargetHiddenSubtreeLevel--; + } + } + + let currentHiddenLevel = currentTargetHiddenSubtreeLevel; + let maxHiddenLevel = currentTargetHiddenSubtreeLevel; + + for (let i = currentTargetIndex - 1; i >= 0; i--) { + const { item, rootOfClosedTree, slotInClosedTree } = path[i]; + + if (rootOfClosedTree) { + currentHiddenLevel++; + } + + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.unshift(idlUtils.wrapperForImpl(item)); + } + + if (slotInClosedTree) { + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + } + + currentHiddenLevel = currentTargetHiddenSubtreeLevel; + maxHiddenLevel = currentTargetHiddenSubtreeLevel; + + for (let index = currentTargetIndex + 1; index < path.length; index++) { + const { item, rootOfClosedTree, slotInClosedTree } = path[index]; + + if (slotInClosedTree) { + currentHiddenLevel++; + } + + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.push(idlUtils.wrapperForImpl(item)); + } + + if (rootOfClosedTree) { + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + } + + return composedPath; + } + + _initialize(type, bubbles, cancelable) { + this.type = type; + this._initializedFlag = true; + + this._stopPropagationFlag = false; + this._stopImmediatePropagationFlag = false; + this._canceledFlag = false; + + this.isTrusted = false; + this.target = null; + this.bubbles = bubbles; + this.cancelable = cancelable; + } + + initEvent(type, bubbles, cancelable) { + if (this._dispatchFlag) { + return; + } + + this._initialize(type, bubbles, cancelable); + } +} +EventImpl.defaultInit = EventInit.convert(undefined, undefined); + +module.exports = { + implementation: EventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/EventModifierMixin-impl.js b/node_modules/jsdom/lib/jsdom/living/events/EventModifierMixin-impl.js new file mode 100644 index 00000000..4603eb9e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/EventModifierMixin-impl.js @@ -0,0 +1,18 @@ +"use strict"; + +// This mixin doesn't have an IDL equivalent, but since MouseEvent and KeyboardEvent implement getModifierState() the +// same way, its implementation is shared here. + +class EventModifierMixinImpl { + // Event's constructor assumes all options correspond to IDL attributes with the same names, and sets them on `this`. + // That is not the case for these modifier boolean options, but since the options are set on `this` anyway we'll + // access them that way. The spec doesn't say much about the case where keyArg is not one of the valid ones + // (https://w3c.github.io/uievents-key/#keys-modifier), but at least Chrome returns false for invalid modifiers. Since + // these invalid modifiers will be undefined on `this` (thus `false` after casting it to boolean), we don't need to do + // extra checking for validity. + getModifierState(keyArg) { + return Boolean(this[`modifier${keyArg}`]); + } +} + +exports.implementation = EventModifierMixinImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js b/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js new file mode 100644 index 00000000..1923e439 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js @@ -0,0 +1,419 @@ +"use strict"; +const DOMException = require("domexception/webidl2js-wrapper"); + +const reportException = require("../helpers/runtime-script-errors"); +const idlUtils = require("../generated/utils"); +const { nodeRoot } = require("../helpers/node"); +const { + isNode, isShadowRoot, isSlotable, getEventTargetParent, + isShadowInclusiveAncestor, retarget +} = require("../helpers/shadow-dom"); + +const MouseEvent = require("../generated/MouseEvent"); + +const EVENT_PHASE = { + NONE: 0, + CAPTURING_PHASE: 1, + AT_TARGET: 2, + BUBBLING_PHASE: 3 +}; + +class EventTargetImpl { + constructor(globalObject) { + this._globalObject = globalObject; + this._eventListeners = Object.create(null); + } + + addEventListener(type, callback, options) { + options = normalizeEventHandlerOptions(options, ["capture", "once", "passive"]); + + if (options.signal !== null && options.signal.aborted) { + return; + } + + if (callback === null) { + return; + } + + if (!this._eventListeners[type]) { + this._eventListeners[type] = []; + } + + for (let i = 0; i < this._eventListeners[type].length; ++i) { + const listener = this._eventListeners[type][i]; + if ( + listener.callback.objectReference === callback.objectReference && + listener.options.capture === options.capture + ) { + return; + } + } + + this._eventListeners[type].push({ + callback, + options + }); + + if (options.signal !== null) { + options.signal._addAlgorithm(() => { + this.removeEventListener(type, callback, options); + }); + } + } + + removeEventListener(type, callback, options) { + options = normalizeEventHandlerOptions(options, ["capture"]); + + if (callback === null) { + // Optimization, not in the spec. + return; + } + + if (!this._eventListeners[type]) { + return; + } + + for (let i = 0; i < this._eventListeners[type].length; ++i) { + const listener = this._eventListeners[type][i]; + if ( + listener.callback.objectReference === callback.objectReference && + listener.options.capture === options.capture + ) { + this._eventListeners[type].splice(i, 1); + break; + } + } + } + + dispatchEvent(eventImpl) { + if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) { + throw DOMException.create(this._globalObject, [ + "Tried to dispatch an uninitialized event", + "InvalidStateError" + ]); + } + if (eventImpl.eventPhase !== EVENT_PHASE.NONE) { + throw DOMException.create(this._globalObject, [ + "Tried to dispatch a dispatching event", + "InvalidStateError" + ]); + } + + eventImpl.isTrusted = false; + + return this._dispatch(eventImpl); + } + + // https://dom.spec.whatwg.org/#get-the-parent + _getTheParent() { + return null; + } + + // https://dom.spec.whatwg.org/#concept-event-dispatch + // legacyOutputDidListenersThrowFlag optional parameter is not necessary here since it is only used by indexDB. + _dispatch(eventImpl, legacyTargetOverrideFlag /* , legacyOutputDidListenersThrowFlag */) { + let targetImpl = this; + let clearTargets = false; + let activationTarget = null; + + eventImpl._dispatchFlag = true; + + const targetOverride = legacyTargetOverrideFlag ? + idlUtils.implForWrapper(targetImpl._globalObject._document) : + targetImpl; + let relatedTarget = retarget(eventImpl.relatedTarget, targetImpl); + + if (targetImpl !== relatedTarget || targetImpl === eventImpl.relatedTarget) { + const touchTargets = []; + + appendToEventPath(eventImpl, targetImpl, targetOverride, relatedTarget, touchTargets, false); + + const isActivationEvent = MouseEvent.isImpl(eventImpl) && eventImpl.type === "click"; + + if (isActivationEvent && targetImpl._hasActivationBehavior) { + activationTarget = targetImpl; + } + + let slotInClosedTree = false; + let slotable = isSlotable(targetImpl) && targetImpl._assignedSlot ? targetImpl : null; + let parent = getEventTargetParent(targetImpl, eventImpl); + + // Populate event path + // https://dom.spec.whatwg.org/#event-path + while (parent !== null) { + if (slotable !== null) { + if (parent.localName !== "slot") { + throw new Error(`JSDOM Internal Error: Expected parent to be a Slot`); + } + + slotable = null; + + const parentRoot = nodeRoot(parent); + if (isShadowRoot(parentRoot) && parentRoot.mode === "closed") { + slotInClosedTree = true; + } + } + + if (isSlotable(parent) && parent._assignedSlot) { + slotable = parent; + } + + relatedTarget = retarget(eventImpl.relatedTarget, parent); + + if ( + (isNode(parent) && isShadowInclusiveAncestor(nodeRoot(targetImpl), parent)) || + idlUtils.wrapperForImpl(parent).constructor.name === "Window" + ) { + if (isActivationEvent && eventImpl.bubbles && activationTarget === null && + parent._hasActivationBehavior) { + activationTarget = parent; + } + + appendToEventPath(eventImpl, parent, null, relatedTarget, touchTargets, slotInClosedTree); + } else if (parent === relatedTarget) { + parent = null; + } else { + targetImpl = parent; + + if (isActivationEvent && activationTarget === null && targetImpl._hasActivationBehavior) { + activationTarget = targetImpl; + } + + appendToEventPath(eventImpl, parent, targetImpl, relatedTarget, touchTargets, slotInClosedTree); + } + + if (parent !== null) { + parent = getEventTargetParent(parent, eventImpl); + } + + slotInClosedTree = false; + } + + let clearTargetsStructIndex = -1; + for (let i = eventImpl._path.length - 1; i >= 0 && clearTargetsStructIndex === -1; i--) { + if (eventImpl._path[i].target !== null) { + clearTargetsStructIndex = i; + } + } + const clearTargetsStruct = eventImpl._path[clearTargetsStructIndex]; + + clearTargets = + (isNode(clearTargetsStruct.target) && isShadowRoot(nodeRoot(clearTargetsStruct.target))) || + (isNode(clearTargetsStruct.relatedTarget) && isShadowRoot(nodeRoot(clearTargetsStruct.relatedTarget))); + + if (activationTarget !== null && activationTarget._legacyPreActivationBehavior) { + activationTarget._legacyPreActivationBehavior(); + } + + for (let i = eventImpl._path.length - 1; i >= 0; --i) { + const struct = eventImpl._path[i]; + + if (struct.target !== null) { + eventImpl.eventPhase = EVENT_PHASE.AT_TARGET; + } else { + eventImpl.eventPhase = EVENT_PHASE.CAPTURING_PHASE; + } + + invokeEventListeners(struct, eventImpl, "capturing"); + } + + for (let i = 0; i < eventImpl._path.length; i++) { + const struct = eventImpl._path[i]; + + if (struct.target !== null) { + eventImpl.eventPhase = EVENT_PHASE.AT_TARGET; + } else { + if (!eventImpl.bubbles) { + continue; + } + + eventImpl.eventPhase = EVENT_PHASE.BUBBLING_PHASE; + } + + invokeEventListeners(struct, eventImpl, "bubbling"); + } + } + + eventImpl.eventPhase = EVENT_PHASE.NONE; + + eventImpl.currentTarget = null; + eventImpl._path = []; + eventImpl._dispatchFlag = false; + eventImpl._stopPropagationFlag = false; + eventImpl._stopImmediatePropagationFlag = false; + + if (clearTargets) { + eventImpl.target = null; + eventImpl.relatedTarget = null; + } + + if (activationTarget !== null) { + if (!eventImpl._canceledFlag) { + activationTarget._activationBehavior(eventImpl); + } else if (activationTarget._legacyCanceledActivationBehavior) { + activationTarget._legacyCanceledActivationBehavior(); + } + } + + return !eventImpl._canceledFlag; + } +} + +module.exports = { + implementation: EventTargetImpl +}; + +// https://dom.spec.whatwg.org/#concept-event-listener-invoke +function invokeEventListeners(struct, eventImpl, phase) { + const structIndex = eventImpl._path.indexOf(struct); + for (let i = structIndex; i >= 0; i--) { + const t = eventImpl._path[i]; + if (t.target) { + eventImpl.target = t.target; + break; + } + } + + eventImpl.relatedTarget = idlUtils.wrapperForImpl(struct.relatedTarget); + + if (eventImpl._stopPropagationFlag) { + return; + } + + eventImpl.currentTarget = idlUtils.wrapperForImpl(struct.item); + + const listeners = struct.item._eventListeners; + innerInvokeEventListeners(eventImpl, listeners, phase, struct.itemInShadowTree); +} + +// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke +function innerInvokeEventListeners(eventImpl, listeners, phase, itemInShadowTree) { + let found = false; + + const { type, target } = eventImpl; + const wrapper = idlUtils.wrapperForImpl(target); + + if (!listeners || !listeners[type]) { + return found; + } + + // Copy event listeners before iterating since the list can be modified during the iteration. + const handlers = listeners[type].slice(); + + for (let i = 0; i < handlers.length; i++) { + const listener = handlers[i]; + const { capture, once, passive } = listener.options; + + // Check if the event listener has been removed since the listeners has been cloned. + if (!listeners[type].includes(listener)) { + continue; + } + + found = true; + + if ( + (phase === "capturing" && !capture) || + (phase === "bubbling" && capture) + ) { + continue; + } + + if (once) { + listeners[type].splice(listeners[type].indexOf(listener), 1); + } + + let window = null; + if (wrapper && wrapper._document) { + // Triggered by Window + window = wrapper; + } else if (target._ownerDocument) { + // Triggered by most webidl2js'ed instances + window = target._ownerDocument._defaultView; + } else if (wrapper._ownerDocument) { + // Currently triggered by some non-webidl2js things + window = wrapper._ownerDocument._defaultView; + } + + let currentEvent; + if (window) { + currentEvent = window._currentEvent; + if (!itemInShadowTree) { + window._currentEvent = eventImpl; + } + } + + if (passive) { + eventImpl._inPassiveListenerFlag = true; + } + + try { + listener.callback.call(eventImpl.currentTarget, eventImpl); + } catch (e) { + if (window) { + reportException(window, e); + } + // Errors in window-less documents just get swallowed... can you think of anything better? + } + + eventImpl._inPassiveListenerFlag = false; + + if (window) { + window._currentEvent = currentEvent; + } + + if (eventImpl._stopImmediatePropagationFlag) { + return found; + } + } + + return found; +} + +/** + * Normalize the event listeners options argument in order to get always a valid options object + * @param {Object} options - user defined options + * @param {Array} defaultBoolKeys - boolean properties that should belong to the options object + * @returns {Object} object containing at least the "defaultBoolKeys" + */ +function normalizeEventHandlerOptions(options, defaultBoolKeys) { + const returnValue = { signal: null }; + + // no need to go further here + if (typeof options === "boolean" || options === null || typeof options === "undefined") { + returnValue.capture = Boolean(options); + return returnValue; + } + + // non objects options so we typecast its value as "capture" value + if (typeof options !== "object") { + returnValue.capture = Boolean(options); + // at this point we don't need to loop the "capture" key anymore + defaultBoolKeys = defaultBoolKeys.filter(k => k !== "capture"); + } + + for (const key of defaultBoolKeys) { + returnValue[key] = Boolean(options[key]); + } + + if (options.signal !== undefined) { + returnValue.signal = options.signal; + } + + return returnValue; +} + +// https://dom.spec.whatwg.org/#concept-event-path-append +function appendToEventPath(eventImpl, target, targetOverride, relatedTarget, touchTargets, slotInClosedTree) { + const itemInShadowTree = isNode(target) && isShadowRoot(nodeRoot(target)); + const rootOfClosedTree = isShadowRoot(target) && target.mode === "closed"; + + eventImpl._path.push({ + item: target, + itemInShadowTree, + target: targetOverride, + relatedTarget, + touchTargets, + rootOfClosedTree, + slotInClosedTree + }); +} diff --git a/node_modules/jsdom/lib/jsdom/living/events/FocusEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/FocusEvent-impl.js new file mode 100644 index 00000000..561cbfc8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/FocusEvent-impl.js @@ -0,0 +1,9 @@ +"use strict"; +const UIEventImpl = require("./UIEvent-impl").implementation; + +const FocusEventInit = require("../generated/FocusEventInit"); + +class FocusEventImpl extends UIEventImpl {} +FocusEventImpl.defaultInit = FocusEventInit.convert(undefined, undefined); + +exports.implementation = FocusEventImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js new file mode 100644 index 00000000..8230e1d2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const HashChangeEventInit = require("../generated/HashChangeEventInit"); + +class HashChangeEventImpl extends EventImpl { + +} +HashChangeEventImpl.defaultInit = HashChangeEventInit.convert(undefined, undefined); + +module.exports = { + implementation: HashChangeEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js new file mode 100644 index 00000000..d9df3cdd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js @@ -0,0 +1,11 @@ +"use strict"; +const UIEventImpl = require("./UIEvent-impl").implementation; +const InputEventInit = require("../generated/InputEventInit"); + +// https://w3c.github.io/uievents/#interface-inputevent +class InputEventImpl extends UIEventImpl { } +InputEventImpl.defaultInit = InputEventInit.convert(undefined, undefined); + +module.exports = { + implementation: InputEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js new file mode 100644 index 00000000..c540e1ed --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js @@ -0,0 +1,29 @@ +"use strict"; + +const { mixin } = require("../../utils"); +const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation; +const UIEventImpl = require("./UIEvent-impl").implementation; + +const KeyboardEventInit = require("../generated/KeyboardEventInit"); + +class KeyboardEventImpl extends UIEventImpl { + initKeyboardEvent(type, bubbles, cancelable, view, key, location, ctrlKey, altKey, shiftKey, metaKey) { + if (this._dispatchFlag) { + return; + } + + this.initUIEvent(type, bubbles, cancelable, view, 0); + this.key = key; + this.location = location; + this.ctrlKey = ctrlKey; + this.altKey = altKey; + this.shiftKey = shiftKey; + this.metaKey = metaKey; + } +} +mixin(KeyboardEventImpl.prototype, EventModifierMixinImpl.prototype); +KeyboardEventImpl.defaultInit = KeyboardEventInit.convert(undefined, undefined); + +module.exports = { + implementation: KeyboardEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js new file mode 100644 index 00000000..0290fd4e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js @@ -0,0 +1,25 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const MessageEventInit = require("../generated/MessageEventInit"); + +class MessageEventImpl extends EventImpl { + initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.data = data; + this.origin = origin; + this.lastEventId = lastEventId; + this.source = source; + this.ports = ports; + } +} +MessageEventImpl.defaultInit = MessageEventInit.convert(undefined, undefined); + +module.exports = { + implementation: MessageEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js new file mode 100644 index 00000000..d8ba1cc7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js @@ -0,0 +1,49 @@ +"use strict"; + +const { mixin } = require("../../utils"); +const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation; +const UIEventImpl = require("./UIEvent-impl").implementation; + +const MouseEventInit = require("../generated/MouseEventInit"); + +class MouseEventImpl extends UIEventImpl { + initMouseEvent( + type, + bubbles, + cancelable, + view, + detail, + screenX, + screenY, + clientX, + clientY, + ctrlKey, + altKey, + shiftKey, + metaKey, + button, + relatedTarget + ) { + if (this._dispatchFlag) { + return; + } + + this.initUIEvent(type, bubbles, cancelable, view, detail); + this.screenX = screenX; + this.screenY = screenY; + this.clientX = clientX; + this.clientY = clientY; + this.ctrlKey = ctrlKey; + this.altKey = altKey; + this.shiftKey = shiftKey; + this.metaKey = metaKey; + this.button = button; + this.relatedTarget = relatedTarget; + } +} +mixin(MouseEventImpl.prototype, EventModifierMixinImpl.prototype); +MouseEventImpl.defaultInit = MouseEventInit.convert(undefined, undefined); + +module.exports = { + implementation: MouseEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js new file mode 100644 index 00000000..565f2469 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js @@ -0,0 +1,20 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const PageTransitionEventInit = require("../generated/PageTransitionEventInit"); + +// https://html.spec.whatwg.org/multipage/browsing-the-web.html#pagetransitionevent +class PageTransitionEventImpl extends EventImpl { + initPageTransitionEvent(type, bubbles, cancelable, persisted) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.persisted = persisted; + } +} +PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined, undefined); + +exports.implementation = PageTransitionEventImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/events/PopStateEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/PopStateEvent-impl.js new file mode 100644 index 00000000..a500201c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/PopStateEvent-impl.js @@ -0,0 +1,9 @@ +"use strict"; +const EventImpl = require("./Event-impl.js").implementation; + +const PopStateEventInit = require("../generated/PopStateEventInit"); + +class PopStateEventImpl extends EventImpl {} +PopStateEventImpl.defaultInit = PopStateEventInit.convert(undefined, undefined); + +exports.implementation = PopStateEventImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js new file mode 100644 index 00000000..59dcf033 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const ProgressEventInit = require("../generated/ProgressEventInit"); + +class ProgressEventImpl extends EventImpl { + +} +ProgressEventImpl.defaultInit = ProgressEventInit.convert(undefined, undefined); + +module.exports = { + implementation: ProgressEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/StorageEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/StorageEvent-impl.js new file mode 100644 index 00000000..9eb6c264 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/StorageEvent-impl.js @@ -0,0 +1,26 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const StorageEventInit = require("../generated/StorageEventInit"); + +// https://html.spec.whatwg.org/multipage/webstorage.html#the-storageevent-interface +class StorageEventImpl extends EventImpl { + initStorageEvent(type, bubbles, cancelable, key, oldValue, newValue, url, storageArea) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.key = key; + this.oldValue = oldValue; + this.newValue = newValue; + this.url = url; + this.storageArea = storageArea; + } +} +StorageEventImpl.defaultInit = StorageEventInit.convert(undefined, undefined); + +module.exports = { + implementation: StorageEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js new file mode 100644 index 00000000..623d20ca --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const UIEventImpl = require("./UIEvent-impl").implementation; + +const TouchEventInit = require("../generated/TouchEventInit"); + +class TouchEventImpl extends UIEventImpl { + +} +TouchEventImpl.defaultInit = TouchEventInit.convert(undefined, undefined); + +module.exports = { + implementation: TouchEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js new file mode 100644 index 00000000..b7a5960a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js @@ -0,0 +1,59 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); +const UIEventInit = require("../generated/UIEventInit"); +const EventImpl = require("./Event-impl").implementation; + +// Until webidl2js gains support for checking for Window, this would have to do. +function isWindow(val) { + if (typeof val !== "object") { + return false; + } + const wrapper = idlUtils.wrapperForImpl(val); + if (typeof wrapper === "object") { + return wrapper === wrapper._globalProxy; + } + + // `val` may be either impl or wrapper currently, because webidl2js currently unwraps Window objects (and their global + // proxies) to their underlying EventTargetImpl during conversion, which is not what we want. But at the same time, + // some internal usage call this constructor with the actual global proxy. + return isWindow(idlUtils.implForWrapper(val)); +} + +class UIEventImpl extends EventImpl { + constructor(globalObject, args, privateData) { + const eventInitDict = args[1]; + + // undefined check included so that we can omit the property in internal usage. + if (eventInitDict && eventInitDict.view !== null && eventInitDict.view !== undefined) { + if (!isWindow(eventInitDict.view)) { + throw new TypeError(`Failed to construct '${new.target.name.replace(/Impl$/, "")}': member view is not of ` + + "type Window."); + } + } + + super(globalObject, args, privateData); + } + + initUIEvent(type, bubbles, cancelable, view, detail) { + if (view !== null) { + if (!isWindow(view)) { + throw new TypeError(`Failed to execute 'initUIEvent' on '${this.constructor.name.replace(/Impl$/, "")}': ` + + "parameter 4 is not of type 'Window'."); + } + } + + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.view = view; + this.detail = detail; + } +} +UIEventImpl.defaultInit = UIEventInit.convert(undefined, undefined); + +module.exports = { + implementation: UIEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/events/WheelEvent-impl.js b/node_modules/jsdom/lib/jsdom/living/events/WheelEvent-impl.js new file mode 100644 index 00000000..c8ba8824 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/events/WheelEvent-impl.js @@ -0,0 +1,12 @@ +"use strict"; + +const MouseEventImpl = require("./MouseEvent-impl").implementation; + +const WheelEventInit = require("../generated/WheelEventInit"); + +class WheelEventImpl extends MouseEventImpl {} +WheelEventImpl.defaultInit = WheelEventInit.convert(undefined, undefined); + +module.exports = { + implementation: WheelEventImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/fetch/Headers-impl.js b/node_modules/jsdom/lib/jsdom/living/fetch/Headers-impl.js new file mode 100644 index 00000000..4330cbfa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/fetch/Headers-impl.js @@ -0,0 +1,170 @@ +"use strict"; + +const { + isForbidden, + isForbiddenResponse, + isPrivilegedNoCORSRequest, + isNoCORSSafelistedRequest, + isCORSWhitelisted +} = require("./header-types"); +const HeaderList = require("./header-list"); + +function assertName(name) { + if (!name.match(/^[!#$%&'*+\-.^`|~\w]+$/)) { + throw new TypeError("name is invalid"); + } +} + +function assertValue(value) { + if (value.match(/[\0\r\n]/)) { + throw new TypeError("value is invalid"); + } +} + +// https://fetch.spec.whatwg.org/#concept-header-value-normalize +function normalizeValue(potentialValue) { + return potentialValue.replace(/^[\n\r\t ]+|[\n\r\t ]+$/g, ""); +} + +class HeadersImpl { + constructor(globalObject, args) { + this.guard = "none"; + this.headersList = new HeaderList(); + + if (args[0]) { + this._fill(args[0]); + } + } + + _fill(init) { + if (Array.isArray(init)) { + for (const header of init) { + if (header.length !== 2) { + throw new TypeError("init is invalid"); + } + this.append(header[0], header[1]); + } + } else { + for (const key of Object.keys(init)) { + this.append(key, init[key]); + } + } + } + + has(name) { + assertName(name); + return this.headersList.contains(name); + } + + get(name) { + assertName(name); + return this.headersList.get(name); + } + + _removePrivilegedNoCORSHeaders() { + this.headersList.delete("range"); + } + + append(name, value) { + value = normalizeValue(value); + assertName(name); + assertValue(value); + + switch (this.guard) { + case "immutable": + throw new TypeError("Headers is immutable"); + case "request": + if (isForbidden(name)) { + return; + } + break; + case "request-no-cors": { + let temporaryValue = this.get(name); + if (temporaryValue === null) { + temporaryValue = value; + } else { + temporaryValue += `, ${value}`; + } + if (!isCORSWhitelisted(name, value)) { + return; + } + break; + } + case "response": + if (isForbiddenResponse(name)) { + return; + } + break; + } + + this.headersList.append(name, value); + this._removePrivilegedNoCORSHeaders(); + } + + set(name, value) { + value = normalizeValue(value); + assertName(name); + assertValue(value); + + switch (this.guard) { + case "immutable": + throw new TypeError("Headers is immutable"); + case "request": + if (isForbidden(name)) { + return; + } + break; + case "request-no-cors": { + if (!isCORSWhitelisted(name, value)) { + return; + } + break; + } + case "response": + if (isForbiddenResponse(name)) { + return; + } + break; + } + this.headersList.set(name, value); + this._removePrivilegedNoCORSHeaders(); + } + + delete(name) { + assertName(name); + + switch (this.guard) { + case "immutable": + throw new TypeError("Headers is immutable"); + case "request": + if (isForbidden(name)) { + return; + } + break; + case "request-no-cors": { + if ( + !isNoCORSSafelistedRequest(name) && + !isPrivilegedNoCORSRequest(name) + ) { + return; + } + break; + } + case "response": + if (isForbiddenResponse(name)) { + return; + } + break; + } + this.headersList.delete(name); + this._removePrivilegedNoCORSHeaders(); + } + + * [Symbol.iterator]() { + for (const header of this.headersList.sortAndCombine()) { + yield header; + } + } +} + +exports.implementation = HeadersImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/fetch/header-list.js b/node_modules/jsdom/lib/jsdom/living/fetch/header-list.js new file mode 100644 index 00000000..b8afa286 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/fetch/header-list.js @@ -0,0 +1,54 @@ +"use strict"; + +/** + * Provides some utility functions for somewhat efficiently modifying a + * collection of headers. + * + * Note that this class only operates on ByteStrings (which is also why we use + * toLowerCase internally). + */ +class HeaderList { + constructor() { + this.headers = new Map(); + } + + append(name, value) { + const existing = this.headers.get(name.toLowerCase()); + if (existing) { + name = existing[0].name; + existing.push({ name, value }); + } else { + this.headers.set(name.toLowerCase(), [{ name, value }]); + } + } + + contains(name) { + return this.headers.has(name.toLowerCase()); + } + + get(name) { + name = name.toLowerCase(); + const values = this.headers.get(name); + if (!values) { + return null; + } + return values.map(h => h.value).join(", "); + } + + delete(name) { + this.headers.delete(name.toLowerCase()); + } + + set(name, value) { + const lowerName = name.toLowerCase(); + this.headers.delete(lowerName); + this.headers.set(lowerName, [{ name, value }]); + } + + sortAndCombine() { + const names = [...this.headers.keys()].sort(); + return names.map(n => [n, this.get(n)]); + } +} + +module.exports = HeaderList; diff --git a/node_modules/jsdom/lib/jsdom/living/fetch/header-types.js b/node_modules/jsdom/lib/jsdom/living/fetch/header-types.js new file mode 100644 index 00000000..ac3637d2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/fetch/header-types.js @@ -0,0 +1,103 @@ +"use strict"; + +const MIMEType = require("whatwg-mimetype"); + +const PRIVILEGED_NO_CORS_REQUEST = new Set(["range"]); +function isPrivilegedNoCORSRequest(name) { + return PRIVILEGED_NO_CORS_REQUEST.has(name.toLowerCase()); +} + +const NO_CORS_SAFELISTED_REQUEST = new Set([ + `accept`, + `accept-language`, + `content-language`, + `content-type` +]); +function isNoCORSSafelistedRequest(name) { + return NO_CORS_SAFELISTED_REQUEST.has(name.toLowerCase()); +} + +const FORBIDDEN = new Set([ + `accept-charset`, + `accept-encoding`, + `access-control-request-headers`, + `access-control-request-method`, + `connection`, + `content-length`, + `cookie`, + `cookie2`, + `date`, + `dnt`, + `expect`, + `host`, + `keep-alive`, + `origin`, + `referer`, + `te`, + `trailer`, + `transfer-encoding`, + `upgrade`, + `via` +]); +function isForbidden(name) { + name = name.toLowerCase(); + return ( + FORBIDDEN.has(name) || name.startsWith("proxy-") || name.startsWith("sec-") + ); +} + +const FORBIDDEN_RESPONSE = new Set(["set-cookie", "set-cookie2"]); +function isForbiddenResponse(name) { + return FORBIDDEN_RESPONSE.has(name.toLowerCase()); +} + +const CORS_UNSAFE_BYTE = /[\x00-\x08\x0A-\x1F"():<>?@[\\\]{}\x7F]/; +function isCORSWhitelisted(name, value) { + name = name.toLowerCase(); + switch (name) { + case "accept": + if (value.match(CORS_UNSAFE_BYTE)) { + return false; + } + break; + case "accept-language": + case "content-language": + if (value.match(/[^\x30-\x39\x41-\x5A\x61-\x7A *,\-.;=]/)) { + return false; + } + break; + case "content-type": { + if (value.match(CORS_UNSAFE_BYTE)) { + return false; + } + const mimeType = MIMEType.parse(value); + if (mimeType === null) { + return false; + } + if ( + ![ + "application/x-www-form-urlencoded", + "multipart/form-data", + "text/plain" + ].includes(mimeType.essence) + ) { + return false; + } + break; + } + default: + return false; + } + if (Buffer.from(value).length > 128) { + return false; + } + return true; +} + +module.exports = { + isPrivilegedNoCORSRequest, + isNoCORSSafelistedRequest, + isForbidden, + isForbiddenResponse, + isCORSWhitelisted +}; diff --git a/node_modules/jsdom/lib/jsdom/living/file-api/Blob-impl.js b/node_modules/jsdom/lib/jsdom/living/file-api/Blob-impl.js new file mode 100644 index 00000000..02cc09f6 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/file-api/Blob-impl.js @@ -0,0 +1,93 @@ +"use strict"; +const Blob = require("../generated/Blob"); +const { isArrayBuffer } = require("../generated/utils"); + +function convertLineEndingsToNative(s) { + // jsdom always pretends to be *nix, for consistency. + // See also https://github.com/jsdom/jsdom/issues/2396. + return s.replace(/\r\n|\r|\n/g, "\n"); +} + +exports.implementation = class BlobImpl { + constructor(globalObject, args) { + const parts = args[0]; + const properties = args[1]; + + const buffers = []; + + if (parts !== undefined) { + for (const part of parts) { + let buffer; + if (isArrayBuffer(part)) { + buffer = Buffer.from(part); + } else if (ArrayBuffer.isView(part)) { + buffer = Buffer.from(part.buffer, part.byteOffset, part.byteLength); + } else if (Blob.isImpl(part)) { + buffer = part._buffer; + } else { + let s = part; + if (properties.endings === "native") { + s = convertLineEndingsToNative(part); + } + buffer = Buffer.from(s); + } + buffers.push(buffer); + } + } + + this._buffer = Buffer.concat(buffers); + this._globalObject = globalObject; + + this.type = properties.type; + if (/[^\u0020-\u007E]/.test(this.type)) { + this.type = ""; + } else { + this.type = this.type.toLowerCase(); + } + } + + get size() { + return this._buffer.length; + } + + slice(start, end, contentType) { + const { size } = this; + + let relativeStart, relativeEnd, relativeContentType; + + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + + if (contentType === undefined) { + relativeContentType = ""; + } else { + // sanitization (lower case and invalid char check) is done in the + // constructor + relativeContentType = contentType; + } + + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this._buffer; + const slicedBuffer = buffer.slice( + relativeStart, + relativeStart + span + ); + + const blob = Blob.createImpl(this._globalObject, [[], { type: relativeContentType }], {}); + blob._buffer = slicedBuffer; + return blob; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/file-api/File-impl.js b/node_modules/jsdom/lib/jsdom/living/file-api/File-impl.js new file mode 100644 index 00000000..911faaf1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/file-api/File-impl.js @@ -0,0 +1,12 @@ +"use strict"; + +const BlobImpl = require("./Blob-impl").implementation; + +exports.implementation = class FileImpl extends BlobImpl { + constructor(globalObject, [fileBits, fileName, options], privateData) { + super(globalObject, [fileBits, options], privateData); + + this.name = fileName; + this.lastModified = "lastModified" in options ? options.lastModified : Date.now(); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/file-api/FileList-impl.js b/node_modules/jsdom/lib/jsdom/living/file-api/FileList-impl.js new file mode 100644 index 00000000..04eedcbc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/file-api/FileList-impl.js @@ -0,0 +1,15 @@ +"use strict"; + +const idlUtils = require("../generated/utils.js"); + +exports.implementation = class FileListImpl extends Array { + constructor() { + super(0); + } + item(index) { + return this[index] || null; + } + get [idlUtils.supportedPropertyIndices]() { + return this.keys(); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/file-api/FileReader-impl.js b/node_modules/jsdom/lib/jsdom/living/file-api/FileReader-impl.js new file mode 100644 index 00000000..9ade8939 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/file-api/FileReader-impl.js @@ -0,0 +1,130 @@ +"use strict"; + +const whatwgEncoding = require("whatwg-encoding"); +const MIMEType = require("whatwg-mimetype"); +const DOMException = require("domexception/webidl2js-wrapper"); +const EventTargetImpl = require("../events/EventTarget-impl").implementation; +const ProgressEvent = require("../generated/ProgressEvent"); +const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor"); +const { fireAnEvent } = require("../helpers/events"); +const { copyToArrayBufferInNewRealm } = require("../helpers/binary-data"); + +const READY_STATES = Object.freeze({ + EMPTY: 0, + LOADING: 1, + DONE: 2 +}); + +const events = ["loadstart", "progress", "load", "abort", "error", "loadend"]; + +class FileReaderImpl extends EventTargetImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this.error = null; + this.readyState = READY_STATES.EMPTY; + this.result = null; + + this._globalObject = globalObject; + this._ownerDocument = globalObject.document; + this._terminated = false; + } + + readAsArrayBuffer(file) { + this._readFile(file, "buffer"); + } + readAsBinaryString(file) { + this._readFile(file, "binaryString"); + } + readAsDataURL(file) { + this._readFile(file, "dataURL"); + } + readAsText(file, encoding) { + this._readFile(file, "text", whatwgEncoding.labelToName(encoding) || "UTF-8"); + } + + abort() { + if (this.readyState === READY_STATES.EMPTY || this.readyState === READY_STATES.DONE) { + this.result = null; + return; + } + + if (this.readyState === READY_STATES.LOADING) { + this.readyState = READY_STATES.DONE; + this.result = null; + } + + this._terminated = true; + this._fireProgressEvent("abort"); + this._fireProgressEvent("loadend"); + } + + _fireProgressEvent(name, props) { + fireAnEvent(name, this, ProgressEvent, props); + } + + _readFile(file, format, encoding) { + if (this.readyState === READY_STATES.LOADING) { + throw DOMException.create(this._globalObject, [ + "The object is in an invalid state.", + "InvalidStateError" + ]); + } + + this.readyState = READY_STATES.LOADING; + + setImmediate(() => { + if (this._terminated) { + this._terminated = false; + return; + } + + this._fireProgressEvent("loadstart"); + + let data = file._buffer; + if (!data) { + data = Buffer.alloc(0); + } + this._fireProgressEvent("progress", { + lengthComputable: !isNaN(file.size), + total: file.size, + loaded: data.length + }); + + setImmediate(() => { + if (this._terminated) { + this._terminated = false; + return; + } + + switch (format) { + case "binaryString": { + this.result = data.toString("binary"); + break; + } + case "dataURL": { + // Spec seems very unclear here; see https://github.com/w3c/FileAPI/issues/104. + const contentType = MIMEType.parse(file.type) || "application/octet-stream"; + this.result = `data:${contentType};base64,${data.toString("base64")}`; + break; + } + case "text": { + this.result = whatwgEncoding.decode(data, encoding); + break; + } + case "buffer": + default: { + this.result = copyToArrayBufferInNewRealm(data, this._globalObject); + break; + } + } + this.readyState = READY_STATES.DONE; + this._fireProgressEvent("load"); + this._fireProgressEvent("loadend"); + }); + }); + } +} +setupForSimpleEventAccessors(FileReaderImpl.prototype, events); + +exports.implementation = FileReaderImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/AbortController.js b/node_modules/jsdom/lib/jsdom/living/generated/AbortController.js new file mode 100644 index 00000000..6b020eab --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/AbortController.js @@ -0,0 +1,143 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "AbortController"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'AbortController'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["AbortController"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class AbortController { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + abort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'abort' called on an object that is not a valid instance of AbortController." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["any"](curArg, { + context: "Failed to execute 'abort' on 'AbortController': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].abort(...args); + } + + get signal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get signal' called on an object that is not a valid instance of AbortController." + ); + } + + return utils.getSameObject(this, "signal", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["signal"]); + }); + } + } + Object.defineProperties(AbortController.prototype, { + abort: { enumerable: true }, + signal: { enumerable: true }, + [Symbol.toStringTag]: { value: "AbortController", configurable: true } + }); + ctorRegistry[interfaceName] = AbortController; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: AbortController + }); +}; + +const Impl = require("../aborting/AbortController-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js b/node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js new file mode 100644 index 00000000..c3362230 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js @@ -0,0 +1,184 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "AbortSignal"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'AbortSignal'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["AbortSignal"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class AbortSignal extends globalObject.EventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get aborted() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get aborted' called on an object that is not a valid instance of AbortSignal." + ); + } + + return esValue[implSymbol]["aborted"]; + } + + get reason() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get reason' called on an object that is not a valid instance of AbortSignal." + ); + } + + return esValue[implSymbol]["reason"]; + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of AbortSignal." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of AbortSignal." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'AbortSignal': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + static abort() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["any"](curArg, { + context: "Failed to execute 'abort' on 'AbortSignal': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(Impl.implementation.abort(globalObject, ...args)); + } + } + Object.defineProperties(AbortSignal.prototype, { + aborted: { enumerable: true }, + reason: { enumerable: true }, + onabort: { enumerable: true }, + [Symbol.toStringTag]: { value: "AbortSignal", configurable: true } + }); + Object.defineProperties(AbortSignal, { abort: { enumerable: true } }); + ctorRegistry[interfaceName] = AbortSignal; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: AbortSignal + }); +}; + +const Impl = require("../aborting/AbortSignal-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/AbstractRange.js b/node_modules/jsdom/lib/jsdom/living/generated/AbstractRange.js new file mode 100644 index 00000000..19f96a77 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/AbstractRange.js @@ -0,0 +1,171 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "AbstractRange"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'AbstractRange'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["AbstractRange"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class AbstractRange { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get startContainer() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get startContainer' called on an object that is not a valid instance of AbstractRange." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["startContainer"]); + } + + get startOffset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get startOffset' called on an object that is not a valid instance of AbstractRange." + ); + } + + return esValue[implSymbol]["startOffset"]; + } + + get endContainer() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get endContainer' called on an object that is not a valid instance of AbstractRange." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["endContainer"]); + } + + get endOffset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get endOffset' called on an object that is not a valid instance of AbstractRange." + ); + } + + return esValue[implSymbol]["endOffset"]; + } + + get collapsed() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get collapsed' called on an object that is not a valid instance of AbstractRange." + ); + } + + return esValue[implSymbol]["collapsed"]; + } + } + Object.defineProperties(AbstractRange.prototype, { + startContainer: { enumerable: true }, + startOffset: { enumerable: true }, + endContainer: { enumerable: true }, + endOffset: { enumerable: true }, + collapsed: { enumerable: true }, + [Symbol.toStringTag]: { value: "AbstractRange", configurable: true } + }); + ctorRegistry[interfaceName] = AbstractRange; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: AbstractRange + }); +}; + +const Impl = require("../range/AbstractRange-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/AddEventListenerOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/AddEventListenerOptions.js new file mode 100644 index 00000000..c45f1f67 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/AddEventListenerOptions.js @@ -0,0 +1,55 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const AbortSignal = require("./AbortSignal.js"); +const EventListenerOptions = require("./EventListenerOptions.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventListenerOptions._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "once"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'once' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "passive"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'passive' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "signal"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = AbortSignal.convert(globalObject, value, { context: context + " has member 'signal' that" }); + + ret[key] = value; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/AssignedNodesOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/AssignedNodesOptions.js new file mode 100644 index 00000000..6a68e093 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/AssignedNodesOptions.js @@ -0,0 +1,28 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "flatten"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'flatten' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Attr.js b/node_modules/jsdom/lib/jsdom/living/generated/Attr.js new file mode 100644 index 00000000..9d17287c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Attr.js @@ -0,0 +1,217 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Node = require("./Node.js"); + +const interfaceName = "Attr"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Attr'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Attr"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Node._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Attr extends globalObject.Node { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get namespaceURI() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get namespaceURI' called on an object that is not a valid instance of Attr." + ); + } + + return esValue[implSymbol]["namespaceURI"]; + } + + get prefix() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get prefix' called on an object that is not a valid instance of Attr."); + } + + return esValue[implSymbol]["prefix"]; + } + + get localName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get localName' called on an object that is not a valid instance of Attr."); + } + + return esValue[implSymbol]["localName"]; + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of Attr."); + } + + return esValue[implSymbol]["name"]; + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get value' called on an object that is not a valid instance of Attr."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set value' called on an object that is not a valid instance of Attr."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'Attr': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get ownerElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ownerElement' called on an object that is not a valid instance of Attr." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ownerElement"]); + } + + get specified() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get specified' called on an object that is not a valid instance of Attr."); + } + + return esValue[implSymbol]["specified"]; + } + } + Object.defineProperties(Attr.prototype, { + namespaceURI: { enumerable: true }, + prefix: { enumerable: true }, + localName: { enumerable: true }, + name: { enumerable: true }, + value: { enumerable: true }, + ownerElement: { enumerable: true }, + specified: { enumerable: true }, + [Symbol.toStringTag]: { value: "Attr", configurable: true } + }); + ctorRegistry[interfaceName] = Attr; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Attr + }); +}; + +const Impl = require("../attributes/Attr-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/BarProp.js b/node_modules/jsdom/lib/jsdom/living/generated/BarProp.js new file mode 100644 index 00000000..d7262560 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/BarProp.js @@ -0,0 +1,117 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "BarProp"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'BarProp'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["BarProp"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class BarProp { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get visible() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get visible' called on an object that is not a valid instance of BarProp."); + } + + return esValue[implSymbol]["visible"]; + } + } + Object.defineProperties(BarProp.prototype, { + visible: { enumerable: true }, + [Symbol.toStringTag]: { value: "BarProp", configurable: true } + }); + ctorRegistry[interfaceName] = BarProp; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: BarProp + }); +}; + +const Impl = require("../window/BarProp-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/BinaryType.js b/node_modules/jsdom/lib/jsdom/living/generated/BinaryType.js new file mode 100644 index 00000000..72fb5740 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/BinaryType.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["blob", "arraybuffer"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for BinaryType`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Blob.js b/node_modules/jsdom/lib/jsdom/living/generated/Blob.js new file mode 100644 index 00000000..bc3bf6ab --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Blob.js @@ -0,0 +1,203 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const BlobPropertyBag = require("./BlobPropertyBag.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Blob"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Blob'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Blob"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Blob { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError("Failed to construct 'Blob': parameter 1" + " is not an iterable object."); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + if (exports.is(nextItem)) { + nextItem = utils.implForWrapper(nextItem); + } else if (utils.isArrayBuffer(nextItem)) { + } else if (ArrayBuffer.isView(nextItem)) { + } else { + nextItem = conversions["USVString"](nextItem, { + context: "Failed to construct 'Blob': parameter 1" + "'s element", + globals: globalObject + }); + } + V.push(nextItem); + } + curArg = V; + } + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = BlobPropertyBag.convert(globalObject, curArg, { context: "Failed to construct 'Blob': parameter 2" }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + slice() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'slice' called on an object that is not a valid instance of Blob."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long long"](curArg, { + context: "Failed to execute 'slice' on 'Blob': parameter 1", + globals: globalObject, + clamp: true + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["long long"](curArg, { + context: "Failed to execute 'slice' on 'Blob': parameter 2", + globals: globalObject, + clamp: true + }); + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'slice' on 'Blob': parameter 3", + globals: globalObject + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].slice(...args)); + } + + get size() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get size' called on an object that is not a valid instance of Blob."); + } + + return esValue[implSymbol]["size"]; + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Blob."); + } + + return esValue[implSymbol]["type"]; + } + } + Object.defineProperties(Blob.prototype, { + slice: { enumerable: true }, + size: { enumerable: true }, + type: { enumerable: true }, + [Symbol.toStringTag]: { value: "Blob", configurable: true } + }); + ctorRegistry[interfaceName] = Blob; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Blob + }); +}; + +const Impl = require("../file-api/Blob-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/BlobCallback.js b/node_modules/jsdom/lib/jsdom/living/generated/BlobCallback.js new file mode 100644 index 00000000..a302a40e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/BlobCallback.js @@ -0,0 +1,30 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (typeof value !== "function") { + throw new globalObject.TypeError(context + " is not a function"); + } + + function invokeTheCallbackFunction(blob) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + blob = utils.tryWrapperForImpl(blob); + + callResult = Reflect.apply(value, thisArg, [blob]); + } + + invokeTheCallbackFunction.construct = blob => { + blob = utils.tryWrapperForImpl(blob); + + let callResult = Reflect.construct(value, [blob]); + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/BlobPropertyBag.js b/node_modules/jsdom/lib/jsdom/living/generated/BlobPropertyBag.js new file mode 100644 index 00000000..fc202113 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/BlobPropertyBag.js @@ -0,0 +1,42 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EndingType = require("./EndingType.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "endings"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = EndingType.convert(globalObject, value, { context: context + " has member 'endings' that" }); + + ret[key] = value; + } else { + ret[key] = "transparent"; + } + } + + { + const key = "type"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { context: context + " has member 'type' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js b/node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js new file mode 100644 index 00000000..ff076de3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Text = require("./Text.js"); + +const interfaceName = "CDATASection"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'CDATASection'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["CDATASection"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Text._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class CDATASection extends globalObject.Text { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(CDATASection.prototype, { + [Symbol.toStringTag]: { value: "CDATASection", configurable: true } + }); + ctorRegistry[interfaceName] = CDATASection; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CDATASection + }); +}; + +const Impl = require("../nodes/CDATASection-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CanPlayTypeResult.js b/node_modules/jsdom/lib/jsdom/living/generated/CanPlayTypeResult.js new file mode 100644 index 00000000..2ebe3834 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CanPlayTypeResult.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["", "maybe", "probably"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for CanPlayTypeResult`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CharacterData.js b/node_modules/jsdom/lib/jsdom/living/generated/CharacterData.js new file mode 100644 index 00000000..69eac3f2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CharacterData.js @@ -0,0 +1,453 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "CharacterData"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'CharacterData'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["CharacterData"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Node._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class CharacterData extends globalObject.Node { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + substringData(offset, count) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'substringData' called on an object that is not a valid instance of CharacterData." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'substringData' on 'CharacterData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'substringData' on 'CharacterData': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].substringData(...args); + } + + appendData(data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'appendData' called on an object that is not a valid instance of CharacterData." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'appendData' on 'CharacterData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].appendData(...args); + } + + insertData(offset, data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertData' called on an object that is not a valid instance of CharacterData." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'insertData' on 'CharacterData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertData' on 'CharacterData': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].insertData(...args); + } + + deleteData(offset, count) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteData' called on an object that is not a valid instance of CharacterData." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'deleteData' on 'CharacterData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'deleteData' on 'CharacterData': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].deleteData(...args); + } + + replaceData(offset, count, data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceData' called on an object that is not a valid instance of CharacterData." + ); + } + + if (arguments.length < 3) { + throw new globalObject.TypeError( + `Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'replaceData' on 'CharacterData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'replaceData' on 'CharacterData': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceData' on 'CharacterData': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].replaceData(...args); + } + + before() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'before' called on an object that is not a valid instance of CharacterData."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'before' on 'CharacterData': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].before(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + after() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'after' called on an object that is not a valid instance of CharacterData."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'after' on 'CharacterData': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].after(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceWith() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceWith' called on an object that is not a valid instance of CharacterData." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceWith' on 'CharacterData': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replaceWith(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + remove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of CharacterData."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].remove(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get data() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get data' called on an object that is not a valid instance of CharacterData." + ); + } + + return esValue[implSymbol]["data"]; + } + + set data(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set data' called on an object that is not a valid instance of CharacterData." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'data' property on 'CharacterData': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + esValue[implSymbol]["data"] = V; + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of CharacterData." + ); + } + + return esValue[implSymbol]["length"]; + } + + get previousElementSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get previousElementSibling' called on an object that is not a valid instance of CharacterData." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["previousElementSibling"]); + } + + get nextElementSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get nextElementSibling' called on an object that is not a valid instance of CharacterData." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["nextElementSibling"]); + } + } + Object.defineProperties(CharacterData.prototype, { + substringData: { enumerable: true }, + appendData: { enumerable: true }, + insertData: { enumerable: true }, + deleteData: { enumerable: true }, + replaceData: { enumerable: true }, + before: { enumerable: true }, + after: { enumerable: true }, + replaceWith: { enumerable: true }, + remove: { enumerable: true }, + data: { enumerable: true }, + length: { enumerable: true }, + previousElementSibling: { enumerable: true }, + nextElementSibling: { enumerable: true }, + [Symbol.toStringTag]: { value: "CharacterData", configurable: true }, + [Symbol.unscopables]: { + value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null }, + configurable: true + } + }); + ctorRegistry[interfaceName] = CharacterData; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CharacterData + }); +}; + +const Impl = require("../nodes/CharacterData-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CloseEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/CloseEvent.js new file mode 100644 index 00000000..ee3e913e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CloseEvent.js @@ -0,0 +1,168 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const CloseEventInit = require("./CloseEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "CloseEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'CloseEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["CloseEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class CloseEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'CloseEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'CloseEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = CloseEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'CloseEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get wasClean() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get wasClean' called on an object that is not a valid instance of CloseEvent." + ); + } + + return esValue[implSymbol]["wasClean"]; + } + + get code() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get code' called on an object that is not a valid instance of CloseEvent."); + } + + return esValue[implSymbol]["code"]; + } + + get reason() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get reason' called on an object that is not a valid instance of CloseEvent." + ); + } + + return esValue[implSymbol]["reason"]; + } + } + Object.defineProperties(CloseEvent.prototype, { + wasClean: { enumerable: true }, + code: { enumerable: true }, + reason: { enumerable: true }, + [Symbol.toStringTag]: { value: "CloseEvent", configurable: true } + }); + ctorRegistry[interfaceName] = CloseEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CloseEvent + }); +}; + +const Impl = require("../events/CloseEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CloseEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/CloseEventInit.js new file mode 100644 index 00000000..afdb65b2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CloseEventInit.js @@ -0,0 +1,65 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "code"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned short"](value, { + context: context + " has member 'code' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "reason"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { + context: context + " has member 'reason' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "wasClean"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'wasClean' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Comment.js b/node_modules/jsdom/lib/jsdom/living/generated/Comment.js new file mode 100644 index 00000000..b8644da4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Comment.js @@ -0,0 +1,120 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const CharacterData = require("./CharacterData.js"); + +const interfaceName = "Comment"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Comment'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Comment"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + CharacterData._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Comment extends globalObject.CharacterData { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'Comment': parameter 1", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + } + Object.defineProperties(Comment.prototype, { [Symbol.toStringTag]: { value: "Comment", configurable: true } }); + ctorRegistry[interfaceName] = Comment; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Comment + }); +}; + +const Impl = require("../nodes/Comment-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CompositionEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/CompositionEvent.js new file mode 100644 index 00000000..6b594d19 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CompositionEvent.js @@ -0,0 +1,219 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const CompositionEventInit = require("./CompositionEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "CompositionEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'CompositionEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["CompositionEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class CompositionEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'CompositionEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'CompositionEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = CompositionEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'CompositionEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initCompositionEvent(typeArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initCompositionEvent' called on an object that is not a valid instance of CompositionEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initCompositionEvent' on 'CompositionEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initCompositionEvent' on 'CompositionEvent': parameter 5", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + return esValue[implSymbol].initCompositionEvent(...args); + } + + get data() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get data' called on an object that is not a valid instance of CompositionEvent." + ); + } + + return esValue[implSymbol]["data"]; + } + } + Object.defineProperties(CompositionEvent.prototype, { + initCompositionEvent: { enumerable: true }, + data: { enumerable: true }, + [Symbol.toStringTag]: { value: "CompositionEvent", configurable: true } + }); + ctorRegistry[interfaceName] = CompositionEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CompositionEvent + }); +}; + +const Impl = require("../events/CompositionEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CompositionEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/CompositionEventInit.js new file mode 100644 index 00000000..e9d9c1d4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CompositionEventInit.js @@ -0,0 +1,32 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const UIEventInit = require("./UIEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + UIEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "data"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { context: context + " has member 'data' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Crypto.js b/node_modules/jsdom/lib/jsdom/living/generated/Crypto.js new file mode 100644 index 00000000..7b93e560 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Crypto.js @@ -0,0 +1,134 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Crypto"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Crypto'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Crypto"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Crypto { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + getRandomValues(array) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getRandomValues' called on an object that is not a valid instance of Crypto." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getRandomValues' on 'Crypto': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + } else { + throw new globalObject.TypeError( + "Failed to execute 'getRandomValues' on 'Crypto': parameter 1" + " is not of any supported type." + ); + } + args.push(curArg); + } + return esValue[implSymbol].getRandomValues(...args); + } + } + Object.defineProperties(Crypto.prototype, { + getRandomValues: { enumerable: true }, + [Symbol.toStringTag]: { value: "Crypto", configurable: true } + }); + ctorRegistry[interfaceName] = Crypto; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Crypto + }); +}; + +const Impl = require("../crypto/Crypto-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CustomElementConstructor.js b/node_modules/jsdom/lib/jsdom/living/generated/CustomElementConstructor.js new file mode 100644 index 00000000..7fac7e0b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CustomElementConstructor.js @@ -0,0 +1,34 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (typeof value !== "function") { + throw new globalObject.TypeError(context + " is not a function"); + } + + function invokeTheCallbackFunction() { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + callResult = Reflect.apply(value, thisArg, []); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + } + + invokeTheCallbackFunction.construct = () => { + let callResult = Reflect.construct(value, []); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CustomElementRegistry.js b/node_modules/jsdom/lib/jsdom/living/generated/CustomElementRegistry.js new file mode 100644 index 00000000..32fd4dfe --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CustomElementRegistry.js @@ -0,0 +1,242 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const CustomElementConstructor = require("./CustomElementConstructor.js"); +const ElementDefinitionOptions = require("./ElementDefinitionOptions.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const Node = require("./Node.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "CustomElementRegistry"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'CustomElementRegistry'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["CustomElementRegistry"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class CustomElementRegistry { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + define(name, constructor) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'define' called on an object that is not a valid instance of CustomElementRegistry." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'define' on 'CustomElementRegistry': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = CustomElementConstructor.convert(globalObject, curArg, { + context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 2" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = ElementDefinitionOptions.convert(globalObject, curArg, { + context: "Failed to execute 'define' on 'CustomElementRegistry': parameter 3" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].define(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get' called on an object that is not a valid instance of CustomElementRegistry." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'get' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'get' on 'CustomElementRegistry': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].get(...args); + } + + whenDefined(name) { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'whenDefined' called on an object that is not a valid instance of CustomElementRegistry." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'whenDefined' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'whenDefined' on 'CustomElementRegistry': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].whenDefined(...args)); + } catch (e) { + return globalObject.Promise.reject(e); + } + } + + upgrade(root) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'upgrade' called on an object that is not a valid instance of CustomElementRegistry." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'upgrade' on 'CustomElementRegistry': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'upgrade' on 'CustomElementRegistry': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].upgrade(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(CustomElementRegistry.prototype, { + define: { enumerable: true }, + get: { enumerable: true }, + whenDefined: { enumerable: true }, + upgrade: { enumerable: true }, + [Symbol.toStringTag]: { value: "CustomElementRegistry", configurable: true } + }); + ctorRegistry[interfaceName] = CustomElementRegistry; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CustomElementRegistry + }); +}; + +const Impl = require("../custom-elements/CustomElementRegistry-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js new file mode 100644 index 00000000..43fd1b0e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CustomEvent.js @@ -0,0 +1,206 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const CustomEventInit = require("./CustomEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "CustomEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'CustomEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["CustomEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class CustomEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'CustomEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'CustomEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = CustomEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'CustomEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initCustomEvent(type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initCustomEvent' called on an object that is not a valid instance of CustomEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initCustomEvent' on 'CustomEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions["any"](curArg, { + context: "Failed to execute 'initCustomEvent' on 'CustomEvent': parameter 4", + globals: globalObject + }); + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].initCustomEvent(...args); + } + + get detail() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get detail' called on an object that is not a valid instance of CustomEvent." + ); + } + + return esValue[implSymbol]["detail"]; + } + } + Object.defineProperties(CustomEvent.prototype, { + initCustomEvent: { enumerable: true }, + detail: { enumerable: true }, + [Symbol.toStringTag]: { value: "CustomEvent", configurable: true } + }); + ctorRegistry[interfaceName] = CustomEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: CustomEvent + }); +}; + +const Impl = require("../events/CustomEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js new file mode 100644 index 00000000..faf921fe --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/CustomEventInit.js @@ -0,0 +1,32 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "detail"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["any"](value, { context: context + " has member 'detail' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = null; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DOMImplementation.js b/node_modules/jsdom/lib/jsdom/living/generated/DOMImplementation.js new file mode 100644 index 00000000..825e7750 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DOMImplementation.js @@ -0,0 +1,237 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const DocumentType = require("./DocumentType.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "DOMImplementation"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'DOMImplementation'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["DOMImplementation"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DOMImplementation { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + createDocumentType(qualifiedName, publicId, systemId) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createDocumentType' called on an object that is not a valid instance of DOMImplementation." + ); + } + + if (arguments.length < 3) { + throw new globalObject.TypeError( + `Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createDocumentType' on 'DOMImplementation': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentType(...args)); + } + + createDocument(namespace, qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createDocument' called on an object that is not a valid instance of DOMImplementation." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 2", + globals: globalObject, + treatNullAsEmptyString: true + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = DocumentType.convert(globalObject, curArg, { + context: "Failed to execute 'createDocument' on 'DOMImplementation': parameter 3" + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createDocument(...args)); + } + + createHTMLDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createHTMLDocument' called on an object that is not a valid instance of DOMImplementation." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createHTMLDocument' on 'DOMImplementation': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createHTMLDocument(...args)); + } + + hasFeature() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'hasFeature' called on an object that is not a valid instance of DOMImplementation." + ); + } + + return esValue[implSymbol].hasFeature(); + } + } + Object.defineProperties(DOMImplementation.prototype, { + createDocumentType: { enumerable: true }, + createDocument: { enumerable: true }, + createHTMLDocument: { enumerable: true }, + hasFeature: { enumerable: true }, + [Symbol.toStringTag]: { value: "DOMImplementation", configurable: true } + }); + ctorRegistry[interfaceName] = DOMImplementation; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMImplementation + }); +}; + +const Impl = require("../nodes/DOMImplementation-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DOMParser.js b/node_modules/jsdom/lib/jsdom/living/generated/DOMParser.js new file mode 100644 index 00000000..a28e6fef --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DOMParser.js @@ -0,0 +1,140 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const SupportedType = require("./SupportedType.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "DOMParser"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'DOMParser'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["DOMParser"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DOMParser { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + parseFromString(str, type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'parseFromString' called on an object that is not a valid instance of DOMParser." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = SupportedType.convert(globalObject, curArg, { + context: "Failed to execute 'parseFromString' on 'DOMParser': parameter 2" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].parseFromString(...args)); + } + } + Object.defineProperties(DOMParser.prototype, { + parseFromString: { enumerable: true }, + [Symbol.toStringTag]: { value: "DOMParser", configurable: true } + }); + ctorRegistry[interfaceName] = DOMParser; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMParser + }); +}; + +const Impl = require("../domparsing/DOMParser-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DOMStringMap.js b/node_modules/jsdom/lib/jsdom/living/generated/DOMStringMap.js new file mode 100644 index 00000000..71b43cb7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DOMStringMap.js @@ -0,0 +1,323 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "DOMStringMap"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'DOMStringMap'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["DOMStringMap"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DOMStringMap { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(DOMStringMap.prototype, { + [Symbol.toStringTag]: { value: "DOMStringMap", configurable: true } + }); + ctorRegistry[interfaceName] = DOMStringMap; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMStringMap + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!utils.hasOwn(target, key)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + const namedValue = target[implSymbol][utils.namedGet](P); + + if (namedValue !== undefined && !utils.hasOwn(target, P) && !ignoreNamedProps) { + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (typeof P === "string") { + let namedValue = V; + + namedValue = conversions["DOMString"](namedValue, { + context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const creating = !(target[implSymbol][utils.namedGet](P) !== undefined); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + + return true; + } + } + let ownDesc; + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (desc.get || desc.set) { + return false; + } + + let namedValue = desc.value; + + namedValue = conversions["DOMString"](namedValue, { + context: "Failed to set the '" + P + "' property on 'DOMStringMap': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const creating = !(target[implSymbol][utils.namedGet](P) !== undefined); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + + return true; + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (target[implSymbol][utils.namedGet](P) !== undefined && !utils.hasOwn(target, P)) { + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + target[implSymbol][utils.namedDelete](P); + return true; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/DOMStringMap-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DOMTokenList.js b/node_modules/jsdom/lib/jsdom/living/generated/DOMTokenList.js new file mode 100644 index 00000000..fa839db9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DOMTokenList.js @@ -0,0 +1,563 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "DOMTokenList"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'DOMTokenList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["DOMTokenList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DOMTokenList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of DOMTokenList."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'DOMTokenList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].item(...args); + } + + contains(token) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'contains' called on an object that is not a valid instance of DOMTokenList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'contains' on 'DOMTokenList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].contains(...args); + } + + add() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'add' called on an object that is not a valid instance of DOMTokenList."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'add' on 'DOMTokenList': parameter " + (i + 1), + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].add(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + remove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of DOMTokenList."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'remove' on 'DOMTokenList': parameter " + (i + 1), + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].remove(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + toggle(token) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toggle' called on an object that is not a valid instance of DOMTokenList."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'toggle' on 'DOMTokenList': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].toggle(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replace(token, newToken) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'replace' called on an object that is not a valid instance of DOMTokenList."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'replace' on 'DOMTokenList': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replace' on 'DOMTokenList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replace' on 'DOMTokenList': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replace(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + supports(token) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'supports' called on an object that is not a valid instance of DOMTokenList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'supports' on 'DOMTokenList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'supports' on 'DOMTokenList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].supports(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of DOMTokenList." + ); + } + + return esValue[implSymbol]["length"]; + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of DOMTokenList." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of DOMTokenList." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'DOMTokenList': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + toString() { + const esValue = this; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'toString' called on an object that is not a valid instance of DOMTokenList." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(DOMTokenList.prototype, { + item: { enumerable: true }, + contains: { enumerable: true }, + add: { enumerable: true }, + remove: { enumerable: true }, + toggle: { enumerable: true }, + replace: { enumerable: true }, + supports: { enumerable: true }, + length: { enumerable: true }, + value: { enumerable: true }, + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: "DOMTokenList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }, + keys: { value: globalObject.Array.prototype.keys, configurable: true, enumerable: true, writable: true }, + values: { value: globalObject.Array.prototype.values, configurable: true, enumerable: true, writable: true }, + entries: { value: globalObject.Array.prototype.entries, configurable: true, enumerable: true, writable: true }, + forEach: { value: globalObject.Array.prototype.forEach, configurable: true, enumerable: true, writable: true } + }); + ctorRegistry[interfaceName] = DOMTokenList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DOMTokenList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/DOMTokenList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Document.js b/node_modules/jsdom/lib/jsdom/living/generated/Document.js new file mode 100644 index 00000000..aeb0f214 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Document.js @@ -0,0 +1,3593 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ElementCreationOptions = require("./ElementCreationOptions.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const Node = require("./Node.js"); +const NodeFilter = require("./NodeFilter.js"); +const HTMLElement = require("./HTMLElement.js"); +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnErrorEventHandlerNonNull = require("./OnErrorEventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Document"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Document'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Document"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +function getUnforgeables(globalObject) { + let unforgeables = unforgeablesMap.get(globalObject); + if (unforgeables === undefined) { + unforgeables = Object.create(null); + utils.define(unforgeables, { + get location() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get location' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["location"]); + }, + set location(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set location' called on an object that is not a valid instance of Document." + ); + } + + const Q = esValue["location"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'location' is not an object"); + } + Reflect.set(Q, "href", V); + } + }); + Object.defineProperties(unforgeables, { + location: { configurable: false } + }); + unforgeablesMap.set(globalObject, unforgeables); + } + return unforgeables; +} + +exports._internalSetup = (wrapper, globalObject) => { + Node._internalSetup(wrapper, globalObject); + + utils.define(wrapper, getUnforgeables(globalObject)); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const unforgeablesMap = new WeakMap(); +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Document extends globalObject.Node { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + getElementsByTagName(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByTagName' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByTagName' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByTagName' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByTagName(...args)); + } + + getElementsByTagNameNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByTagNameNS' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByTagNameNS' on 'Document': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByTagNameNS' on 'Document': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByTagNameNS' on 'Document': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByTagNameNS(...args)); + } + + getElementsByClassName(classNames) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByClassName' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByClassName' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByClassName' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByClassName(...args)); + } + + createElement(localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createElement' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createElement' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createElement' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = ElementCreationOptions.convert(globalObject, curArg, { + context: "Failed to execute 'createElement' on 'Document': parameter 2" + }); + } else if (utils.isObject(curArg)) { + curArg = ElementCreationOptions.convert(globalObject, curArg, { + context: "Failed to execute 'createElement' on 'Document': parameter 2" + " dictionary" + }); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createElement' on 'Document': parameter 2", + globals: globalObject + }); + } + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].createElement(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + createElementNS(namespace, qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createElementNS' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'createElementNS' on 'Document': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createElementNS' on 'Document': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createElementNS' on 'Document': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = ElementCreationOptions.convert(globalObject, curArg, { + context: "Failed to execute 'createElementNS' on 'Document': parameter 3" + }); + } else if (utils.isObject(curArg)) { + curArg = ElementCreationOptions.convert(globalObject, curArg, { + context: "Failed to execute 'createElementNS' on 'Document': parameter 3" + " dictionary" + }); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createElementNS' on 'Document': parameter 3", + globals: globalObject + }); + } + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].createElementNS(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + createDocumentFragment() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createDocumentFragment' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentFragment()); + } + + createTextNode(data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createTextNode' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createTextNode' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createTextNode' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createTextNode(...args)); + } + + createCDATASection(data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createCDATASection' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createCDATASection' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createCDATASection' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createCDATASection(...args)); + } + + createComment(data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createComment' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createComment' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createComment' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createComment(...args)); + } + + createProcessingInstruction(target, data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createProcessingInstruction' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'createProcessingInstruction' on 'Document': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createProcessingInstruction' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createProcessingInstruction' on 'Document': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createProcessingInstruction(...args)); + } + + importNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'importNode' called on an object that is not a valid instance of Document."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'importNode' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'importNode' on 'Document': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'importNode' on 'Document': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].importNode(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + adoptNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'adoptNode' called on an object that is not a valid instance of Document."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'adoptNode' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'adoptNode' on 'Document': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].adoptNode(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + createAttribute(localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createAttribute' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createAttribute' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createAttribute' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createAttribute(...args)); + } + + createAttributeNS(namespace, qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createAttributeNS' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'createAttributeNS' on 'Document': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createAttributeNS' on 'Document': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createAttributeNS' on 'Document': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createAttributeNS(...args)); + } + + createEvent(interface_) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'createEvent' called on an object that is not a valid instance of Document."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createEvent' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createEvent' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createEvent(...args)); + } + + createRange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'createRange' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createRange()); + } + + createNodeIterator(root) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createNodeIterator' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createNodeIterator' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'createNodeIterator' on 'Document': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'createNodeIterator' on 'Document': parameter 2", + globals: globalObject + }); + } else { + curArg = 0xffffffff; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = NodeFilter.convert(globalObject, curArg, { + context: "Failed to execute 'createNodeIterator' on 'Document': parameter 3" + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createNodeIterator(...args)); + } + + createTreeWalker(root) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createTreeWalker' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createTreeWalker' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'createTreeWalker' on 'Document': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'createTreeWalker' on 'Document': parameter 2", + globals: globalObject + }); + } else { + curArg = 0xffffffff; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = NodeFilter.convert(globalObject, curArg, { + context: "Failed to execute 'createTreeWalker' on 'Document': parameter 3" + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].createTreeWalker(...args)); + } + + getElementsByName(elementName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByName' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByName' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByName' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByName(...args)); + } + + open() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'open' called on an object that is not a valid instance of Document."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'open' on 'Document': parameter 1", + globals: globalObject + }); + } else { + curArg = "text/html"; + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'open' on 'Document': parameter 2", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].open(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + close() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'close' called on an object that is not a valid instance of Document."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].close(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + write() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'write' called on an object that is not a valid instance of Document."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'write' on 'Document': parameter " + (i + 1), + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].write(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + writeln() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'writeln' called on an object that is not a valid instance of Document."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'writeln' on 'Document': parameter " + (i + 1), + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].writeln(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + hasFocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'hasFocus' called on an object that is not a valid instance of Document."); + } + + return esValue[implSymbol].hasFocus(); + } + + clear() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'clear' called on an object that is not a valid instance of Document."); + } + + return esValue[implSymbol].clear(); + } + + captureEvents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'captureEvents' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol].captureEvents(); + } + + releaseEvents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'releaseEvents' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol].releaseEvents(); + } + + getSelection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getSelection' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getSelection()); + } + + getElementById(elementId) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementById' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementById' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementById' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args)); + } + + prepend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'prepend' called on an object that is not a valid instance of Document."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'prepend' on 'Document': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].prepend(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + append() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'append' called on an object that is not a valid instance of Document."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'append' on 'Document': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].append(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceChildren() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceChildren' called on an object that is not a valid instance of Document." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceChildren' on 'Document': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replaceChildren(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + querySelector(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'querySelector' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'querySelector' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'querySelector' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args)); + } + + querySelectorAll(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'querySelectorAll' called on an object that is not a valid instance of Document." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'querySelectorAll' on 'Document': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'querySelectorAll' on 'Document': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args)); + } + + get implementation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get implementation' called on an object that is not a valid instance of Document." + ); + } + + return utils.getSameObject(this, "implementation", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["implementation"]); + }); + } + + get URL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get URL' called on an object that is not a valid instance of Document."); + } + + return esValue[implSymbol]["URL"]; + } + + get documentURI() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get documentURI' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["documentURI"]; + } + + get compatMode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get compatMode' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["compatMode"]; + } + + get characterSet() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get characterSet' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["characterSet"]; + } + + get charset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get charset' called on an object that is not a valid instance of Document."); + } + + return esValue[implSymbol]["charset"]; + } + + get inputEncoding() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get inputEncoding' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["inputEncoding"]; + } + + get contentType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get contentType' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["contentType"]; + } + + get doctype() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get doctype' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["doctype"]); + } + + get documentElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get documentElement' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["documentElement"]); + } + + get referrer() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get referrer' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["referrer"]; + } + + get cookie() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get cookie' called on an object that is not a valid instance of Document."); + } + + return esValue[implSymbol]["cookie"]; + } + + set cookie(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set cookie' called on an object that is not a valid instance of Document."); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'cookie' property on 'Document': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["cookie"] = V; + } + + get lastModified() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lastModified' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["lastModified"]; + } + + get readyState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readyState' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["readyState"]); + } + + get title() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get title' called on an object that is not a valid instance of Document."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["title"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set title(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set title' called on an object that is not a valid instance of Document."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'title' property on 'Document': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["title"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get dir() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get dir' called on an object that is not a valid instance of Document."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["dir"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set dir(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set dir' called on an object that is not a valid instance of Document."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'dir' property on 'Document': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["dir"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get body() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get body' called on an object that is not a valid instance of Document."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol]["body"]); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set body(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set body' called on an object that is not a valid instance of Document."); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = HTMLElement.convert(globalObject, V, { + context: "Failed to set the 'body' property on 'Document': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["body"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get head() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get head' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["head"]); + } + + get images() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get images' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "images", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["images"]); + }); + } + + get embeds() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get embeds' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "embeds", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["embeds"]); + }); + } + + get plugins() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get plugins' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "plugins", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["plugins"]); + }); + } + + get links() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get links' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "links", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["links"]); + }); + } + + get forms() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get forms' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "forms", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["forms"]); + }); + } + + get scripts() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get scripts' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "scripts", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["scripts"]); + }); + } + + get currentScript() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentScript' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["currentScript"]); + } + + get defaultView() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultView' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["defaultView"]); + } + + get onreadystatechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreadystatechange"]); + } + + set onreadystatechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreadystatechange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onreadystatechange"] = V; + } + + get anchors() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get anchors' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "anchors", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["anchors"]); + }); + } + + get applets() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get applets' called on an object that is not a valid instance of Document."); + } + + return utils.getSameObject(this, "applets", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["applets"]); + }); + } + + get styleSheets() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get styleSheets' called on an object that is not a valid instance of Document." + ); + } + + return utils.getSameObject(this, "styleSheets", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["styleSheets"]); + }); + } + + get hidden() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get hidden' called on an object that is not a valid instance of Document."); + } + + return esValue[implSymbol]["hidden"]; + } + + get visibilityState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get visibilityState' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["visibilityState"]); + } + + get onvisibilitychange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onvisibilitychange' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onvisibilitychange"]); + } + + set onvisibilitychange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onvisibilitychange' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onvisibilitychange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onvisibilitychange"] = V; + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onabort' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onabort' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onauxclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onauxclick' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onauxclick"]); + } + + set onauxclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onauxclick' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onauxclick' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onauxclick"] = V; + } + + get onblur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onblur' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onblur"]); + } + + set onblur(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onblur' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onblur' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onblur"] = V; + } + + get oncancel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncancel' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncancel"]); + } + + set oncancel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncancel' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncancel' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oncancel"] = V; + } + + get oncanplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplay' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplay"]); + } + + set oncanplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplay' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplay' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oncanplay"] = V; + } + + get oncanplaythrough() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplaythrough' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplaythrough"]); + } + + set oncanplaythrough(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplaythrough' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplaythrough' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oncanplaythrough"] = V; + } + + get onchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onchange' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onchange"]); + } + + set onchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onchange' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onchange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onchange"] = V; + } + + get onclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onclick' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclick"]); + } + + set onclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onclick' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclick' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onclick"] = V; + } + + get onclose() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onclose' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclose"]); + } + + set onclose(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onclose' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclose' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onclose"] = V; + } + + get oncontextmenu() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncontextmenu' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncontextmenu"]); + } + + set oncontextmenu(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncontextmenu' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncontextmenu' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oncontextmenu"] = V; + } + + get oncuechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncuechange' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncuechange"]); + } + + set oncuechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncuechange' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncuechange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oncuechange"] = V; + } + + get ondblclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondblclick' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondblclick"]); + } + + set ondblclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondblclick' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondblclick' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondblclick"] = V; + } + + get ondrag() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get ondrag' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrag"]); + } + + set ondrag(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set ondrag' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrag' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondrag"] = V; + } + + get ondragend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragend' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragend"]); + } + + set ondragend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragend' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragend' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondragend"] = V; + } + + get ondragenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragenter' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragenter"]); + } + + set ondragenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragenter' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragenter' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondragenter"] = V; + } + + get ondragleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragleave' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragleave"]); + } + + set ondragleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragleave' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragleave' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondragleave"] = V; + } + + get ondragover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragover' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragover"]); + } + + set ondragover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragover' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragover' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondragover"] = V; + } + + get ondragstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragstart' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragstart"]); + } + + set ondragstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragstart' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragstart' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondragstart"] = V; + } + + get ondrop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get ondrop' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrop"]); + } + + set ondrop(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set ondrop' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrop' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondrop"] = V; + } + + get ondurationchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondurationchange' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondurationchange"]); + } + + set ondurationchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondurationchange' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondurationchange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ondurationchange"] = V; + } + + get onemptied() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onemptied' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onemptied"]); + } + + set onemptied(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onemptied' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onemptied' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onemptied"] = V; + } + + get onended() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onended' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onended"]); + } + + set onended(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onended' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onended' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onended"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onerror' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onerror' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnErrorEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onfocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onfocus' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onfocus"]); + } + + set onfocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onfocus' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onfocus' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onfocus"] = V; + } + + get oninput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get oninput' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninput"]); + } + + set oninput(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set oninput' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninput' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oninput"] = V; + } + + get oninvalid() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninvalid' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninvalid"]); + } + + set oninvalid(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninvalid' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninvalid' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["oninvalid"] = V; + } + + get onkeydown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeydown' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeydown"]); + } + + set onkeydown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeydown' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeydown' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onkeydown"] = V; + } + + get onkeypress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeypress' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeypress"]); + } + + set onkeypress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeypress' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeypress' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onkeypress"] = V; + } + + get onkeyup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onkeyup' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeyup"]); + } + + set onkeyup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onkeyup' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeyup' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onkeyup"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onload' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onload' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get onloadeddata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadeddata' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadeddata"]); + } + + set onloadeddata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadeddata' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadeddata' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onloadeddata"] = V; + } + + get onloadedmetadata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadedmetadata' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadedmetadata"]); + } + + set onloadedmetadata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadedmetadata' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadedmetadata' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onloadedmetadata"] = V; + } + + get onloadend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadend' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]); + } + + set onloadend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadend' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadend' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onloadend"] = V; + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onmousedown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousedown' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousedown"]); + } + + set onmousedown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousedown' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousedown' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmousedown"] = V; + } + + get onmouseenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseenter"]); + } + + set onmouseenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseenter' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmouseenter"] = V; + } + + get onmouseleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseleave"]); + } + + set onmouseleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseleave' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmouseleave"] = V; + } + + get onmousemove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousemove' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousemove"]); + } + + set onmousemove(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousemove' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousemove' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmousemove"] = V; + } + + get onmouseout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseout' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseout"]); + } + + set onmouseout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseout' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseout' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmouseout"] = V; + } + + get onmouseover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseover' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseover"]); + } + + set onmouseover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseover' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseover' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmouseover"] = V; + } + + get onmouseup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseup' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseup"]); + } + + set onmouseup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseup' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseup' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onmouseup"] = V; + } + + get onwheel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onwheel' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwheel"]); + } + + set onwheel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onwheel' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwheel' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onwheel"] = V; + } + + get onpause() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onpause' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpause"]); + } + + set onpause(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onpause' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpause' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onpause"] = V; + } + + get onplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onplay' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplay"]); + } + + set onplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onplay' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplay' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onplay"] = V; + } + + get onplaying() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplaying' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplaying"]); + } + + set onplaying(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplaying' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplaying' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onplaying"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onratechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onratechange' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onratechange"]); + } + + set onratechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onratechange' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onratechange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onratechange"] = V; + } + + get onreset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onreset' called on an object that is not a valid instance of Document."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreset"]); + } + + set onreset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onreset' called on an object that is not a valid instance of Document."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreset' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onreset"] = V; + } + + get onresize() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onresize' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onresize"]); + } + + set onresize(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onresize' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onresize' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onresize"] = V; + } + + get onscroll() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onscroll' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onscroll"]); + } + + set onscroll(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onscroll' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onscroll' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onscroll"] = V; + } + + get onsecuritypolicyviolation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsecuritypolicyviolation' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsecuritypolicyviolation"]); + } + + set onsecuritypolicyviolation(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsecuritypolicyviolation' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsecuritypolicyviolation' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onsecuritypolicyviolation"] = V; + } + + get onseeked() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeked' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeked"]); + } + + set onseeked(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeked' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeked' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onseeked"] = V; + } + + get onseeking() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeking' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeking"]); + } + + set onseeking(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeking' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeking' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onseeking"] = V; + } + + get onselect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onselect' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onselect"]); + } + + set onselect(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onselect' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onselect' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onselect"] = V; + } + + get onstalled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstalled' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstalled"]); + } + + set onstalled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstalled' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstalled' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onstalled"] = V; + } + + get onsubmit() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsubmit' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsubmit"]); + } + + set onsubmit(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsubmit' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsubmit' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onsubmit"] = V; + } + + get onsuspend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsuspend' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsuspend"]); + } + + set onsuspend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsuspend' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsuspend' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onsuspend"] = V; + } + + get ontimeupdate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontimeupdate' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontimeupdate"]); + } + + set ontimeupdate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontimeupdate' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontimeupdate' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ontimeupdate"] = V; + } + + get ontoggle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontoggle' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontoggle"]); + } + + set ontoggle(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontoggle' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontoggle' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["ontoggle"] = V; + } + + get onvolumechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onvolumechange' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onvolumechange"]); + } + + set onvolumechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onvolumechange' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onvolumechange' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onvolumechange"] = V; + } + + get onwaiting() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwaiting' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwaiting"]); + } + + set onwaiting(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwaiting' called on an object that is not a valid instance of Document." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwaiting' property on 'Document': The provided value" + }); + } + esValue[implSymbol]["onwaiting"] = V; + } + + get activeElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get activeElement' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["activeElement"]); + } + + get children() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get children' called on an object that is not a valid instance of Document." + ); + } + + return utils.getSameObject(this, "children", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["children"]); + }); + } + + get firstElementChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get firstElementChild' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["firstElementChild"]); + } + + get lastElementChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lastElementChild' called on an object that is not a valid instance of Document." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["lastElementChild"]); + } + + get childElementCount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get childElementCount' called on an object that is not a valid instance of Document." + ); + } + + return esValue[implSymbol]["childElementCount"]; + } + } + Object.defineProperties(Document.prototype, { + getElementsByTagName: { enumerable: true }, + getElementsByTagNameNS: { enumerable: true }, + getElementsByClassName: { enumerable: true }, + createElement: { enumerable: true }, + createElementNS: { enumerable: true }, + createDocumentFragment: { enumerable: true }, + createTextNode: { enumerable: true }, + createCDATASection: { enumerable: true }, + createComment: { enumerable: true }, + createProcessingInstruction: { enumerable: true }, + importNode: { enumerable: true }, + adoptNode: { enumerable: true }, + createAttribute: { enumerable: true }, + createAttributeNS: { enumerable: true }, + createEvent: { enumerable: true }, + createRange: { enumerable: true }, + createNodeIterator: { enumerable: true }, + createTreeWalker: { enumerable: true }, + getElementsByName: { enumerable: true }, + open: { enumerable: true }, + close: { enumerable: true }, + write: { enumerable: true }, + writeln: { enumerable: true }, + hasFocus: { enumerable: true }, + clear: { enumerable: true }, + captureEvents: { enumerable: true }, + releaseEvents: { enumerable: true }, + getSelection: { enumerable: true }, + getElementById: { enumerable: true }, + prepend: { enumerable: true }, + append: { enumerable: true }, + replaceChildren: { enumerable: true }, + querySelector: { enumerable: true }, + querySelectorAll: { enumerable: true }, + implementation: { enumerable: true }, + URL: { enumerable: true }, + documentURI: { enumerable: true }, + compatMode: { enumerable: true }, + characterSet: { enumerable: true }, + charset: { enumerable: true }, + inputEncoding: { enumerable: true }, + contentType: { enumerable: true }, + doctype: { enumerable: true }, + documentElement: { enumerable: true }, + referrer: { enumerable: true }, + cookie: { enumerable: true }, + lastModified: { enumerable: true }, + readyState: { enumerable: true }, + title: { enumerable: true }, + dir: { enumerable: true }, + body: { enumerable: true }, + head: { enumerable: true }, + images: { enumerable: true }, + embeds: { enumerable: true }, + plugins: { enumerable: true }, + links: { enumerable: true }, + forms: { enumerable: true }, + scripts: { enumerable: true }, + currentScript: { enumerable: true }, + defaultView: { enumerable: true }, + onreadystatechange: { enumerable: true }, + anchors: { enumerable: true }, + applets: { enumerable: true }, + styleSheets: { enumerable: true }, + hidden: { enumerable: true }, + visibilityState: { enumerable: true }, + onvisibilitychange: { enumerable: true }, + onabort: { enumerable: true }, + onauxclick: { enumerable: true }, + onblur: { enumerable: true }, + oncancel: { enumerable: true }, + oncanplay: { enumerable: true }, + oncanplaythrough: { enumerable: true }, + onchange: { enumerable: true }, + onclick: { enumerable: true }, + onclose: { enumerable: true }, + oncontextmenu: { enumerable: true }, + oncuechange: { enumerable: true }, + ondblclick: { enumerable: true }, + ondrag: { enumerable: true }, + ondragend: { enumerable: true }, + ondragenter: { enumerable: true }, + ondragleave: { enumerable: true }, + ondragover: { enumerable: true }, + ondragstart: { enumerable: true }, + ondrop: { enumerable: true }, + ondurationchange: { enumerable: true }, + onemptied: { enumerable: true }, + onended: { enumerable: true }, + onerror: { enumerable: true }, + onfocus: { enumerable: true }, + oninput: { enumerable: true }, + oninvalid: { enumerable: true }, + onkeydown: { enumerable: true }, + onkeypress: { enumerable: true }, + onkeyup: { enumerable: true }, + onload: { enumerable: true }, + onloadeddata: { enumerable: true }, + onloadedmetadata: { enumerable: true }, + onloadend: { enumerable: true }, + onloadstart: { enumerable: true }, + onmousedown: { enumerable: true }, + onmouseenter: { enumerable: true }, + onmouseleave: { enumerable: true }, + onmousemove: { enumerable: true }, + onmouseout: { enumerable: true }, + onmouseover: { enumerable: true }, + onmouseup: { enumerable: true }, + onwheel: { enumerable: true }, + onpause: { enumerable: true }, + onplay: { enumerable: true }, + onplaying: { enumerable: true }, + onprogress: { enumerable: true }, + onratechange: { enumerable: true }, + onreset: { enumerable: true }, + onresize: { enumerable: true }, + onscroll: { enumerable: true }, + onsecuritypolicyviolation: { enumerable: true }, + onseeked: { enumerable: true }, + onseeking: { enumerable: true }, + onselect: { enumerable: true }, + onstalled: { enumerable: true }, + onsubmit: { enumerable: true }, + onsuspend: { enumerable: true }, + ontimeupdate: { enumerable: true }, + ontoggle: { enumerable: true }, + onvolumechange: { enumerable: true }, + onwaiting: { enumerable: true }, + activeElement: { enumerable: true }, + children: { enumerable: true }, + firstElementChild: { enumerable: true }, + lastElementChild: { enumerable: true }, + childElementCount: { enumerable: true }, + [Symbol.toStringTag]: { value: "Document", configurable: true }, + [Symbol.unscopables]: { + value: { prepend: true, append: true, replaceChildren: true, __proto__: null }, + configurable: true + } + }); + ctorRegistry[interfaceName] = Document; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Document + }); +}; + +const Impl = require("../nodes/Document-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DocumentFragment.js b/node_modules/jsdom/lib/jsdom/living/generated/DocumentFragment.js new file mode 100644 index 00000000..1df4a507 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DocumentFragment.js @@ -0,0 +1,334 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "DocumentFragment"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'DocumentFragment'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["DocumentFragment"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Node._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DocumentFragment extends globalObject.Node { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + getElementById(elementId) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementById' called on an object that is not a valid instance of DocumentFragment." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementById' on 'DocumentFragment': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementById' on 'DocumentFragment': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args)); + } + + prepend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'prepend' called on an object that is not a valid instance of DocumentFragment." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'prepend' on 'DocumentFragment': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].prepend(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + append() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'append' called on an object that is not a valid instance of DocumentFragment." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'append' on 'DocumentFragment': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].append(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceChildren() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceChildren' called on an object that is not a valid instance of DocumentFragment." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceChildren' on 'DocumentFragment': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replaceChildren(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + querySelector(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'querySelector' called on an object that is not a valid instance of DocumentFragment." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'querySelector' on 'DocumentFragment': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'querySelector' on 'DocumentFragment': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args)); + } + + querySelectorAll(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'querySelectorAll' called on an object that is not a valid instance of DocumentFragment." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'querySelectorAll' on 'DocumentFragment': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'querySelectorAll' on 'DocumentFragment': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args)); + } + + get children() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get children' called on an object that is not a valid instance of DocumentFragment." + ); + } + + return utils.getSameObject(this, "children", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["children"]); + }); + } + + get firstElementChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get firstElementChild' called on an object that is not a valid instance of DocumentFragment." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["firstElementChild"]); + } + + get lastElementChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lastElementChild' called on an object that is not a valid instance of DocumentFragment." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["lastElementChild"]); + } + + get childElementCount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get childElementCount' called on an object that is not a valid instance of DocumentFragment." + ); + } + + return esValue[implSymbol]["childElementCount"]; + } + } + Object.defineProperties(DocumentFragment.prototype, { + getElementById: { enumerable: true }, + prepend: { enumerable: true }, + append: { enumerable: true }, + replaceChildren: { enumerable: true }, + querySelector: { enumerable: true }, + querySelectorAll: { enumerable: true }, + children: { enumerable: true }, + firstElementChild: { enumerable: true }, + lastElementChild: { enumerable: true }, + childElementCount: { enumerable: true }, + [Symbol.toStringTag]: { value: "DocumentFragment", configurable: true }, + [Symbol.unscopables]: { + value: { prepend: true, append: true, replaceChildren: true, __proto__: null }, + configurable: true + } + }); + ctorRegistry[interfaceName] = DocumentFragment; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DocumentFragment + }); +}; + +const Impl = require("../nodes/DocumentFragment-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DocumentReadyState.js b/node_modules/jsdom/lib/jsdom/living/generated/DocumentReadyState.js new file mode 100644 index 00000000..5b7e85d2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DocumentReadyState.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["loading", "interactive", "complete"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for DocumentReadyState`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/DocumentType.js b/node_modules/jsdom/lib/jsdom/living/generated/DocumentType.js new file mode 100644 index 00000000..be1e3c90 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/DocumentType.js @@ -0,0 +1,252 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "DocumentType"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'DocumentType'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["DocumentType"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Node._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class DocumentType extends globalObject.Node { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + before() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'before' called on an object that is not a valid instance of DocumentType."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'before' on 'DocumentType': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].before(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + after() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'after' called on an object that is not a valid instance of DocumentType."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'after' on 'DocumentType': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].after(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceWith() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceWith' called on an object that is not a valid instance of DocumentType." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceWith' on 'DocumentType': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replaceWith(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + remove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of DocumentType."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].remove(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of DocumentType." + ); + } + + return esValue[implSymbol]["name"]; + } + + get publicId() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get publicId' called on an object that is not a valid instance of DocumentType." + ); + } + + return esValue[implSymbol]["publicId"]; + } + + get systemId() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get systemId' called on an object that is not a valid instance of DocumentType." + ); + } + + return esValue[implSymbol]["systemId"]; + } + } + Object.defineProperties(DocumentType.prototype, { + before: { enumerable: true }, + after: { enumerable: true }, + replaceWith: { enumerable: true }, + remove: { enumerable: true }, + name: { enumerable: true }, + publicId: { enumerable: true }, + systemId: { enumerable: true }, + [Symbol.toStringTag]: { value: "DocumentType", configurable: true }, + [Symbol.unscopables]: { + value: { before: true, after: true, replaceWith: true, remove: true, __proto__: null }, + configurable: true + } + }); + ctorRegistry[interfaceName] = DocumentType; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: DocumentType + }); +}; + +const Impl = require("../nodes/DocumentType-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Element.js b/node_modules/jsdom/lib/jsdom/living/generated/Element.js new file mode 100644 index 00000000..30925230 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Element.js @@ -0,0 +1,1718 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const Attr = require("./Attr.js"); +const ShadowRootInit = require("./ShadowRootInit.js"); +const Node = require("./Node.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Element"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Element'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Element"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Node._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Element extends globalObject.Node { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + hasAttributes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'hasAttributes' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol].hasAttributes(); + } + + getAttributeNames() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getAttributeNames' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getAttributeNames()); + } + + getAttribute(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getAttribute' called on an object that is not a valid instance of Element."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getAttribute' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getAttribute' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getAttribute(...args); + } + + getAttributeNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getAttributeNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'getAttributeNS' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getAttributeNS' on 'Element': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getAttributeNS' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getAttributeNS(...args); + } + + setAttribute(qualifiedName, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setAttribute' called on an object that is not a valid instance of Element."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setAttribute' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setAttribute' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setAttribute' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].setAttribute(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + setAttributeNS(namespace, qualifiedName, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setAttributeNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 3) { + throw new globalObject.TypeError( + `Failed to execute 'setAttributeNS' on 'Element': 3 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setAttributeNS' on 'Element': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setAttributeNS' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setAttributeNS' on 'Element': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].setAttributeNS(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + removeAttribute(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeAttribute' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeAttribute' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeAttribute' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].removeAttribute(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + removeAttributeNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeAttributeNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'removeAttributeNS' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeAttributeNS' on 'Element': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeAttributeNS' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].removeAttributeNS(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + toggleAttribute(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'toggleAttribute' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'toggleAttribute' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'toggleAttribute' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'toggleAttribute' on 'Element': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].toggleAttribute(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + hasAttribute(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'hasAttribute' called on an object that is not a valid instance of Element."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'hasAttribute' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'hasAttribute' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].hasAttribute(...args); + } + + hasAttributeNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'hasAttributeNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'hasAttributeNS' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'hasAttributeNS' on 'Element': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'hasAttributeNS' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].hasAttributeNS(...args); + } + + getAttributeNode(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getAttributeNode' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getAttributeNode' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getAttributeNode' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getAttributeNode(...args)); + } + + getAttributeNodeNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getAttributeNodeNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'getAttributeNodeNS' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getAttributeNodeNS' on 'Element': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getAttributeNodeNS' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getAttributeNodeNS(...args)); + } + + setAttributeNode(attr) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setAttributeNode' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setAttributeNode' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Attr.convert(globalObject, curArg, { + context: "Failed to execute 'setAttributeNode' on 'Element': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].setAttributeNode(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + setAttributeNodeNS(attr) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setAttributeNodeNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setAttributeNodeNS' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Attr.convert(globalObject, curArg, { + context: "Failed to execute 'setAttributeNodeNS' on 'Element': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].setAttributeNodeNS(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + removeAttributeNode(attr) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeAttributeNode' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeAttributeNode' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Attr.convert(globalObject, curArg, { + context: "Failed to execute 'removeAttributeNode' on 'Element': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].removeAttributeNode(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + attachShadow(init) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'attachShadow' called on an object that is not a valid instance of Element."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'attachShadow' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = ShadowRootInit.convert(globalObject, curArg, { + context: "Failed to execute 'attachShadow' on 'Element': parameter 1" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].attachShadow(...args)); + } + + closest(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'closest' called on an object that is not a valid instance of Element."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'closest' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'closest' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].closest(...args)); + } + + matches(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'matches' called on an object that is not a valid instance of Element."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'matches' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'matches' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].matches(...args); + } + + webkitMatchesSelector(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'webkitMatchesSelector' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'webkitMatchesSelector' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'webkitMatchesSelector' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].webkitMatchesSelector(...args); + } + + getElementsByTagName(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByTagName' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByTagName' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByTagName' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByTagName(...args)); + } + + getElementsByTagNameNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByTagNameNS' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByTagNameNS' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByTagNameNS' on 'Element': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByTagNameNS' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByTagNameNS(...args)); + } + + getElementsByClassName(classNames) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementsByClassName' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementsByClassName' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementsByClassName' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByClassName(...args)); + } + + insertAdjacentElement(where, element) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertAdjacentElement' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertAdjacentElement' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertAdjacentElement' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'insertAdjacentElement' on 'Element': parameter 2" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].insertAdjacentElement(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + insertAdjacentText(where, data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertAdjacentText' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertAdjacentText' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertAdjacentText' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertAdjacentText' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].insertAdjacentText(...args); + } + + insertAdjacentHTML(position, text) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertAdjacentHTML' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertAdjacentHTML' on 'Element': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertAdjacentHTML' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertAdjacentHTML' on 'Element': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].insertAdjacentHTML(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + getClientRects() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getClientRects' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getClientRects()); + } + + getBoundingClientRect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getBoundingClientRect' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getBoundingClientRect()); + } + + before() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'before' called on an object that is not a valid instance of Element."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'before' on 'Element': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].before(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + after() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'after' called on an object that is not a valid instance of Element."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'after' on 'Element': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].after(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceWith() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'replaceWith' called on an object that is not a valid instance of Element."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceWith' on 'Element': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replaceWith(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + remove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'remove' called on an object that is not a valid instance of Element."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].remove(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + prepend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'prepend' called on an object that is not a valid instance of Element."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'prepend' on 'Element': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].prepend(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + append() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'append' called on an object that is not a valid instance of Element."); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'append' on 'Element': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].append(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceChildren() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceChildren' called on an object that is not a valid instance of Element." + ); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + if (Node.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceChildren' on 'Element': parameter " + (i + 1), + globals: globalObject + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].replaceChildren(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + querySelector(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'querySelector' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'querySelector' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'querySelector' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args)); + } + + querySelectorAll(selectors) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'querySelectorAll' called on an object that is not a valid instance of Element." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'querySelectorAll' on 'Element': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'querySelectorAll' on 'Element': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args)); + } + + get namespaceURI() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get namespaceURI' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["namespaceURI"]; + } + + get prefix() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get prefix' called on an object that is not a valid instance of Element."); + } + + return esValue[implSymbol]["prefix"]; + } + + get localName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get localName' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["localName"]; + } + + get tagName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get tagName' called on an object that is not a valid instance of Element."); + } + + return esValue[implSymbol]["tagName"]; + } + + get id() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get id' called on an object that is not a valid instance of Element."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "id"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set id(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set id' called on an object that is not a valid instance of Element."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'id' property on 'Element': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "id", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get className() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get className' called on an object that is not a valid instance of Element." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "class"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set className(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set className' called on an object that is not a valid instance of Element." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'className' property on 'Element': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "class", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get classList() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get classList' called on an object that is not a valid instance of Element." + ); + } + + return utils.getSameObject(this, "classList", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["classList"]); + }); + } + + set classList(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set classList' called on an object that is not a valid instance of Element." + ); + } + + const Q = esValue["classList"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'classList' is not an object"); + } + Reflect.set(Q, "value", V); + } + + get slot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get slot' called on an object that is not a valid instance of Element."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "slot"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set slot(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set slot' called on an object that is not a valid instance of Element."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'slot' property on 'Element': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "slot", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get attributes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get attributes' called on an object that is not a valid instance of Element." + ); + } + + return utils.getSameObject(this, "attributes", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["attributes"]); + }); + } + + get shadowRoot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shadowRoot' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["shadowRoot"]); + } + + get outerHTML() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get outerHTML' called on an object that is not a valid instance of Element." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["outerHTML"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set outerHTML(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set outerHTML' called on an object that is not a valid instance of Element." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'outerHTML' property on 'Element': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["outerHTML"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get scrollTop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrollTop' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["scrollTop"]; + } + + set scrollTop(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scrollTop' called on an object that is not a valid instance of Element." + ); + } + + V = conversions["unrestricted double"](V, { + context: "Failed to set the 'scrollTop' property on 'Element': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["scrollTop"] = V; + } + + get scrollLeft() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrollLeft' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["scrollLeft"]; + } + + set scrollLeft(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scrollLeft' called on an object that is not a valid instance of Element." + ); + } + + V = conversions["unrestricted double"](V, { + context: "Failed to set the 'scrollLeft' property on 'Element': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["scrollLeft"] = V; + } + + get scrollWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrollWidth' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["scrollWidth"]; + } + + get scrollHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrollHeight' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["scrollHeight"]; + } + + get clientTop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clientTop' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["clientTop"]; + } + + get clientLeft() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clientLeft' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["clientLeft"]; + } + + get clientWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clientWidth' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["clientWidth"]; + } + + get clientHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clientHeight' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["clientHeight"]; + } + + get innerHTML() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get innerHTML' called on an object that is not a valid instance of Element." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["innerHTML"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set innerHTML(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set innerHTML' called on an object that is not a valid instance of Element." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'innerHTML' property on 'Element': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["innerHTML"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get previousElementSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get previousElementSibling' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["previousElementSibling"]); + } + + get nextElementSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get nextElementSibling' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["nextElementSibling"]); + } + + get children() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get children' called on an object that is not a valid instance of Element."); + } + + return utils.getSameObject(this, "children", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["children"]); + }); + } + + get firstElementChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get firstElementChild' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["firstElementChild"]); + } + + get lastElementChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lastElementChild' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["lastElementChild"]); + } + + get childElementCount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get childElementCount' called on an object that is not a valid instance of Element." + ); + } + + return esValue[implSymbol]["childElementCount"]; + } + + get assignedSlot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get assignedSlot' called on an object that is not a valid instance of Element." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["assignedSlot"]); + } + } + Object.defineProperties(Element.prototype, { + hasAttributes: { enumerable: true }, + getAttributeNames: { enumerable: true }, + getAttribute: { enumerable: true }, + getAttributeNS: { enumerable: true }, + setAttribute: { enumerable: true }, + setAttributeNS: { enumerable: true }, + removeAttribute: { enumerable: true }, + removeAttributeNS: { enumerable: true }, + toggleAttribute: { enumerable: true }, + hasAttribute: { enumerable: true }, + hasAttributeNS: { enumerable: true }, + getAttributeNode: { enumerable: true }, + getAttributeNodeNS: { enumerable: true }, + setAttributeNode: { enumerable: true }, + setAttributeNodeNS: { enumerable: true }, + removeAttributeNode: { enumerable: true }, + attachShadow: { enumerable: true }, + closest: { enumerable: true }, + matches: { enumerable: true }, + webkitMatchesSelector: { enumerable: true }, + getElementsByTagName: { enumerable: true }, + getElementsByTagNameNS: { enumerable: true }, + getElementsByClassName: { enumerable: true }, + insertAdjacentElement: { enumerable: true }, + insertAdjacentText: { enumerable: true }, + insertAdjacentHTML: { enumerable: true }, + getClientRects: { enumerable: true }, + getBoundingClientRect: { enumerable: true }, + before: { enumerable: true }, + after: { enumerable: true }, + replaceWith: { enumerable: true }, + remove: { enumerable: true }, + prepend: { enumerable: true }, + append: { enumerable: true }, + replaceChildren: { enumerable: true }, + querySelector: { enumerable: true }, + querySelectorAll: { enumerable: true }, + namespaceURI: { enumerable: true }, + prefix: { enumerable: true }, + localName: { enumerable: true }, + tagName: { enumerable: true }, + id: { enumerable: true }, + className: { enumerable: true }, + classList: { enumerable: true }, + slot: { enumerable: true }, + attributes: { enumerable: true }, + shadowRoot: { enumerable: true }, + outerHTML: { enumerable: true }, + scrollTop: { enumerable: true }, + scrollLeft: { enumerable: true }, + scrollWidth: { enumerable: true }, + scrollHeight: { enumerable: true }, + clientTop: { enumerable: true }, + clientLeft: { enumerable: true }, + clientWidth: { enumerable: true }, + clientHeight: { enumerable: true }, + innerHTML: { enumerable: true }, + previousElementSibling: { enumerable: true }, + nextElementSibling: { enumerable: true }, + children: { enumerable: true }, + firstElementChild: { enumerable: true }, + lastElementChild: { enumerable: true }, + childElementCount: { enumerable: true }, + assignedSlot: { enumerable: true }, + [Symbol.toStringTag]: { value: "Element", configurable: true }, + [Symbol.unscopables]: { + value: { + slot: true, + before: true, + after: true, + replaceWith: true, + remove: true, + prepend: true, + append: true, + replaceChildren: true, + __proto__: null + }, + configurable: true + } + }); + ctorRegistry[interfaceName] = Element; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Element + }); +}; + +const Impl = require("../nodes/Element-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ElementCreationOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/ElementCreationOptions.js new file mode 100644 index 00000000..873b2a79 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ElementCreationOptions.js @@ -0,0 +1,26 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "is"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { context: context + " has member 'is' that", globals: globalObject }); + + ret[key] = value; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ElementDefinitionOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/ElementDefinitionOptions.js new file mode 100644 index 00000000..e32d1e82 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ElementDefinitionOptions.js @@ -0,0 +1,29 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "extends"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'extends' that", + globals: globalObject + }); + + ret[key] = value; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EndingType.js b/node_modules/jsdom/lib/jsdom/living/generated/EndingType.js new file mode 100644 index 00000000..05128c22 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EndingType.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["transparent", "native"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for EndingType`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js new file mode 100644 index 00000000..4d722738 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ErrorEvent.js @@ -0,0 +1,192 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ErrorEventInit = require("./ErrorEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "ErrorEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'ErrorEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ErrorEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ErrorEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'ErrorEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'ErrorEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = ErrorEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'ErrorEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get message() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get message' called on an object that is not a valid instance of ErrorEvent." + ); + } + + return esValue[implSymbol]["message"]; + } + + get filename() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get filename' called on an object that is not a valid instance of ErrorEvent." + ); + } + + return esValue[implSymbol]["filename"]; + } + + get lineno() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lineno' called on an object that is not a valid instance of ErrorEvent." + ); + } + + return esValue[implSymbol]["lineno"]; + } + + get colno() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get colno' called on an object that is not a valid instance of ErrorEvent."); + } + + return esValue[implSymbol]["colno"]; + } + + get error() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get error' called on an object that is not a valid instance of ErrorEvent."); + } + + return esValue[implSymbol]["error"]; + } + } + Object.defineProperties(ErrorEvent.prototype, { + message: { enumerable: true }, + filename: { enumerable: true }, + lineno: { enumerable: true }, + colno: { enumerable: true }, + error: { enumerable: true }, + [Symbol.toStringTag]: { value: "ErrorEvent", configurable: true } + }); + ctorRegistry[interfaceName] = ErrorEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ErrorEvent + }); +}; + +const Impl = require("../events/ErrorEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js new file mode 100644 index 00000000..e615f5a4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ErrorEventInit.js @@ -0,0 +1,92 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "colno"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'colno' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "error"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["any"](value, { context: context + " has member 'error' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "filename"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { + context: context + " has member 'filename' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "lineno"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'lineno' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "message"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'message' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Event.js b/node_modules/jsdom/lib/jsdom/living/generated/Event.js new file mode 100644 index 00000000..e1fede2e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Event.js @@ -0,0 +1,430 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Event"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Event'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Event"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +function getUnforgeables(globalObject) { + let unforgeables = unforgeablesMap.get(globalObject); + if (unforgeables === undefined) { + unforgeables = Object.create(null); + utils.define(unforgeables, { + get isTrusted() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isTrusted' called on an object that is not a valid instance of Event." + ); + } + + return esValue[implSymbol]["isTrusted"]; + } + }); + Object.defineProperties(unforgeables, { + isTrusted: { configurable: false } + }); + unforgeablesMap.set(globalObject, unforgeables); + } + return unforgeables; +} + +exports._internalSetup = (wrapper, globalObject) => { + utils.define(wrapper, getUnforgeables(globalObject)); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const unforgeablesMap = new WeakMap(); +const exposed = new Set(["Window", "Worker", "AudioWorklet"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'Event': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'Event': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = EventInit.convert(globalObject, curArg, { context: "Failed to construct 'Event': parameter 2" }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + composedPath() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'composedPath' called on an object that is not a valid instance of Event."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].composedPath()); + } + + stopPropagation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'stopPropagation' called on an object that is not a valid instance of Event." + ); + } + + return esValue[implSymbol].stopPropagation(); + } + + stopImmediatePropagation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'stopImmediatePropagation' called on an object that is not a valid instance of Event." + ); + } + + return esValue[implSymbol].stopImmediatePropagation(); + } + + preventDefault() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'preventDefault' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol].preventDefault(); + } + + initEvent(type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'initEvent' called on an object that is not a valid instance of Event."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initEvent' on 'Event': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initEvent' on 'Event': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initEvent' on 'Event': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initEvent' on 'Event': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + return esValue[implSymbol].initEvent(...args); + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol]["type"]; + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get target' called on an object that is not a valid instance of Event."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["target"]); + } + + get srcElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get srcElement' called on an object that is not a valid instance of Event."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["srcElement"]); + } + + get currentTarget() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentTarget' called on an object that is not a valid instance of Event." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["currentTarget"]); + } + + get eventPhase() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get eventPhase' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol]["eventPhase"]; + } + + get cancelBubble() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cancelBubble' called on an object that is not a valid instance of Event." + ); + } + + return esValue[implSymbol]["cancelBubble"]; + } + + set cancelBubble(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cancelBubble' called on an object that is not a valid instance of Event." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'cancelBubble' property on 'Event': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["cancelBubble"] = V; + } + + get bubbles() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get bubbles' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol]["bubbles"]; + } + + get cancelable() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get cancelable' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol]["cancelable"]; + } + + get returnValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get returnValue' called on an object that is not a valid instance of Event." + ); + } + + return esValue[implSymbol]["returnValue"]; + } + + set returnValue(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set returnValue' called on an object that is not a valid instance of Event." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'returnValue' property on 'Event': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["returnValue"] = V; + } + + get defaultPrevented() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultPrevented' called on an object that is not a valid instance of Event." + ); + } + + return esValue[implSymbol]["defaultPrevented"]; + } + + get composed() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get composed' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol]["composed"]; + } + + get timeStamp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get timeStamp' called on an object that is not a valid instance of Event."); + } + + return esValue[implSymbol]["timeStamp"]; + } + } + Object.defineProperties(Event.prototype, { + composedPath: { enumerable: true }, + stopPropagation: { enumerable: true }, + stopImmediatePropagation: { enumerable: true }, + preventDefault: { enumerable: true }, + initEvent: { enumerable: true }, + type: { enumerable: true }, + target: { enumerable: true }, + srcElement: { enumerable: true }, + currentTarget: { enumerable: true }, + eventPhase: { enumerable: true }, + cancelBubble: { enumerable: true }, + bubbles: { enumerable: true }, + cancelable: { enumerable: true }, + returnValue: { enumerable: true }, + defaultPrevented: { enumerable: true }, + composed: { enumerable: true }, + timeStamp: { enumerable: true }, + [Symbol.toStringTag]: { value: "Event", configurable: true }, + NONE: { value: 0, enumerable: true }, + CAPTURING_PHASE: { value: 1, enumerable: true }, + AT_TARGET: { value: 2, enumerable: true }, + BUBBLING_PHASE: { value: 3, enumerable: true } + }); + Object.defineProperties(Event, { + NONE: { value: 0, enumerable: true }, + CAPTURING_PHASE: { value: 1, enumerable: true }, + AT_TARGET: { value: 2, enumerable: true }, + BUBBLING_PHASE: { value: 3, enumerable: true } + }); + ctorRegistry[interfaceName] = Event; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Event + }); +}; + +const Impl = require("../events/Event-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js b/node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js new file mode 100644 index 00000000..a8fc6665 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js @@ -0,0 +1,36 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + function invokeTheCallbackFunction(event) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + if (typeof value === "function") { + event = utils.tryWrapperForImpl(event); + + callResult = Reflect.apply(value, thisArg, [event]); + } + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + } + + invokeTheCallbackFunction.construct = event => { + event = utils.tryWrapperForImpl(event); + + let callResult = Reflect.construct(value, [event]); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/EventInit.js new file mode 100644 index 00000000..b0bdcbcf --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EventInit.js @@ -0,0 +1,58 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "bubbles"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'bubbles' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "cancelable"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'cancelable' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "composed"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'composed' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js b/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js new file mode 100644 index 00000000..d7477366 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js @@ -0,0 +1,35 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + function callTheUserObjectsOperation(event) { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; + + if (typeof O !== "function") { + X = O["handleEvent"]; + if (typeof X !== "function") { + throw new globalObject.TypeError(`${context} does not correctly implement EventListener.`); + } + thisArg = O; + } + + event = utils.tryWrapperForImpl(event); + + let callResult = Reflect.apply(X, thisArg, [event]); + } + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; +}; + +exports.install = (globalObject, globalNames) => {}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EventListenerOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/EventListenerOptions.js new file mode 100644 index 00000000..49e46860 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EventListenerOptions.js @@ -0,0 +1,28 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "capture"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'capture' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js b/node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js new file mode 100644 index 00000000..227250bf --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EventModifierInit.js @@ -0,0 +1,221 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const UIEventInit = require("./UIEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + UIEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "altKey"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'altKey' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "ctrlKey"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'ctrlKey' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "metaKey"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'metaKey' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierAltGraph"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierAltGraph' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierCapsLock"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierCapsLock' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierFn"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierFn' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierFnLock"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierFnLock' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierHyper"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierHyper' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierNumLock"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierNumLock' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierScrollLock"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierScrollLock' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierSuper"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierSuper' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierSymbol"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierSymbol' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "modifierSymbolLock"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'modifierSymbolLock' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "shiftKey"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'shiftKey' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js b/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js new file mode 100644 index 00000000..fc7116d4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js @@ -0,0 +1,259 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventListener = require("./EventListener.js"); +const AddEventListenerOptions = require("./AddEventListenerOptions.js"); +const EventListenerOptions = require("./EventListenerOptions.js"); +const Event = require("./Event.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "EventTarget"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'EventTarget'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["EventTarget"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker", "AudioWorklet"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class EventTarget { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + addEventListener(type, callback) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'addEventListener' called on an object that is not a valid instance of EventTarget." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = EventListener.convert(globalObject, curArg, { + context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 2" + }); + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = AddEventListenerOptions.convert(globalObject, curArg, { + context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3" + }); + } else if (utils.isObject(curArg)) { + curArg = AddEventListenerOptions.convert(globalObject, curArg, { + context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3" + " dictionary" + }); + } else if (typeof curArg === "boolean") { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3", + globals: globalObject + }); + } else { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'addEventListener' on 'EventTarget': parameter 3", + globals: globalObject + }); + } + } + args.push(curArg); + } + return esValue[implSymbol].addEventListener(...args); + } + + removeEventListener(type, callback) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeEventListener' called on an object that is not a valid instance of EventTarget." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = EventListener.convert(globalObject, curArg, { + context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 2" + }); + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = EventListenerOptions.convert(globalObject, curArg, { + context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3" + }); + } else if (utils.isObject(curArg)) { + curArg = EventListenerOptions.convert(globalObject, curArg, { + context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3" + " dictionary" + }); + } else if (typeof curArg === "boolean") { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3", + globals: globalObject + }); + } else { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'removeEventListener' on 'EventTarget': parameter 3", + globals: globalObject + }); + } + } + args.push(curArg); + } + return esValue[implSymbol].removeEventListener(...args); + } + + dispatchEvent(event) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'dispatchEvent' called on an object that is not a valid instance of EventTarget." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Event.convert(globalObject, curArg, { + context: "Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].dispatchEvent(...args); + } + } + Object.defineProperties(EventTarget.prototype, { + addEventListener: { enumerable: true }, + removeEventListener: { enumerable: true }, + dispatchEvent: { enumerable: true }, + [Symbol.toStringTag]: { value: "EventTarget", configurable: true } + }); + ctorRegistry[interfaceName] = EventTarget; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: EventTarget + }); +}; + +const Impl = require("../events/EventTarget-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/External.js b/node_modules/jsdom/lib/jsdom/living/generated/External.js new file mode 100644 index 00000000..5f813d0d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/External.js @@ -0,0 +1,130 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "External"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'External'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["External"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class External { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + AddSearchProvider() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'AddSearchProvider' called on an object that is not a valid instance of External." + ); + } + + return esValue[implSymbol].AddSearchProvider(); + } + + IsSearchProviderInstalled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'IsSearchProviderInstalled' called on an object that is not a valid instance of External." + ); + } + + return esValue[implSymbol].IsSearchProviderInstalled(); + } + } + Object.defineProperties(External.prototype, { + AddSearchProvider: { enumerable: true }, + IsSearchProviderInstalled: { enumerable: true }, + [Symbol.toStringTag]: { value: "External", configurable: true } + }); + ctorRegistry[interfaceName] = External; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: External + }); +}; + +const Impl = require("../window/External-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/File.js b/node_modules/jsdom/lib/jsdom/living/generated/File.js new file mode 100644 index 00000000..0ac0e68c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/File.js @@ -0,0 +1,177 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Blob = require("./Blob.js"); +const FilePropertyBag = require("./FilePropertyBag.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "File"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'File'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["File"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Blob._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class File extends globalObject.Blob { + constructor(fileBits, fileName) { + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError("Failed to construct 'File': parameter 1" + " is not an iterable object."); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + if (Blob.is(nextItem)) { + nextItem = utils.implForWrapper(nextItem); + } else if (utils.isArrayBuffer(nextItem)) { + } else if (ArrayBuffer.isView(nextItem)) { + } else { + nextItem = conversions["USVString"](nextItem, { + context: "Failed to construct 'File': parameter 1" + "'s element", + globals: globalObject + }); + } + V.push(nextItem); + } + curArg = V; + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to construct 'File': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = FilePropertyBag.convert(globalObject, curArg, { context: "Failed to construct 'File': parameter 3" }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of File."); + } + + return esValue[implSymbol]["name"]; + } + + get lastModified() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lastModified' called on an object that is not a valid instance of File." + ); + } + + return esValue[implSymbol]["lastModified"]; + } + } + Object.defineProperties(File.prototype, { + name: { enumerable: true }, + lastModified: { enumerable: true }, + [Symbol.toStringTag]: { value: "File", configurable: true } + }); + ctorRegistry[interfaceName] = File; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: File + }); +}; + +const Impl = require("../file-api/File-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/FileList.js b/node_modules/jsdom/lib/jsdom/living/generated/FileList.js new file mode 100644 index 00000000..f5095a5e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/FileList.js @@ -0,0 +1,324 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "FileList"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'FileList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["FileList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class FileList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of FileList."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'FileList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'FileList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of FileList."); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(FileList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "FileList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = FileList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: FileList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../file-api/FileList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/FilePropertyBag.js b/node_modules/jsdom/lib/jsdom/living/generated/FilePropertyBag.js new file mode 100644 index 00000000..42e0cc6c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/FilePropertyBag.js @@ -0,0 +1,33 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const BlobPropertyBag = require("./BlobPropertyBag.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + BlobPropertyBag._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "lastModified"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long long"](value, { + context: context + " has member 'lastModified' that", + globals: globalObject + }); + + ret[key] = value; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/FileReader.js b/node_modules/jsdom/lib/jsdom/living/generated/FileReader.js new file mode 100644 index 00000000..29ba18fc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/FileReader.js @@ -0,0 +1,468 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Blob = require("./Blob.js"); +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "FileReader"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'FileReader'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["FileReader"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class FileReader extends globalObject.EventTarget { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + readAsArrayBuffer(blob) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'readAsArrayBuffer' called on an object that is not a valid instance of FileReader." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'readAsArrayBuffer' on 'FileReader': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].readAsArrayBuffer(...args); + } + + readAsBinaryString(blob) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'readAsBinaryString' called on an object that is not a valid instance of FileReader." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'readAsBinaryString' on 'FileReader': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].readAsBinaryString(...args); + } + + readAsText(blob) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'readAsText' called on an object that is not a valid instance of FileReader." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'readAsText' on 'FileReader': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'readAsText' on 'FileReader': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'readAsText' on 'FileReader': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].readAsText(...args); + } + + readAsDataURL(blob) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'readAsDataURL' called on an object that is not a valid instance of FileReader." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'readAsDataURL' on 'FileReader': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].readAsDataURL(...args); + } + + abort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'abort' called on an object that is not a valid instance of FileReader."); + } + + return esValue[implSymbol].abort(); + } + + get readyState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readyState' called on an object that is not a valid instance of FileReader." + ); + } + + return esValue[implSymbol]["readyState"]; + } + + get result() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get result' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["result"]); + } + + get error() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get error' called on an object that is not a valid instance of FileReader."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["error"]); + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of FileReader." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'FileReader': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of FileReader." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'FileReader': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onload' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onload' called on an object that is not a valid instance of FileReader." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'FileReader': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of FileReader." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'FileReader': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of FileReader." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'FileReader': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onloadend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadend' called on an object that is not a valid instance of FileReader." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]); + } + + set onloadend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadend' called on an object that is not a valid instance of FileReader." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadend' property on 'FileReader': The provided value" + }); + } + esValue[implSymbol]["onloadend"] = V; + } + } + Object.defineProperties(FileReader.prototype, { + readAsArrayBuffer: { enumerable: true }, + readAsBinaryString: { enumerable: true }, + readAsText: { enumerable: true }, + readAsDataURL: { enumerable: true }, + abort: { enumerable: true }, + readyState: { enumerable: true }, + result: { enumerable: true }, + error: { enumerable: true }, + onloadstart: { enumerable: true }, + onprogress: { enumerable: true }, + onload: { enumerable: true }, + onabort: { enumerable: true }, + onerror: { enumerable: true }, + onloadend: { enumerable: true }, + [Symbol.toStringTag]: { value: "FileReader", configurable: true }, + EMPTY: { value: 0, enumerable: true }, + LOADING: { value: 1, enumerable: true }, + DONE: { value: 2, enumerable: true } + }); + Object.defineProperties(FileReader, { + EMPTY: { value: 0, enumerable: true }, + LOADING: { value: 1, enumerable: true }, + DONE: { value: 2, enumerable: true } + }); + ctorRegistry[interfaceName] = FileReader; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: FileReader + }); +}; + +const Impl = require("../file-api/FileReader-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/FocusEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/FocusEvent.js new file mode 100644 index 00000000..bb690b12 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/FocusEvent.js @@ -0,0 +1,144 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const FocusEventInit = require("./FocusEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "FocusEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'FocusEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["FocusEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class FocusEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'FocusEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'FocusEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = FocusEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'FocusEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get relatedTarget() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get relatedTarget' called on an object that is not a valid instance of FocusEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["relatedTarget"]); + } + } + Object.defineProperties(FocusEvent.prototype, { + relatedTarget: { enumerable: true }, + [Symbol.toStringTag]: { value: "FocusEvent", configurable: true } + }); + ctorRegistry[interfaceName] = FocusEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: FocusEvent + }); +}; + +const Impl = require("../events/FocusEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/FocusEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/FocusEventInit.js new file mode 100644 index 00000000..9fcc3d4d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/FocusEventInit.js @@ -0,0 +1,36 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventTarget = require("./EventTarget.js"); +const UIEventInit = require("./UIEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + UIEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "relatedTarget"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = EventTarget.convert(globalObject, value, { context: context + " has member 'relatedTarget' that" }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/FormData.js b/node_modules/jsdom/lib/jsdom/living/generated/FormData.js new file mode 100644 index 00000000..245a36a9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/FormData.js @@ -0,0 +1,452 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLFormElement = require("./HTMLFormElement.js"); +const Blob = require("./Blob.js"); +const Function = require("./Function.js"); +const newObjectInRealm = utils.newObjectInRealm; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "FormData"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'FormData'.`); +}; + +exports.createDefaultIterator = (globalObject, target, kind) => { + const ctorRegistry = globalObject[ctorRegistrySymbol]; + const iteratorPrototype = ctorRegistry["FormData Iterator"]; + const iterator = Object.create(iteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, index: 0 }, + configurable: true + }); + return iterator; +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["FormData"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class FormData { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = HTMLFormElement.convert(globalObject, curArg, { + context: "Failed to construct 'FormData': parameter 1" + }); + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + append(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'append' called on an object that is not a valid instance of FormData."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'append' on 'FormData': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + switch (arguments.length) { + case 2: + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'append' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (Blob.is(curArg)) { + { + let curArg = arguments[1]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'append' on 'FormData': parameter 2" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'append' on 'FormData': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + } + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'append' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'append' on 'FormData': parameter 2" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'append' on 'FormData': parameter 3", + globals: globalObject + }); + } + args.push(curArg); + } + } + return esValue[implSymbol].append(...args); + } + + delete(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'delete' called on an object that is not a valid instance of FormData."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'delete' on 'FormData': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'delete' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].delete(...args); + } + + get(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get' called on an object that is not a valid instance of FormData."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'get' on 'FormData': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'get' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].get(...args)); + } + + getAll(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getAll' called on an object that is not a valid instance of FormData."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getAll' on 'FormData': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'getAll' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args)); + } + + has(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'has' called on an object that is not a valid instance of FormData."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'has' on 'FormData': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'has' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].has(...args); + } + + set(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set' called on an object that is not a valid instance of FormData."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'set' on 'FormData': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + switch (arguments.length) { + case 2: + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'set' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (Blob.is(curArg)) { + { + let curArg = arguments[1]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'set' on 'FormData': parameter 2" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'set' on 'FormData': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + } + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'set' on 'FormData': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'set' on 'FormData': parameter 2" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'set' on 'FormData': parameter 3", + globals: globalObject + }); + } + args.push(curArg); + } + } + return esValue[implSymbol].set(...args); + } + + keys() { + if (!exports.is(this)) { + throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of FormData."); + } + return exports.createDefaultIterator(globalObject, this, "key"); + } + + values() { + if (!exports.is(this)) { + throw new globalObject.TypeError("'values' called on an object that is not a valid instance of FormData."); + } + return exports.createDefaultIterator(globalObject, this, "value"); + } + + entries() { + if (!exports.is(this)) { + throw new globalObject.TypeError("'entries' called on an object that is not a valid instance of FormData."); + } + return exports.createDefaultIterator(globalObject, this, "key+value"); + } + + forEach(callback) { + if (!exports.is(this)) { + throw new globalObject.TypeError("'forEach' called on an object that is not a valid instance of FormData."); + } + if (arguments.length < 1) { + throw new globalObject.TypeError( + "Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present." + ); + } + callback = Function.convert(globalObject, callback, { + context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1" + }); + const thisArg = arguments[1]; + let pairs = Array.from(this[implSymbol]); + let i = 0; + while (i < pairs.length) { + const [key, value] = pairs[i].map(utils.tryWrapperForImpl); + callback.call(thisArg, value, key, this); + pairs = Array.from(this[implSymbol]); + i++; + } + } + } + Object.defineProperties(FormData.prototype, { + append: { enumerable: true }, + delete: { enumerable: true }, + get: { enumerable: true }, + getAll: { enumerable: true }, + has: { enumerable: true }, + set: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + forEach: { enumerable: true }, + [Symbol.toStringTag]: { value: "FormData", configurable: true }, + [Symbol.iterator]: { value: FormData.prototype.entries, configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = FormData; + + ctorRegistry["FormData Iterator"] = Object.create(ctorRegistry["%IteratorPrototype%"], { + [Symbol.toStringTag]: { + configurable: true, + value: "FormData Iterator" + } + }); + utils.define(ctorRegistry["FormData Iterator"], { + next() { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + throw new globalObject.TypeError("next() called on a value that is not a FormData iterator object"); + } + + const { target, kind, index } = internal; + const values = Array.from(target[implSymbol]); + const len = values.length; + if (index >= len) { + return newObjectInRealm(globalObject, { value: undefined, done: true }); + } + + const pair = values[index]; + internal.index = index + 1; + return newObjectInRealm(globalObject, utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind)); + } + }); + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: FormData + }); +}; + +const Impl = require("../xhr/FormData-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Function.js b/node_modules/jsdom/lib/jsdom/living/generated/Function.js new file mode 100644 index 00000000..ea8712fd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Function.js @@ -0,0 +1,42 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (typeof value !== "function") { + throw new globalObject.TypeError(context + " is not a function"); + } + + function invokeTheCallbackFunction(...args) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + for (let i = 0; i < args.length; i++) { + args[i] = utils.tryWrapperForImpl(args[i]); + } + + callResult = Reflect.apply(value, thisArg, args); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + } + + invokeTheCallbackFunction.construct = (...args) => { + for (let i = 0; i < args.length; i++) { + args[i] = utils.tryWrapperForImpl(args[i]); + } + + let callResult = Reflect.construct(value, args); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/GetRootNodeOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/GetRootNodeOptions.js new file mode 100644 index 00000000..524a5227 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/GetRootNodeOptions.js @@ -0,0 +1,31 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "composed"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'composed' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLAnchorElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLAnchorElement.js new file mode 100644 index 00000000..10ff8763 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLAnchorElement.js @@ -0,0 +1,1023 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLAnchorElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLAnchorElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLAnchorElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLAnchorElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "target"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set target(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set target' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'target' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "target", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get download() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get download' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "download"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set download(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set download' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'download' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "download", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rel' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rel"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rel' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rel' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rel", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get relList() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get relList' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + return utils.getSameObject(this, "relList", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["relList"]); + }); + } + + set relList(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set relList' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + const Q = esValue["relList"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'relList' is not an object"); + } + Reflect.set(Q, "value", V); + } + + get hreflang() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hreflang' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "hreflang"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hreflang(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hreflang' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'hreflang' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "hreflang", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get text() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get text' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["text"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set text(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set text' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'text' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["text"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get coords() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get coords' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "coords"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set coords(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set coords' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'coords' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "coords", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get charset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get charset' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charset"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set charset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set charset' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'charset' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charset", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rev() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rev' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rev"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rev(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rev' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rev' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rev", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get shape() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shape' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "shape"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set shape(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set shape' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'shape' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "shape", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get href' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["href"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set href' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'href' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["href"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + toString() { + const esValue = this; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'toString' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["href"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get origin' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + return esValue[implSymbol]["origin"]; + } + + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get protocol' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["protocol"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set protocol(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set protocol' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'protocol' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["protocol"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get username() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get username' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["username"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set username(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set username' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'username' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["username"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get password() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get password' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["password"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set password(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set password' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'password' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["password"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get host() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get host' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["host"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set host(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set host' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'host' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["host"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hostname() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hostname' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["hostname"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hostname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hostname' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'hostname' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["hostname"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get port() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get port' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["port"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set port(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set port' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'port' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["port"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get pathname() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pathname' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["pathname"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set pathname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set pathname' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'pathname' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["pathname"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get search() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get search' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["search"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set search(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set search' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'search' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["search"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hash() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hash' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["hash"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hash(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hash' called on an object that is not a valid instance of HTMLAnchorElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'hash' property on 'HTMLAnchorElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["hash"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLAnchorElement.prototype, { + target: { enumerable: true }, + download: { enumerable: true }, + rel: { enumerable: true }, + relList: { enumerable: true }, + hreflang: { enumerable: true }, + type: { enumerable: true }, + text: { enumerable: true }, + coords: { enumerable: true }, + charset: { enumerable: true }, + name: { enumerable: true }, + rev: { enumerable: true }, + shape: { enumerable: true }, + href: { enumerable: true }, + toString: { enumerable: true }, + origin: { enumerable: true }, + protocol: { enumerable: true }, + username: { enumerable: true }, + password: { enumerable: true }, + host: { enumerable: true }, + hostname: { enumerable: true }, + port: { enumerable: true }, + pathname: { enumerable: true }, + search: { enumerable: true }, + hash: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLAnchorElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLAnchorElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLAnchorElement + }); +}; + +const Impl = require("../nodes/HTMLAnchorElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLAreaElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLAreaElement.js new file mode 100644 index 00000000..d12c0296 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLAreaElement.js @@ -0,0 +1,822 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLAreaElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLAreaElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLAreaElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLAreaElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get alt() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get alt' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "alt"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set alt(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set alt' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'alt' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "alt", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get coords() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get coords' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "coords"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set coords(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set coords' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'coords' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "coords", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get shape() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shape' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "shape"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set shape(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set shape' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'shape' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "shape", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "target"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set target(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set target' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'target' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "target", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rel' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rel"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rel' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rel' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rel", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get relList() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get relList' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + return utils.getSameObject(this, "relList", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["relList"]); + }); + } + + set relList(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set relList' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + const Q = esValue["relList"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'relList' is not an object"); + } + Reflect.set(Q, "value", V); + } + + get noHref() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get noHref' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "nohref"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set noHref(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set noHref' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'noHref' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "nohref", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "nohref"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get href' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["href"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set href' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'href' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["href"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + toString() { + const esValue = this; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'toString' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["href"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get origin' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + return esValue[implSymbol]["origin"]; + } + + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get protocol' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["protocol"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set protocol(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set protocol' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'protocol' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["protocol"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get username() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get username' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["username"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set username(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set username' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'username' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["username"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get password() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get password' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["password"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set password(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set password' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'password' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["password"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get host() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get host' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["host"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set host(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set host' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'host' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["host"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hostname() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hostname' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["hostname"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hostname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hostname' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'hostname' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["hostname"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get port() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get port' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["port"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set port(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set port' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'port' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["port"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get pathname() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pathname' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["pathname"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set pathname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set pathname' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'pathname' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["pathname"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get search() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get search' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["search"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set search(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set search' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'search' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["search"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hash() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hash' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["hash"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hash(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hash' called on an object that is not a valid instance of HTMLAreaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'hash' property on 'HTMLAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["hash"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLAreaElement.prototype, { + alt: { enumerable: true }, + coords: { enumerable: true }, + shape: { enumerable: true }, + target: { enumerable: true }, + rel: { enumerable: true }, + relList: { enumerable: true }, + noHref: { enumerable: true }, + href: { enumerable: true }, + toString: { enumerable: true }, + origin: { enumerable: true }, + protocol: { enumerable: true }, + username: { enumerable: true }, + password: { enumerable: true }, + host: { enumerable: true }, + hostname: { enumerable: true }, + port: { enumerable: true }, + pathname: { enumerable: true }, + search: { enumerable: true }, + hash: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLAreaElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLAreaElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLAreaElement + }); +}; + +const Impl = require("../nodes/HTMLAreaElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLAudioElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLAudioElement.js new file mode 100644 index 00000000..c286bfb8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLAudioElement.js @@ -0,0 +1,110 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLMediaElement = require("./HTMLMediaElement.js"); + +const interfaceName = "HTMLAudioElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLAudioElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLAudioElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLMediaElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLAudioElement extends globalObject.HTMLMediaElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + } + Object.defineProperties(HTMLAudioElement.prototype, { + [Symbol.toStringTag]: { value: "HTMLAudioElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLAudioElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLAudioElement + }); +}; + +const Impl = require("../nodes/HTMLAudioElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLBRElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLBRElement.js new file mode 100644 index 00000000..a8e54315 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLBRElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLBRElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLBRElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLBRElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLBRElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get clear() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clear' called on an object that is not a valid instance of HTMLBRElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "clear"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set clear(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set clear' called on an object that is not a valid instance of HTMLBRElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'clear' property on 'HTMLBRElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "clear", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLBRElement.prototype, { + clear: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLBRElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLBRElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLBRElement + }); +}; + +const Impl = require("../nodes/HTMLBRElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLBaseElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLBaseElement.js new file mode 100644 index 00000000..fc8b8468 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLBaseElement.js @@ -0,0 +1,193 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLBaseElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLBaseElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLBaseElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLBaseElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get href' called on an object that is not a valid instance of HTMLBaseElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["href"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set href' called on an object that is not a valid instance of HTMLBaseElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'href' property on 'HTMLBaseElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["href"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of HTMLBaseElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "target"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set target(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set target' called on an object that is not a valid instance of HTMLBaseElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'target' property on 'HTMLBaseElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "target", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLBaseElement.prototype, { + href: { enumerable: true }, + target: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLBaseElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLBaseElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLBaseElement + }); +}; + +const Impl = require("../nodes/HTMLBaseElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLBodyElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLBodyElement.js new file mode 100644 index 00000000..84dafd85 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLBodyElement.js @@ -0,0 +1,877 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLBodyElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLBodyElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLBodyElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLBodyElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get text() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get text' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "text"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set text(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set text' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'text' property on 'HTMLBodyElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "text", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get link() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get link' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "link"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set link(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set link' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'link' property on 'HTMLBodyElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "link", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vLink() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vLink' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "vlink"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vLink(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vLink' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'vLink' property on 'HTMLBodyElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "vlink", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get aLink() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get aLink' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "alink"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set aLink(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set aLink' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'aLink' property on 'HTMLBodyElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "alink", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get bgColor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bgColor' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "bgcolor"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set bgColor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set bgColor' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'bgColor' property on 'HTMLBodyElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "bgcolor", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get background() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get background' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "background"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set background(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set background' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'background' property on 'HTMLBodyElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "background", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get onafterprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onafterprint' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]); + } + + set onafterprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onafterprint' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onafterprint' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onafterprint"] = V; + } + + get onbeforeprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]); + } + + set onbeforeprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeprint' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeprint' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeprint"] = V; + } + + get onbeforeunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeunload' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeunload"]); + } + + set onbeforeunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeunload' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeunload' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeunload"] = V; + } + + get onhashchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onhashchange' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]); + } + + set onhashchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onhashchange' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onhashchange' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onhashchange"] = V; + } + + get onlanguagechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onlanguagechange' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onlanguagechange"]); + } + + set onlanguagechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onlanguagechange' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onlanguagechange' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onlanguagechange"] = V; + } + + get onmessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessage' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]); + } + + set onmessage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessage' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessage' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onmessage"] = V; + } + + get onmessageerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessageerror' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessageerror"]); + } + + set onmessageerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessageerror' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessageerror' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onmessageerror"] = V; + } + + get onoffline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onoffline' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]); + } + + set onoffline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onoffline' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onoffline' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onoffline"] = V; + } + + get ononline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ononline' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]); + } + + set ononline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ononline' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ononline' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["ononline"] = V; + } + + get onpagehide() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpagehide' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]); + } + + set onpagehide(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpagehide' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpagehide' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onpagehide"] = V; + } + + get onpageshow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpageshow' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]); + } + + set onpageshow(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpageshow' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpageshow' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onpageshow"] = V; + } + + get onpopstate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpopstate' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]); + } + + set onpopstate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpopstate' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpopstate' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onpopstate"] = V; + } + + get onrejectionhandled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onrejectionhandled' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onrejectionhandled"]); + } + + set onrejectionhandled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onrejectionhandled' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onrejectionhandled' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onrejectionhandled"] = V; + } + + get onstorage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstorage' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]); + } + + set onstorage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstorage' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstorage' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onstorage"] = V; + } + + get onunhandledrejection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunhandledrejection' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunhandledrejection"]); + } + + set onunhandledrejection(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunhandledrejection' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunhandledrejection' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onunhandledrejection"] = V; + } + + get onunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunload' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]); + } + + set onunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunload' called on an object that is not a valid instance of HTMLBodyElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunload' property on 'HTMLBodyElement': The provided value" + }); + } + esValue[implSymbol]["onunload"] = V; + } + } + Object.defineProperties(HTMLBodyElement.prototype, { + text: { enumerable: true }, + link: { enumerable: true }, + vLink: { enumerable: true }, + aLink: { enumerable: true }, + bgColor: { enumerable: true }, + background: { enumerable: true }, + onafterprint: { enumerable: true }, + onbeforeprint: { enumerable: true }, + onbeforeunload: { enumerable: true }, + onhashchange: { enumerable: true }, + onlanguagechange: { enumerable: true }, + onmessage: { enumerable: true }, + onmessageerror: { enumerable: true }, + onoffline: { enumerable: true }, + ononline: { enumerable: true }, + onpagehide: { enumerable: true }, + onpageshow: { enumerable: true }, + onpopstate: { enumerable: true }, + onrejectionhandled: { enumerable: true }, + onstorage: { enumerable: true }, + onunhandledrejection: { enumerable: true }, + onunload: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLBodyElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLBodyElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLBodyElement + }); +}; + +const Impl = require("../nodes/HTMLBodyElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLButtonElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLButtonElement.js new file mode 100644 index 00000000..6183f0a5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLButtonElement.js @@ -0,0 +1,522 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLButtonElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLButtonElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLButtonElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLButtonElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLButtonElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLButtonElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + get autofocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autofocus' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "autofocus"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autofocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autofocus' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'autofocus' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "autofocus", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "autofocus"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get formNoValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get formNoValidate' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "formnovalidate"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set formNoValidate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set formNoValidate' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'formNoValidate' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "formnovalidate", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "formnovalidate"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get formTarget() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get formTarget' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "formtarget"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set formTarget(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set formTarget' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'formTarget' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "formtarget", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["type"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["type"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "value"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLButtonElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "value", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLButtonElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + } + Object.defineProperties(HTMLButtonElement.prototype, { + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + autofocus: { enumerable: true }, + disabled: { enumerable: true }, + form: { enumerable: true }, + formNoValidate: { enumerable: true }, + formTarget: { enumerable: true }, + name: { enumerable: true }, + type: { enumerable: true }, + value: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + labels: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLButtonElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLButtonElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLButtonElement + }); +}; + +const Impl = require("../nodes/HTMLButtonElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js new file mode 100644 index 00000000..fddaa1e2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js @@ -0,0 +1,304 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const BlobCallback = require("./BlobCallback.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLCanvasElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLCanvasElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLCanvasElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLCanvasElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + getContext(contextId) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getContext' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getContext' on 'HTMLCanvasElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getContext' on 'HTMLCanvasElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions["any"](curArg, { + context: "Failed to execute 'getContext' on 'HTMLCanvasElement': parameter " + (i + 1), + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getContext(...args)); + } + + toDataURL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'toDataURL' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["any"](curArg, { + context: "Failed to execute 'toDataURL' on 'HTMLCanvasElement': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].toDataURL(...args); + } + + toBlob(callback) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'toBlob' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = BlobCallback.convert(globalObject, curArg, { + context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["any"](curArg, { + context: "Failed to execute 'toBlob' on 'HTMLCanvasElement': parameter 3", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].toBlob(...args); + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["width"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'width' property on 'HTMLCanvasElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["width"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["height"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLCanvasElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'height' property on 'HTMLCanvasElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["height"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLCanvasElement.prototype, { + getContext: { enumerable: true }, + toDataURL: { enumerable: true }, + toBlob: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLCanvasElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLCanvasElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLCanvasElement + }); +}; + +const Impl = require("../nodes/HTMLCanvasElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLCollection.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLCollection.js new file mode 100644 index 00000000..cc33de80 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLCollection.js @@ -0,0 +1,378 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "HTMLCollection"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLCollection'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLCollection"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLCollection { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of HTMLCollection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'HTMLCollection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'HTMLCollection': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'namedItem' called on an object that is not a valid instance of HTMLCollection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'HTMLCollection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'HTMLCollection': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of HTMLCollection." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(HTMLCollection.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLCollection", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = HTMLCollection; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLCollection + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + const namedValue = target[implSymbol].namedItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: false, + enumerable: false, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + if (!utils.hasOwn(target, P)) { + const creating = !(target[implSymbol].namedItem(P) !== null); + if (!creating) { + return false; + } + } + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/HTMLCollection-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDListElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDListElement.js new file mode 100644 index 00000000..54ba16c1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDListElement.js @@ -0,0 +1,156 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDListElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDListElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDListElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDListElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get compact() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get compact' called on an object that is not a valid instance of HTMLDListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "compact"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set compact(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set compact' called on an object that is not a valid instance of HTMLDListElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'compact' property on 'HTMLDListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "compact", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "compact"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLDListElement.prototype, { + compact: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDListElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDListElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDListElement + }); +}; + +const Impl = require("../nodes/HTMLDListElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDataElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDataElement.js new file mode 100644 index 00000000..7e72ce87 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDataElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDataElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDataElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDataElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDataElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLDataElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "value"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLDataElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLDataElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "value", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLDataElement.prototype, { + value: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDataElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDataElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDataElement + }); +}; + +const Impl = require("../nodes/HTMLDataElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDataListElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDataListElement.js new file mode 100644 index 00000000..416decd3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDataListElement.js @@ -0,0 +1,125 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDataListElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDataListElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDataListElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDataListElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get options() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get options' called on an object that is not a valid instance of HTMLDataListElement." + ); + } + + return utils.getSameObject(this, "options", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["options"]); + }); + } + } + Object.defineProperties(HTMLDataListElement.prototype, { + options: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDataListElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDataListElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDataListElement + }); +}; + +const Impl = require("../nodes/HTMLDataListElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDetailsElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDetailsElement.js new file mode 100644 index 00000000..0cf42f83 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDetailsElement.js @@ -0,0 +1,156 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDetailsElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDetailsElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDetailsElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDetailsElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get open() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get open' called on an object that is not a valid instance of HTMLDetailsElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "open"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set open(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set open' called on an object that is not a valid instance of HTMLDetailsElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'open' property on 'HTMLDetailsElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "open", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "open"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLDetailsElement.prototype, { + open: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDetailsElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDetailsElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDetailsElement + }); +}; + +const Impl = require("../nodes/HTMLDetailsElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDialogElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDialogElement.js new file mode 100644 index 00000000..e87f110b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDialogElement.js @@ -0,0 +1,156 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDialogElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDialogElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDialogElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDialogElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get open() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get open' called on an object that is not a valid instance of HTMLDialogElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "open"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set open(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set open' called on an object that is not a valid instance of HTMLDialogElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'open' property on 'HTMLDialogElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "open", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "open"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLDialogElement.prototype, { + open: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDialogElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDialogElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDialogElement + }); +}; + +const Impl = require("../nodes/HTMLDialogElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDirectoryElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDirectoryElement.js new file mode 100644 index 00000000..5edbe417 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDirectoryElement.js @@ -0,0 +1,156 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDirectoryElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDirectoryElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDirectoryElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDirectoryElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get compact() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get compact' called on an object that is not a valid instance of HTMLDirectoryElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "compact"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set compact(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set compact' called on an object that is not a valid instance of HTMLDirectoryElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'compact' property on 'HTMLDirectoryElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "compact", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "compact"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLDirectoryElement.prototype, { + compact: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDirectoryElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDirectoryElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDirectoryElement + }); +}; + +const Impl = require("../nodes/HTMLDirectoryElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLDivElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDivElement.js new file mode 100644 index 00000000..a6321837 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLDivElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLDivElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLDivElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLDivElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLDivElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLDivElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLDivElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLDivElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLDivElement.prototype, { + align: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLDivElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLDivElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLDivElement + }); +}; + +const Impl = require("../nodes/HTMLDivElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js new file mode 100644 index 00000000..4bf1e185 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js @@ -0,0 +1,2549 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnErrorEventHandlerNonNull = require("./OnErrorEventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Element = require("./Element.js"); + +const interfaceName = "HTMLElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Element._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLElement extends globalObject.Element { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + click() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'click' called on an object that is not a valid instance of HTMLElement."); + } + + return esValue[implSymbol].click(); + } + + focus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'focus' called on an object that is not a valid instance of HTMLElement."); + } + + return esValue[implSymbol].focus(); + } + + blur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'blur' called on an object that is not a valid instance of HTMLElement."); + } + + return esValue[implSymbol].blur(); + } + + get title() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get title' called on an object that is not a valid instance of HTMLElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "title"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set title(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set title' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'title' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "title", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get lang() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get lang' called on an object that is not a valid instance of HTMLElement."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "lang"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set lang(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set lang' called on an object that is not a valid instance of HTMLElement."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'lang' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "lang", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get translate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get translate' called on an object that is not a valid instance of HTMLElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["translate"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set translate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set translate' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'translate' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["translate"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get dir() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get dir' called on an object that is not a valid instance of HTMLElement."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["dir"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set dir(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set dir' called on an object that is not a valid instance of HTMLElement."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'dir' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["dir"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hidden() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hidden' called on an object that is not a valid instance of HTMLElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "hidden"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hidden(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hidden' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'hidden' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "hidden", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "hidden"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get accessKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get accessKey' called on an object that is not a valid instance of HTMLElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "accesskey"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set accessKey(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set accessKey' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'accessKey' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "accesskey", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get draggable() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get draggable' called on an object that is not a valid instance of HTMLElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["draggable"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set draggable(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set draggable' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'draggable' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["draggable"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get offsetParent() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get offsetParent' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["offsetParent"]); + } + + get offsetTop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get offsetTop' called on an object that is not a valid instance of HTMLElement." + ); + } + + return esValue[implSymbol]["offsetTop"]; + } + + get offsetLeft() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get offsetLeft' called on an object that is not a valid instance of HTMLElement." + ); + } + + return esValue[implSymbol]["offsetLeft"]; + } + + get offsetWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get offsetWidth' called on an object that is not a valid instance of HTMLElement." + ); + } + + return esValue[implSymbol]["offsetWidth"]; + } + + get offsetHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get offsetHeight' called on an object that is not a valid instance of HTMLElement." + ); + } + + return esValue[implSymbol]["offsetHeight"]; + } + + get style() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get style' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.getSameObject(this, "style", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["style"]); + }); + } + + set style(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set style' called on an object that is not a valid instance of HTMLElement." + ); + } + + const Q = esValue["style"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'style' is not an object"); + } + Reflect.set(Q, "cssText", V); + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onauxclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onauxclick' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onauxclick"]); + } + + set onauxclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onauxclick' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onauxclick' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onauxclick"] = V; + } + + get onblur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onblur' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onblur"]); + } + + set onblur(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onblur' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onblur' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onblur"] = V; + } + + get oncancel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncancel' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncancel"]); + } + + set oncancel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncancel' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncancel' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oncancel"] = V; + } + + get oncanplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplay' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplay"]); + } + + set oncanplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplay' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplay' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oncanplay"] = V; + } + + get oncanplaythrough() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplaythrough' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplaythrough"]); + } + + set oncanplaythrough(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplaythrough' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplaythrough' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oncanplaythrough"] = V; + } + + get onchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onchange' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onchange"]); + } + + set onchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onchange' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onchange' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onchange"] = V; + } + + get onclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclick' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclick"]); + } + + set onclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclick' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclick' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onclick"] = V; + } + + get onclose() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclose' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclose"]); + } + + set onclose(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclose' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclose' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onclose"] = V; + } + + get oncontextmenu() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncontextmenu' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncontextmenu"]); + } + + set oncontextmenu(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncontextmenu' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncontextmenu' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oncontextmenu"] = V; + } + + get oncuechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncuechange' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncuechange"]); + } + + set oncuechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncuechange' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncuechange' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oncuechange"] = V; + } + + get ondblclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondblclick' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondblclick"]); + } + + set ondblclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondblclick' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondblclick' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondblclick"] = V; + } + + get ondrag() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondrag' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrag"]); + } + + set ondrag(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondrag' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrag' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondrag"] = V; + } + + get ondragend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragend' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragend"]); + } + + set ondragend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragend' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragend' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondragend"] = V; + } + + get ondragenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragenter' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragenter"]); + } + + set ondragenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragenter' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragenter' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondragenter"] = V; + } + + get ondragleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragleave' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragleave"]); + } + + set ondragleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragleave' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragleave' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondragleave"] = V; + } + + get ondragover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragover' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragover"]); + } + + set ondragover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragover' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragover' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondragover"] = V; + } + + get ondragstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragstart' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragstart"]); + } + + set ondragstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragstart' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragstart' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondragstart"] = V; + } + + get ondrop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondrop' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrop"]); + } + + set ondrop(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondrop' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrop' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondrop"] = V; + } + + get ondurationchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondurationchange' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondurationchange"]); + } + + set ondurationchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondurationchange' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondurationchange' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ondurationchange"] = V; + } + + get onemptied() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onemptied' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onemptied"]); + } + + set onemptied(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onemptied' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onemptied' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onemptied"] = V; + } + + get onended() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onended' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onended"]); + } + + set onended(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onended' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onended' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onended"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnErrorEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onfocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onfocus' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onfocus"]); + } + + set onfocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onfocus' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onfocus' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onfocus"] = V; + } + + get oninput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninput' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninput"]); + } + + set oninput(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninput' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninput' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oninput"] = V; + } + + get oninvalid() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninvalid' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninvalid"]); + } + + set oninvalid(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninvalid' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninvalid' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["oninvalid"] = V; + } + + get onkeydown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeydown' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeydown"]); + } + + set onkeydown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeydown' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeydown' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onkeydown"] = V; + } + + get onkeypress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeypress' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeypress"]); + } + + set onkeypress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeypress' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeypress' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onkeypress"] = V; + } + + get onkeyup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeyup' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeyup"]); + } + + set onkeyup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeyup' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeyup' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onkeyup"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onload' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onload' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get onloadeddata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadeddata' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadeddata"]); + } + + set onloadeddata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadeddata' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadeddata' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onloadeddata"] = V; + } + + get onloadedmetadata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadedmetadata' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadedmetadata"]); + } + + set onloadedmetadata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadedmetadata' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadedmetadata' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onloadedmetadata"] = V; + } + + get onloadend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadend' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]); + } + + set onloadend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadend' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadend' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onloadend"] = V; + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onmousedown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousedown' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousedown"]); + } + + set onmousedown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousedown' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousedown' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmousedown"] = V; + } + + get onmouseenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseenter"]); + } + + set onmouseenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseenter' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmouseenter"] = V; + } + + get onmouseleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseleave"]); + } + + set onmouseleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseleave' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmouseleave"] = V; + } + + get onmousemove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousemove' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousemove"]); + } + + set onmousemove(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousemove' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousemove' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmousemove"] = V; + } + + get onmouseout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseout' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseout"]); + } + + set onmouseout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseout' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseout' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmouseout"] = V; + } + + get onmouseover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseover' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseover"]); + } + + set onmouseover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseover' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseover' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmouseover"] = V; + } + + get onmouseup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseup' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseup"]); + } + + set onmouseup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseup' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseup' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onmouseup"] = V; + } + + get onwheel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwheel' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwheel"]); + } + + set onwheel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwheel' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwheel' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onwheel"] = V; + } + + get onpause() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpause' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpause"]); + } + + set onpause(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpause' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpause' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onpause"] = V; + } + + get onplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplay' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplay"]); + } + + set onplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplay' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplay' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onplay"] = V; + } + + get onplaying() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplaying' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplaying"]); + } + + set onplaying(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplaying' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplaying' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onplaying"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onratechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onratechange' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onratechange"]); + } + + set onratechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onratechange' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onratechange' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onratechange"] = V; + } + + get onreset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onreset' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreset"]); + } + + set onreset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onreset' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreset' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onreset"] = V; + } + + get onresize() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onresize' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onresize"]); + } + + set onresize(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onresize' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onresize' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onresize"] = V; + } + + get onscroll() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onscroll' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onscroll"]); + } + + set onscroll(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onscroll' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onscroll' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onscroll"] = V; + } + + get onsecuritypolicyviolation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsecuritypolicyviolation' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsecuritypolicyviolation"]); + } + + set onsecuritypolicyviolation(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsecuritypolicyviolation' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsecuritypolicyviolation' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onsecuritypolicyviolation"] = V; + } + + get onseeked() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeked' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeked"]); + } + + set onseeked(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeked' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeked' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onseeked"] = V; + } + + get onseeking() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeking' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeking"]); + } + + set onseeking(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeking' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeking' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onseeking"] = V; + } + + get onselect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onselect' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onselect"]); + } + + set onselect(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onselect' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onselect' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onselect"] = V; + } + + get onstalled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstalled' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstalled"]); + } + + set onstalled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstalled' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstalled' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onstalled"] = V; + } + + get onsubmit() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsubmit' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsubmit"]); + } + + set onsubmit(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsubmit' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsubmit' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onsubmit"] = V; + } + + get onsuspend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsuspend' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsuspend"]); + } + + set onsuspend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsuspend' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsuspend' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onsuspend"] = V; + } + + get ontimeupdate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontimeupdate' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontimeupdate"]); + } + + set ontimeupdate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontimeupdate' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontimeupdate' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ontimeupdate"] = V; + } + + get ontoggle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontoggle' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontoggle"]); + } + + set ontoggle(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontoggle' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontoggle' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["ontoggle"] = V; + } + + get onvolumechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onvolumechange' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onvolumechange"]); + } + + set onvolumechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onvolumechange' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onvolumechange' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onvolumechange"] = V; + } + + get onwaiting() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwaiting' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwaiting"]); + } + + set onwaiting(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwaiting' called on an object that is not a valid instance of HTMLElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwaiting' property on 'HTMLElement': The provided value" + }); + } + esValue[implSymbol]["onwaiting"] = V; + } + + get dataset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dataset' called on an object that is not a valid instance of HTMLElement." + ); + } + + return utils.getSameObject(this, "dataset", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["dataset"]); + }); + } + + get nonce() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get nonce' called on an object that is not a valid instance of HTMLElement." + ); + } + + const value = esValue[implSymbol].getAttributeNS(null, "nonce"); + return value === null ? "" : value; + } + + set nonce(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set nonce' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'nonce' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol].setAttributeNS(null, "nonce", V); + } + + get tabIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tabIndex' called on an object that is not a valid instance of HTMLElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["tabIndex"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set tabIndex(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set tabIndex' called on an object that is not a valid instance of HTMLElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'tabIndex' property on 'HTMLElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["tabIndex"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLElement.prototype, { + click: { enumerable: true }, + focus: { enumerable: true }, + blur: { enumerable: true }, + title: { enumerable: true }, + lang: { enumerable: true }, + translate: { enumerable: true }, + dir: { enumerable: true }, + hidden: { enumerable: true }, + accessKey: { enumerable: true }, + draggable: { enumerable: true }, + offsetParent: { enumerable: true }, + offsetTop: { enumerable: true }, + offsetLeft: { enumerable: true }, + offsetWidth: { enumerable: true }, + offsetHeight: { enumerable: true }, + style: { enumerable: true }, + onabort: { enumerable: true }, + onauxclick: { enumerable: true }, + onblur: { enumerable: true }, + oncancel: { enumerable: true }, + oncanplay: { enumerable: true }, + oncanplaythrough: { enumerable: true }, + onchange: { enumerable: true }, + onclick: { enumerable: true }, + onclose: { enumerable: true }, + oncontextmenu: { enumerable: true }, + oncuechange: { enumerable: true }, + ondblclick: { enumerable: true }, + ondrag: { enumerable: true }, + ondragend: { enumerable: true }, + ondragenter: { enumerable: true }, + ondragleave: { enumerable: true }, + ondragover: { enumerable: true }, + ondragstart: { enumerable: true }, + ondrop: { enumerable: true }, + ondurationchange: { enumerable: true }, + onemptied: { enumerable: true }, + onended: { enumerable: true }, + onerror: { enumerable: true }, + onfocus: { enumerable: true }, + oninput: { enumerable: true }, + oninvalid: { enumerable: true }, + onkeydown: { enumerable: true }, + onkeypress: { enumerable: true }, + onkeyup: { enumerable: true }, + onload: { enumerable: true }, + onloadeddata: { enumerable: true }, + onloadedmetadata: { enumerable: true }, + onloadend: { enumerable: true }, + onloadstart: { enumerable: true }, + onmousedown: { enumerable: true }, + onmouseenter: { enumerable: true }, + onmouseleave: { enumerable: true }, + onmousemove: { enumerable: true }, + onmouseout: { enumerable: true }, + onmouseover: { enumerable: true }, + onmouseup: { enumerable: true }, + onwheel: { enumerable: true }, + onpause: { enumerable: true }, + onplay: { enumerable: true }, + onplaying: { enumerable: true }, + onprogress: { enumerable: true }, + onratechange: { enumerable: true }, + onreset: { enumerable: true }, + onresize: { enumerable: true }, + onscroll: { enumerable: true }, + onsecuritypolicyviolation: { enumerable: true }, + onseeked: { enumerable: true }, + onseeking: { enumerable: true }, + onselect: { enumerable: true }, + onstalled: { enumerable: true }, + onsubmit: { enumerable: true }, + onsuspend: { enumerable: true }, + ontimeupdate: { enumerable: true }, + ontoggle: { enumerable: true }, + onvolumechange: { enumerable: true }, + onwaiting: { enumerable: true }, + dataset: { enumerable: true }, + nonce: { enumerable: true }, + tabIndex: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLElement + }); +}; + +const Impl = require("../nodes/HTMLElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLEmbedElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLEmbedElement.js new file mode 100644 index 00000000..96ae19a1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLEmbedElement.js @@ -0,0 +1,371 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLEmbedElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLEmbedElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLEmbedElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLEmbedElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLEmbedElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLEmbedElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLEmbedElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "height"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'height' property on 'HTMLEmbedElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "height", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLEmbedElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLEmbedElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLEmbedElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLEmbedElement.prototype, { + src: { enumerable: true }, + type: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + align: { enumerable: true }, + name: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLEmbedElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLEmbedElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLEmbedElement + }); +}; + +const Impl = require("../nodes/HTMLEmbedElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLFieldSetElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFieldSetElement.js new file mode 100644 index 00000000..855774d0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFieldSetElement.js @@ -0,0 +1,329 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLFieldSetElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLFieldSetElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLFieldSetElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLFieldSetElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLFieldSetElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLFieldSetElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLFieldSetElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLFieldSetElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return esValue[implSymbol]["type"]; + } + + get elements() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get elements' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return utils.getSameObject(this, "elements", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["elements"]); + }); + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return utils.getSameObject(this, "validity", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + }); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLFieldSetElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + } + Object.defineProperties(HTMLFieldSetElement.prototype, { + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + disabled: { enumerable: true }, + form: { enumerable: true }, + name: { enumerable: true }, + type: { enumerable: true }, + elements: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLFieldSetElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLFieldSetElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLFieldSetElement + }); +}; + +const Impl = require("../nodes/HTMLFieldSetElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLFontElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFontElement.js new file mode 100644 index 00000000..48a179d7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFontElement.js @@ -0,0 +1,236 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLFontElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLFontElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLFontElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLFontElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get color() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get color' called on an object that is not a valid instance of HTMLFontElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "color"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set color(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set color' called on an object that is not a valid instance of HTMLFontElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'color' property on 'HTMLFontElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "color", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get face() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get face' called on an object that is not a valid instance of HTMLFontElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "face"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set face(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set face' called on an object that is not a valid instance of HTMLFontElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'face' property on 'HTMLFontElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "face", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get size() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get size' called on an object that is not a valid instance of HTMLFontElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "size"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set size(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set size' called on an object that is not a valid instance of HTMLFontElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'size' property on 'HTMLFontElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "size", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLFontElement.prototype, { + color: { enumerable: true }, + face: { enumerable: true }, + size: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLFontElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLFontElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLFontElement + }); +}; + +const Impl = require("../nodes/HTMLFontElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLFormControlsCollection.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFormControlsCollection.js new file mode 100644 index 00000000..a2257b5e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFormControlsCollection.js @@ -0,0 +1,344 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLCollection = require("./HTMLCollection.js"); + +const interfaceName = "HTMLFormControlsCollection"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLFormControlsCollection'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLFormControlsCollection"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLCollection._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLFormControlsCollection extends globalObject.HTMLCollection { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'namedItem' called on an object that is not a valid instance of HTMLFormControlsCollection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'HTMLFormControlsCollection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'HTMLFormControlsCollection': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); + } + } + Object.defineProperties(HTMLFormControlsCollection.prototype, { + namedItem: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLFormControlsCollection", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = HTMLFormControlsCollection; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLFormControlsCollection + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + const namedValue = target[implSymbol].namedItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + if (!utils.hasOwn(target, P)) { + const creating = !(target[implSymbol].namedItem(P) !== null); + if (!creating) { + return false; + } + } + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/HTMLFormControlsCollection-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLFormElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFormElement.js new file mode 100644 index 00000000..8d93fc3b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFormElement.js @@ -0,0 +1,501 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const HTMLElement = require("./HTMLElement.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "HTMLFormElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLFormElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLFormElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLFormElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + submit() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'submit' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + return esValue[implSymbol].submit(); + } + + requestSubmit() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'requestSubmit' called on an object that is not a valid instance of HTMLFormElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = HTMLElement.convert(globalObject, curArg, { + context: "Failed to execute 'requestSubmit' on 'HTMLFormElement': parameter 1" + }); + } + args.push(curArg); + } + return esValue[implSymbol].requestSubmit(...args); + } + + reset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reset' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].reset(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + get acceptCharset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get acceptCharset' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "accept-charset"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set acceptCharset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set acceptCharset' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'acceptCharset' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "accept-charset", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get action() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get action' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["action"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set action(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set action' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'action' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["action"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get enctype() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get enctype' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["enctype"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set enctype(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set enctype' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'enctype' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["enctype"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get method() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get method' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["method"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set method(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set method' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'method' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["method"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get noValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get noValidate' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "novalidate"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set noValidate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set noValidate' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'noValidate' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "novalidate", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "novalidate"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "target"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set target(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set target' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'target' property on 'HTMLFormElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "target", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get elements() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get elements' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + return utils.getSameObject(this, "elements", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["elements"]); + }); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of HTMLFormElement." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(HTMLFormElement.prototype, { + submit: { enumerable: true }, + requestSubmit: { enumerable: true }, + reset: { enumerable: true }, + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + acceptCharset: { enumerable: true }, + action: { enumerable: true }, + enctype: { enumerable: true }, + method: { enumerable: true }, + name: { enumerable: true }, + noValidate: { enumerable: true }, + target: { enumerable: true }, + elements: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLFormElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLFormElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLFormElement + }); +}; + +const Impl = require("../nodes/HTMLFormElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLFrameElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFrameElement.js new file mode 100644 index 00000000..b5ff048a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFrameElement.js @@ -0,0 +1,494 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLFrameElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLFrameElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLFrameElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLFrameElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get scrolling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrolling' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "scrolling"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set scrolling(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scrolling' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'scrolling' property on 'HTMLFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "scrolling", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get frameBorder() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get frameBorder' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "frameborder"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set frameBorder(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set frameBorder' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'frameBorder' property on 'HTMLFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "frameborder", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get longDesc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get longDesc' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "longdesc"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set longDesc(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set longDesc' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'longDesc' property on 'HTMLFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "longdesc", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get noResize() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get noResize' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "noresize"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set noResize(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set noResize' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'noResize' property on 'HTMLFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "noresize", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "noresize"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get contentDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get contentDocument' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["contentDocument"]); + } + + get contentWindow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get contentWindow' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["contentWindow"]); + } + + get marginHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get marginHeight' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "marginheight"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set marginHeight(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set marginHeight' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'marginHeight' property on 'HTMLFrameElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "marginheight", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get marginWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get marginWidth' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "marginwidth"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set marginWidth(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set marginWidth' called on an object that is not a valid instance of HTMLFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'marginWidth' property on 'HTMLFrameElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "marginwidth", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLFrameElement.prototype, { + name: { enumerable: true }, + scrolling: { enumerable: true }, + src: { enumerable: true }, + frameBorder: { enumerable: true }, + longDesc: { enumerable: true }, + noResize: { enumerable: true }, + contentDocument: { enumerable: true }, + contentWindow: { enumerable: true }, + marginHeight: { enumerable: true }, + marginWidth: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLFrameElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLFrameElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLFrameElement + }); +}; + +const Impl = require("../nodes/HTMLFrameElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLFrameSetElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFrameSetElement.js new file mode 100644 index 00000000..ca1f8580 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLFrameSetElement.js @@ -0,0 +1,708 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLFrameSetElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLFrameSetElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLFrameSetElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLFrameSetElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get cols() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cols' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "cols"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set cols(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cols' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'cols' property on 'HTMLFrameSetElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "cols", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rows() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rows' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rows"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rows(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rows' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rows' property on 'HTMLFrameSetElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rows", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get onafterprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onafterprint' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]); + } + + set onafterprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onafterprint' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onafterprint' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onafterprint"] = V; + } + + get onbeforeprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeprint' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]); + } + + set onbeforeprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeprint' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeprint' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeprint"] = V; + } + + get onbeforeunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeunload' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeunload"]); + } + + set onbeforeunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeunload' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeunload' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeunload"] = V; + } + + get onhashchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onhashchange' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]); + } + + set onhashchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onhashchange' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onhashchange' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onhashchange"] = V; + } + + get onlanguagechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onlanguagechange' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onlanguagechange"]); + } + + set onlanguagechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onlanguagechange' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onlanguagechange' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onlanguagechange"] = V; + } + + get onmessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessage' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]); + } + + set onmessage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessage' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessage' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onmessage"] = V; + } + + get onmessageerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessageerror' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessageerror"]); + } + + set onmessageerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessageerror' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessageerror' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onmessageerror"] = V; + } + + get onoffline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onoffline' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]); + } + + set onoffline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onoffline' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onoffline' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onoffline"] = V; + } + + get ononline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ononline' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]); + } + + set ononline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ononline' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ononline' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["ononline"] = V; + } + + get onpagehide() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpagehide' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]); + } + + set onpagehide(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpagehide' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpagehide' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onpagehide"] = V; + } + + get onpageshow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpageshow' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]); + } + + set onpageshow(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpageshow' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpageshow' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onpageshow"] = V; + } + + get onpopstate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpopstate' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]); + } + + set onpopstate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpopstate' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpopstate' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onpopstate"] = V; + } + + get onrejectionhandled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onrejectionhandled' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onrejectionhandled"]); + } + + set onrejectionhandled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onrejectionhandled' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onrejectionhandled' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onrejectionhandled"] = V; + } + + get onstorage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstorage' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]); + } + + set onstorage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstorage' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstorage' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onstorage"] = V; + } + + get onunhandledrejection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunhandledrejection' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunhandledrejection"]); + } + + set onunhandledrejection(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunhandledrejection' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunhandledrejection' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onunhandledrejection"] = V; + } + + get onunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunload' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]); + } + + set onunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunload' called on an object that is not a valid instance of HTMLFrameSetElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunload' property on 'HTMLFrameSetElement': The provided value" + }); + } + esValue[implSymbol]["onunload"] = V; + } + } + Object.defineProperties(HTMLFrameSetElement.prototype, { + cols: { enumerable: true }, + rows: { enumerable: true }, + onafterprint: { enumerable: true }, + onbeforeprint: { enumerable: true }, + onbeforeunload: { enumerable: true }, + onhashchange: { enumerable: true }, + onlanguagechange: { enumerable: true }, + onmessage: { enumerable: true }, + onmessageerror: { enumerable: true }, + onoffline: { enumerable: true }, + ononline: { enumerable: true }, + onpagehide: { enumerable: true }, + onpageshow: { enumerable: true }, + onpopstate: { enumerable: true }, + onrejectionhandled: { enumerable: true }, + onstorage: { enumerable: true }, + onunhandledrejection: { enumerable: true }, + onunload: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLFrameSetElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLFrameSetElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLFrameSetElement + }); +}; + +const Impl = require("../nodes/HTMLFrameSetElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLHRElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHRElement.js new file mode 100644 index 00000000..948fc8e9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHRElement.js @@ -0,0 +1,320 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLHRElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLHRElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLHRElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLHRElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLHRElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get color() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get color' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "color"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set color(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set color' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'color' property on 'HTMLHRElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "color", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get noShade() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get noShade' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "noshade"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set noShade(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set noShade' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'noShade' property on 'HTMLHRElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "noshade", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "noshade"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get size() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get size' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "size"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set size(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set size' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'size' property on 'HTMLHRElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "size", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLHRElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLHRElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLHRElement.prototype, { + align: { enumerable: true }, + color: { enumerable: true }, + noShade: { enumerable: true }, + size: { enumerable: true }, + width: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLHRElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLHRElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLHRElement + }); +}; + +const Impl = require("../nodes/HTMLHRElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLHeadElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHeadElement.js new file mode 100644 index 00000000..2ae40f8d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHeadElement.js @@ -0,0 +1,110 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLHeadElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLHeadElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLHeadElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLHeadElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + } + Object.defineProperties(HTMLHeadElement.prototype, { + [Symbol.toStringTag]: { value: "HTMLHeadElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLHeadElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLHeadElement + }); +}; + +const Impl = require("../nodes/HTMLHeadElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLHeadingElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHeadingElement.js new file mode 100644 index 00000000..8aa98bcd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHeadingElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLHeadingElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLHeadingElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLHeadingElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLHeadingElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLHeadingElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLHeadingElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLHeadingElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLHeadingElement.prototype, { + align: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLHeadingElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLHeadingElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLHeadingElement + }); +}; + +const Impl = require("../nodes/HTMLHeadingElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLHtmlElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHtmlElement.js new file mode 100644 index 00000000..8bb2f05b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLHtmlElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLHtmlElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLHtmlElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLHtmlElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLHtmlElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get version() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get version' called on an object that is not a valid instance of HTMLHtmlElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "version"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set version(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set version' called on an object that is not a valid instance of HTMLHtmlElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'version' property on 'HTMLHtmlElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "version", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLHtmlElement.prototype, { + version: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLHtmlElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLHtmlElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLHtmlElement + }); +}; + +const Impl = require("../nodes/HTMLHtmlElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLIFrameElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLIFrameElement.js new file mode 100644 index 00000000..538fcf09 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLIFrameElement.js @@ -0,0 +1,670 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLIFrameElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLIFrameElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLIFrameElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLIFrameElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + getSVGDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getSVGDocument' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getSVGDocument()); + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get srcdoc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get srcdoc' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "srcdoc"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set srcdoc(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set srcdoc' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'srcdoc' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "srcdoc", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get allowFullscreen() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get allowFullscreen' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "allowfullscreen"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set allowFullscreen(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set allowFullscreen' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'allowFullscreen' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "allowfullscreen", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "allowfullscreen"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "height"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'height' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "height", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get contentDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get contentDocument' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["contentDocument"]); + } + + get contentWindow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get contentWindow' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["contentWindow"]); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get scrolling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrolling' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "scrolling"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set scrolling(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scrolling' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'scrolling' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "scrolling", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get frameBorder() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get frameBorder' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "frameborder"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set frameBorder(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set frameBorder' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'frameBorder' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "frameborder", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get longDesc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get longDesc' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "longdesc"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set longDesc(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set longDesc' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'longDesc' property on 'HTMLIFrameElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "longdesc", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get marginHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get marginHeight' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "marginheight"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set marginHeight(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set marginHeight' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'marginHeight' property on 'HTMLIFrameElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "marginheight", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get marginWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get marginWidth' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "marginwidth"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set marginWidth(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set marginWidth' called on an object that is not a valid instance of HTMLIFrameElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'marginWidth' property on 'HTMLIFrameElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "marginwidth", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLIFrameElement.prototype, { + getSVGDocument: { enumerable: true }, + src: { enumerable: true }, + srcdoc: { enumerable: true }, + name: { enumerable: true }, + allowFullscreen: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + contentDocument: { enumerable: true }, + contentWindow: { enumerable: true }, + align: { enumerable: true }, + scrolling: { enumerable: true }, + frameBorder: { enumerable: true }, + longDesc: { enumerable: true }, + marginHeight: { enumerable: true }, + marginWidth: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLIFrameElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLIFrameElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLIFrameElement + }); +}; + +const Impl = require("../nodes/HTMLIFrameElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLImageElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLImageElement.js new file mode 100644 index 00000000..7129d3c4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLImageElement.js @@ -0,0 +1,870 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLImageElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLImageElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLImageElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLImageElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get alt() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get alt' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "alt"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set alt(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set alt' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'alt' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "alt", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get srcset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get srcset' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "srcset"); + return value === null ? "" : conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set srcset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set srcset' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'srcset' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "srcset", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get sizes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get sizes' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "sizes"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set sizes(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set sizes' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'sizes' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "sizes", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get crossOrigin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get crossOrigin' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "crossorigin"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set crossOrigin(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set crossOrigin' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'crossOrigin' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "crossorigin", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get useMap() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get useMap' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "usemap"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set useMap(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set useMap' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'useMap' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "usemap", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get isMap() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isMap' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "ismap"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set isMap(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set isMap' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'isMap' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "ismap", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "ismap"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["width"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'width' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["width"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["height"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'height' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["height"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get naturalWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get naturalWidth' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + return esValue[implSymbol]["naturalWidth"]; + } + + get naturalHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get naturalHeight' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + return esValue[implSymbol]["naturalHeight"]; + } + + get complete() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get complete' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + return esValue[implSymbol]["complete"]; + } + + get currentSrc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentSrc' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + return esValue[implSymbol]["currentSrc"]; + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get lowsrc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lowsrc' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "lowsrc"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set lowsrc(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set lowsrc' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'lowsrc' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "lowsrc", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hspace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hspace' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "hspace"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hspace(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hspace' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'hspace' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "hspace", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vspace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vspace' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "vspace"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vspace(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vspace' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'vspace' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "vspace", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get longDesc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get longDesc' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "longdesc"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set longDesc(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set longDesc' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'longDesc' property on 'HTMLImageElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "longdesc", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get border() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get border' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "border"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set border(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set border' called on an object that is not a valid instance of HTMLImageElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'border' property on 'HTMLImageElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "border", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLImageElement.prototype, { + alt: { enumerable: true }, + src: { enumerable: true }, + srcset: { enumerable: true }, + sizes: { enumerable: true }, + crossOrigin: { enumerable: true }, + useMap: { enumerable: true }, + isMap: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + naturalWidth: { enumerable: true }, + naturalHeight: { enumerable: true }, + complete: { enumerable: true }, + currentSrc: { enumerable: true }, + name: { enumerable: true }, + lowsrc: { enumerable: true }, + align: { enumerable: true }, + hspace: { enumerable: true }, + vspace: { enumerable: true }, + longDesc: { enumerable: true }, + border: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLImageElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLImageElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLImageElement + }); +}; + +const Impl = require("../nodes/HTMLImageElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLInputElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLInputElement.js new file mode 100644 index 00000000..d8d73fde --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLInputElement.js @@ -0,0 +1,1875 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const SelectionMode = require("./SelectionMode.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const FileList = require("./FileList.js"); +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLInputElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLInputElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLInputElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLInputElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + stepUp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'stepUp' called on an object that is not a valid instance of HTMLInputElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'stepUp' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + } else { + curArg = 1; + } + args.push(curArg); + } + return esValue[implSymbol].stepUp(...args); + } + + stepDown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'stepDown' called on an object that is not a valid instance of HTMLInputElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'stepDown' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + } else { + curArg = 1; + } + args.push(curArg); + } + return esValue[implSymbol].stepDown(...args); + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLInputElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + select() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'select' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol].select(); + } + + setRangeText(replacement) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setRangeText' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setRangeText' on 'HTMLInputElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + break; + case 2: + throw new globalObject.TypeError( + `Failed to execute 'setRangeText' on 'HTMLInputElement': only ${arguments.length} arguments present.` + ); + break; + case 3: + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = SelectionMode.convert(globalObject, curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLInputElement': parameter 4" + }); + } else { + curArg = "preserve"; + } + args.push(curArg); + } + } + return esValue[implSymbol].setRangeText(...args); + } + + setSelectionRange(start, end) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setSelectionRange' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setSelectionRange' on 'HTMLInputElement': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setSelectionRange' on 'HTMLInputElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setSelectionRange' on 'HTMLInputElement': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setSelectionRange' on 'HTMLInputElement': parameter 3", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].setSelectionRange(...args); + } + + get accept() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get accept' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "accept"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set accept(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set accept' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'accept' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "accept", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get alt() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get alt' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "alt"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set alt(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set alt' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'alt' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "alt", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get autocomplete() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autocomplete' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "autocomplete"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autocomplete(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autocomplete' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'autocomplete' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "autocomplete", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get autofocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autofocus' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "autofocus"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autofocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autofocus' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'autofocus' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "autofocus", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "autofocus"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get defaultChecked() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultChecked' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "checked"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defaultChecked(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultChecked' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'defaultChecked' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "checked", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "checked"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get checked() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get checked' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["checked"]; + } + + set checked(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set checked' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'checked' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["checked"] = V; + } + + get dirName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dirName' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "dirname"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set dirName(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set dirName' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'dirName' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "dirname", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get files() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get files' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["files"]); + } + + set files(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set files' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = FileList.convert(globalObject, V, { + context: "Failed to set the 'files' property on 'HTMLInputElement': The provided value" + }); + } + esValue[implSymbol]["files"] = V; + } + + get formNoValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get formNoValidate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "formnovalidate"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set formNoValidate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set formNoValidate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'formNoValidate' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "formnovalidate", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "formnovalidate"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get formTarget() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get formTarget' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "formtarget"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set formTarget(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set formTarget' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'formTarget' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "formtarget", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get indeterminate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get indeterminate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["indeterminate"]; + } + + set indeterminate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set indeterminate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'indeterminate' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["indeterminate"] = V; + } + + get inputMode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get inputMode' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "inputmode"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set inputMode(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set inputMode' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'inputMode' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "inputmode", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get list() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get list' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["list"]); + } + + get max() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get max' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "max"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set max(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set max' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'max' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "max", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get maxLength() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get maxLength' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["maxLength"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set maxLength(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set maxLength' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'maxLength' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["maxLength"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get min() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get min' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "min"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set min(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set min' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'min' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "min", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get minLength() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get minLength' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["minLength"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set minLength(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set minLength' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'minLength' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["minLength"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get multiple() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get multiple' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "multiple"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set multiple(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set multiple' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'multiple' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "multiple", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "multiple"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get pattern() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pattern' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "pattern"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set pattern(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set pattern' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'pattern' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "pattern", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get placeholder() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get placeholder' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "placeholder"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set placeholder(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set placeholder' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'placeholder' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "placeholder", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get readOnly() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readOnly' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "readonly"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set readOnly(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set readOnly' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'readOnly' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "readonly", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "readonly"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get required() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get required' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "required"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set required(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set required' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'required' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "required", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "required"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get size() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get size' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["size"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set size(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set size' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'size' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["size"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get step() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get step' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "step"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set step(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set step' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'step' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "step", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["type"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["type"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get defaultValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultValue' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "value"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defaultValue(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultValue' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'defaultValue' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "value", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLInputElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get valueAsDate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valueAsDate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["valueAsDate"]; + } + + set valueAsDate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set valueAsDate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["object"](V, { + context: "Failed to set the 'valueAsDate' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + } + esValue[implSymbol]["valueAsDate"] = V; + } + + get valueAsNumber() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valueAsNumber' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["valueAsNumber"]; + } + + set valueAsNumber(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set valueAsNumber' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["unrestricted double"](V, { + context: "Failed to set the 'valueAsNumber' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["valueAsNumber"] = V; + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + + get selectionStart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectionStart' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["selectionStart"]; + } + + set selectionStart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectionStart' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["unsigned long"](V, { + context: "Failed to set the 'selectionStart' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + } + esValue[implSymbol]["selectionStart"] = V; + } + + get selectionEnd() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectionEnd' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["selectionEnd"]; + } + + set selectionEnd(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectionEnd' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["unsigned long"](V, { + context: "Failed to set the 'selectionEnd' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + } + esValue[implSymbol]["selectionEnd"] = V; + } + + get selectionDirection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectionDirection' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + return esValue[implSymbol]["selectionDirection"]; + } + + set selectionDirection(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectionDirection' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'selectionDirection' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + } + esValue[implSymbol]["selectionDirection"] = V; + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get useMap() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get useMap' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "usemap"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set useMap(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set useMap' called on an object that is not a valid instance of HTMLInputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'useMap' property on 'HTMLInputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "usemap", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLInputElement.prototype, { + stepUp: { enumerable: true }, + stepDown: { enumerable: true }, + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + select: { enumerable: true }, + setRangeText: { enumerable: true }, + setSelectionRange: { enumerable: true }, + accept: { enumerable: true }, + alt: { enumerable: true }, + autocomplete: { enumerable: true }, + autofocus: { enumerable: true }, + defaultChecked: { enumerable: true }, + checked: { enumerable: true }, + dirName: { enumerable: true }, + disabled: { enumerable: true }, + form: { enumerable: true }, + files: { enumerable: true }, + formNoValidate: { enumerable: true }, + formTarget: { enumerable: true }, + indeterminate: { enumerable: true }, + inputMode: { enumerable: true }, + list: { enumerable: true }, + max: { enumerable: true }, + maxLength: { enumerable: true }, + min: { enumerable: true }, + minLength: { enumerable: true }, + multiple: { enumerable: true }, + name: { enumerable: true }, + pattern: { enumerable: true }, + placeholder: { enumerable: true }, + readOnly: { enumerable: true }, + required: { enumerable: true }, + size: { enumerable: true }, + src: { enumerable: true }, + step: { enumerable: true }, + type: { enumerable: true }, + defaultValue: { enumerable: true }, + value: { enumerable: true }, + valueAsDate: { enumerable: true }, + valueAsNumber: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + labels: { enumerable: true }, + selectionStart: { enumerable: true }, + selectionEnd: { enumerable: true }, + selectionDirection: { enumerable: true }, + align: { enumerable: true }, + useMap: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLInputElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLInputElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLInputElement + }); +}; + +const Impl = require("../nodes/HTMLInputElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLLIElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLIElement.js new file mode 100644 index 00000000..fccec652 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLIElement.js @@ -0,0 +1,199 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseInteger_helpers_strings = require("../helpers/strings.js").parseInteger; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLLIElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLLIElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLLIElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLLIElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLLIElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "value"); + if (value === null) { + return 0; + } + value = parseInteger_helpers_strings(value); + return value !== null && conversions.long(value) === value ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLLIElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'value' property on 'HTMLLIElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "value", String(V)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLLIElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLLIElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLLIElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLLIElement.prototype, { + value: { enumerable: true }, + type: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLLIElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLLIElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLLIElement + }); +}; + +const Impl = require("../nodes/HTMLLIElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLLabelElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLabelElement.js new file mode 100644 index 00000000..56cdf40d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLabelElement.js @@ -0,0 +1,179 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLLabelElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLLabelElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLLabelElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLLabelElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLLabelElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get htmlFor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get htmlFor' called on an object that is not a valid instance of HTMLLabelElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "for"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set htmlFor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set htmlFor' called on an object that is not a valid instance of HTMLLabelElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'htmlFor' property on 'HTMLLabelElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "for", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get control() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get control' called on an object that is not a valid instance of HTMLLabelElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["control"]); + } + } + Object.defineProperties(HTMLLabelElement.prototype, { + form: { enumerable: true }, + htmlFor: { enumerable: true }, + control: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLLabelElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLLabelElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLLabelElement + }); +}; + +const Impl = require("../nodes/HTMLLabelElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLLegendElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLegendElement.js new file mode 100644 index 00000000..aefcd1be --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLegendElement.js @@ -0,0 +1,166 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLLegendElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLLegendElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLLegendElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLLegendElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLLegendElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLLegendElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLLegendElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLLegendElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLLegendElement.prototype, { + form: { enumerable: true }, + align: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLLegendElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLLegendElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLLegendElement + }); +}; + +const Impl = require("../nodes/HTMLLegendElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLLinkElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLinkElement.js new file mode 100644 index 00000000..a5b8e7ba --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLLinkElement.js @@ -0,0 +1,542 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLLinkElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLLinkElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLLinkElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLLinkElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get href' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "href"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set href' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'href' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "href", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get crossOrigin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get crossOrigin' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "crossorigin"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set crossOrigin(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set crossOrigin' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'crossOrigin' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "crossorigin", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rel' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rel"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rel' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rel' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rel", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get relList() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get relList' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + return utils.getSameObject(this, "relList", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["relList"]); + }); + } + + set relList(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set relList' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + const Q = esValue["relList"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'relList' is not an object"); + } + Reflect.set(Q, "value", V); + } + + get media() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get media' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "media"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set media(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set media' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'media' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "media", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hreflang() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hreflang' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "hreflang"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hreflang(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hreflang' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'hreflang' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "hreflang", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get charset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get charset' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charset"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set charset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set charset' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'charset' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charset", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rev() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rev' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rev"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rev(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rev' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rev' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rev", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "target"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set target(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set target' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'target' property on 'HTMLLinkElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "target", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get sheet() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get sheet' called on an object that is not a valid instance of HTMLLinkElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["sheet"]); + } + } + Object.defineProperties(HTMLLinkElement.prototype, { + href: { enumerable: true }, + crossOrigin: { enumerable: true }, + rel: { enumerable: true }, + relList: { enumerable: true }, + media: { enumerable: true }, + hreflang: { enumerable: true }, + type: { enumerable: true }, + charset: { enumerable: true }, + rev: { enumerable: true }, + target: { enumerable: true }, + sheet: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLLinkElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLLinkElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLLinkElement + }); +}; + +const Impl = require("../nodes/HTMLLinkElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLMapElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMapElement.js new file mode 100644 index 00000000..f9ea83b4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMapElement.js @@ -0,0 +1,168 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLMapElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLMapElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLMapElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLMapElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLMapElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLMapElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLMapElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get areas() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get areas' called on an object that is not a valid instance of HTMLMapElement." + ); + } + + return utils.getSameObject(this, "areas", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["areas"]); + }); + } + } + Object.defineProperties(HTMLMapElement.prototype, { + name: { enumerable: true }, + areas: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLMapElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLMapElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLMapElement + }); +}; + +const Impl = require("../nodes/HTMLMapElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLMarqueeElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMarqueeElement.js new file mode 100644 index 00000000..ced48618 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMarqueeElement.js @@ -0,0 +1,546 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLMarqueeElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLMarqueeElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLMarqueeElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLMarqueeElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get behavior() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get behavior' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "behavior"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set behavior(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set behavior' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'behavior' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "behavior", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get bgColor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bgColor' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "bgcolor"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set bgColor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set bgColor' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'bgColor' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "bgcolor", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get direction() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get direction' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "direction"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set direction(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set direction' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'direction' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "direction", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "height"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'height' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "height", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hspace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hspace' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "hspace"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hspace(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hspace' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'hspace' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "hspace", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get scrollAmount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrollAmount' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "scrollamount"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set scrollAmount(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scrollAmount' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'scrollAmount' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "scrollamount", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get scrollDelay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scrollDelay' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "scrolldelay"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set scrollDelay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scrollDelay' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'scrollDelay' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "scrolldelay", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get trueSpeed() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get trueSpeed' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "truespeed"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set trueSpeed(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set trueSpeed' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'trueSpeed' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "truespeed", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "truespeed"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vspace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vspace' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "vspace"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vspace(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vspace' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'vspace' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "vspace", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLMarqueeElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLMarqueeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLMarqueeElement.prototype, { + behavior: { enumerable: true }, + bgColor: { enumerable: true }, + direction: { enumerable: true }, + height: { enumerable: true }, + hspace: { enumerable: true }, + scrollAmount: { enumerable: true }, + scrollDelay: { enumerable: true }, + trueSpeed: { enumerable: true }, + vspace: { enumerable: true }, + width: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLMarqueeElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLMarqueeElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLMarqueeElement + }); +}; + +const Impl = require("../nodes/HTMLMarqueeElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLMediaElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMediaElement.js new file mode 100644 index 00000000..120e7554 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMediaElement.js @@ -0,0 +1,888 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const TextTrackKind = require("./TextTrackKind.js"); +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLMediaElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLMediaElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLMediaElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLMediaElement extends globalObject.HTMLElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + load() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'load' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol].load(); + } + + canPlayType(type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'canPlayType' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'canPlayType' on 'HTMLMediaElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'canPlayType' on 'HTMLMediaElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].canPlayType(...args)); + } + + play() { + try { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'play' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].play()); + } catch (e) { + return globalObject.Promise.reject(e); + } + } + + pause() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'pause' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol].pause(); + } + + addTextTrack(kind) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'addTextTrack' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'addTextTrack' on 'HTMLMediaElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = TextTrackKind.convert(globalObject, curArg, { + context: "Failed to execute 'addTextTrack' on 'HTMLMediaElement': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'addTextTrack' on 'HTMLMediaElement': parameter 2", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'addTextTrack' on 'HTMLMediaElement': parameter 3", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].addTextTrack(...args)); + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get currentSrc() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentSrc' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["currentSrc"]; + } + + get crossOrigin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get crossOrigin' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "crossorigin"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set crossOrigin(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set crossOrigin' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'crossOrigin' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "crossorigin", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get networkState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get networkState' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["networkState"]; + } + + get preload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get preload' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "preload"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set preload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set preload' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'preload' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "preload", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get buffered() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get buffered' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["buffered"]); + } + + get readyState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readyState' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["readyState"]; + } + + get seeking() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get seeking' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["seeking"]; + } + + get currentTime() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentTime' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["currentTime"]; + } + + set currentTime(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set currentTime' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["currentTime"] = V; + } + + get duration() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get duration' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["duration"]; + } + + get paused() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get paused' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["paused"]; + } + + get defaultPlaybackRate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultPlaybackRate' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["defaultPlaybackRate"]; + } + + set defaultPlaybackRate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultPlaybackRate' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'defaultPlaybackRate' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["defaultPlaybackRate"] = V; + } + + get playbackRate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get playbackRate' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["playbackRate"]; + } + + set playbackRate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set playbackRate' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'playbackRate' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["playbackRate"] = V; + } + + get played() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get played' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["played"]); + } + + get seekable() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get seekable' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["seekable"]); + } + + get ended() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ended' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["ended"]; + } + + get autoplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autoplay' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "autoplay"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autoplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autoplay' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'autoplay' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "autoplay", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "autoplay"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get loop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get loop' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "loop"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set loop(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set loop' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'loop' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "loop", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "loop"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get controls() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get controls' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "controls"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set controls(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set controls' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'controls' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "controls", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "controls"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get volume() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get volume' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["volume"]; + } + + set volume(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set volume' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'volume' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["volume"] = V; + } + + get muted() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get muted' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return esValue[implSymbol]["muted"]; + } + + set muted(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set muted' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'muted' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["muted"] = V; + } + + get defaultMuted() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultMuted' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "muted"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defaultMuted(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultMuted' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'defaultMuted' property on 'HTMLMediaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "muted", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "muted"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get audioTracks() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get audioTracks' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.getSameObject(this, "audioTracks", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["audioTracks"]); + }); + } + + get videoTracks() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get videoTracks' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.getSameObject(this, "videoTracks", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["videoTracks"]); + }); + } + + get textTracks() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get textTracks' called on an object that is not a valid instance of HTMLMediaElement." + ); + } + + return utils.getSameObject(this, "textTracks", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["textTracks"]); + }); + } + } + Object.defineProperties(HTMLMediaElement.prototype, { + load: { enumerable: true }, + canPlayType: { enumerable: true }, + play: { enumerable: true }, + pause: { enumerable: true }, + addTextTrack: { enumerable: true }, + src: { enumerable: true }, + currentSrc: { enumerable: true }, + crossOrigin: { enumerable: true }, + networkState: { enumerable: true }, + preload: { enumerable: true }, + buffered: { enumerable: true }, + readyState: { enumerable: true }, + seeking: { enumerable: true }, + currentTime: { enumerable: true }, + duration: { enumerable: true }, + paused: { enumerable: true }, + defaultPlaybackRate: { enumerable: true }, + playbackRate: { enumerable: true }, + played: { enumerable: true }, + seekable: { enumerable: true }, + ended: { enumerable: true }, + autoplay: { enumerable: true }, + loop: { enumerable: true }, + controls: { enumerable: true }, + volume: { enumerable: true }, + muted: { enumerable: true }, + defaultMuted: { enumerable: true }, + audioTracks: { enumerable: true }, + videoTracks: { enumerable: true }, + textTracks: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLMediaElement", configurable: true }, + NETWORK_EMPTY: { value: 0, enumerable: true }, + NETWORK_IDLE: { value: 1, enumerable: true }, + NETWORK_LOADING: { value: 2, enumerable: true }, + NETWORK_NO_SOURCE: { value: 3, enumerable: true }, + HAVE_NOTHING: { value: 0, enumerable: true }, + HAVE_METADATA: { value: 1, enumerable: true }, + HAVE_CURRENT_DATA: { value: 2, enumerable: true }, + HAVE_FUTURE_DATA: { value: 3, enumerable: true }, + HAVE_ENOUGH_DATA: { value: 4, enumerable: true } + }); + Object.defineProperties(HTMLMediaElement, { + NETWORK_EMPTY: { value: 0, enumerable: true }, + NETWORK_IDLE: { value: 1, enumerable: true }, + NETWORK_LOADING: { value: 2, enumerable: true }, + NETWORK_NO_SOURCE: { value: 3, enumerable: true }, + HAVE_NOTHING: { value: 0, enumerable: true }, + HAVE_METADATA: { value: 1, enumerable: true }, + HAVE_CURRENT_DATA: { value: 2, enumerable: true }, + HAVE_FUTURE_DATA: { value: 3, enumerable: true }, + HAVE_ENOUGH_DATA: { value: 4, enumerable: true } + }); + ctorRegistry[interfaceName] = HTMLMediaElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLMediaElement + }); +}; + +const Impl = require("../nodes/HTMLMediaElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLMenuElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMenuElement.js new file mode 100644 index 00000000..7e7f8172 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMenuElement.js @@ -0,0 +1,156 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLMenuElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLMenuElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLMenuElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLMenuElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get compact() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get compact' called on an object that is not a valid instance of HTMLMenuElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "compact"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set compact(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set compact' called on an object that is not a valid instance of HTMLMenuElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'compact' property on 'HTMLMenuElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "compact", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "compact"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLMenuElement.prototype, { + compact: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLMenuElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLMenuElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLMenuElement + }); +}; + +const Impl = require("../nodes/HTMLMenuElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLMetaElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMetaElement.js new file mode 100644 index 00000000..8610758b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMetaElement.js @@ -0,0 +1,276 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLMetaElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLMetaElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLMetaElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLMetaElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLMetaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get httpEquiv() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get httpEquiv' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "http-equiv"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set httpEquiv(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set httpEquiv' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'httpEquiv' property on 'HTMLMetaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "http-equiv", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get content() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get content' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "content"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set content(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set content' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'content' property on 'HTMLMetaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "content", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get scheme() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scheme' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "scheme"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set scheme(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scheme' called on an object that is not a valid instance of HTMLMetaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'scheme' property on 'HTMLMetaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "scheme", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLMetaElement.prototype, { + name: { enumerable: true }, + httpEquiv: { enumerable: true }, + content: { enumerable: true }, + scheme: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLMetaElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLMetaElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLMetaElement + }); +}; + +const Impl = require("../nodes/HTMLMetaElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLMeterElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMeterElement.js new file mode 100644 index 00000000..4a31cc00 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLMeterElement.js @@ -0,0 +1,365 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLMeterElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLMeterElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLMeterElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLMeterElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'value' property on 'HTMLMeterElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get min() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get min' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["min"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set min(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set min' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'min' property on 'HTMLMeterElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["min"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get max() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get max' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["max"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set max(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set max' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'max' property on 'HTMLMeterElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["max"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get low() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get low' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["low"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set low(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set low' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'low' property on 'HTMLMeterElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["low"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get high() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get high' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["high"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set high(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set high' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'high' property on 'HTMLMeterElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["high"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get optimum() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get optimum' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["optimum"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set optimum(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set optimum' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'optimum' property on 'HTMLMeterElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["optimum"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLMeterElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + } + Object.defineProperties(HTMLMeterElement.prototype, { + value: { enumerable: true }, + min: { enumerable: true }, + max: { enumerable: true }, + low: { enumerable: true }, + high: { enumerable: true }, + optimum: { enumerable: true }, + labels: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLMeterElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLMeterElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLMeterElement + }); +}; + +const Impl = require("../nodes/HTMLMeterElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLModElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLModElement.js new file mode 100644 index 00000000..afe0642f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLModElement.js @@ -0,0 +1,207 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLModElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLModElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLModElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLModElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get cite() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cite' called on an object that is not a valid instance of HTMLModElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "cite"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set cite(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cite' called on an object that is not a valid instance of HTMLModElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'cite' property on 'HTMLModElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "cite", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get dateTime() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dateTime' called on an object that is not a valid instance of HTMLModElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "datetime"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set dateTime(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set dateTime' called on an object that is not a valid instance of HTMLModElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'dateTime' property on 'HTMLModElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "datetime", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLModElement.prototype, { + cite: { enumerable: true }, + dateTime: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLModElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLModElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLModElement + }); +}; + +const Impl = require("../nodes/HTMLModElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLOListElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOListElement.js new file mode 100644 index 00000000..a721c2cc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOListElement.js @@ -0,0 +1,281 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLOListElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLOListElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLOListElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLOListElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get reversed() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get reversed' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "reversed"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set reversed(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set reversed' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'reversed' property on 'HTMLOListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "reversed", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "reversed"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get start() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get start' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["start"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set start(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set start' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'start' property on 'HTMLOListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["start"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLOListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get compact() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get compact' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "compact"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set compact(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set compact' called on an object that is not a valid instance of HTMLOListElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'compact' property on 'HTMLOListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "compact", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "compact"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLOListElement.prototype, { + reversed: { enumerable: true }, + start: { enumerable: true }, + type: { enumerable: true }, + compact: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLOListElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLOListElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLOListElement + }); +}; + +const Impl = require("../nodes/HTMLOListElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLObjectElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLObjectElement.js new file mode 100644 index 00000000..d0ae3587 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLObjectElement.js @@ -0,0 +1,921 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLObjectElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLObjectElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLObjectElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLObjectElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLObjectElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLObjectElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + get data() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get data' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "data"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set data(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set data' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'data' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "data", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get useMap() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get useMap' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "usemap"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set useMap(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set useMap' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'useMap' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "usemap", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "height"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'height' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "height", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get contentDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get contentDocument' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["contentDocument"]); + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get archive() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get archive' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "archive"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set archive(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set archive' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'archive' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "archive", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get code() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get code' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "code"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set code(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set code' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'code' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "code", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get declare() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get declare' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "declare"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set declare(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set declare' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'declare' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "declare", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "declare"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get hspace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hspace' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "hspace"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set hspace(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hspace' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'hspace' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "hspace", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get standby() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get standby' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "standby"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set standby(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set standby' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'standby' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "standby", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vspace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vspace' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "vspace"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vspace(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vspace' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'vspace' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "vspace", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get codeBase() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get codeBase' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "codebase"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set codeBase(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set codeBase' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'codeBase' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "codebase", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get codeType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get codeType' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "codetype"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set codeType(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set codeType' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'codeType' property on 'HTMLObjectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "codetype", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get border() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get border' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "border"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set border(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set border' called on an object that is not a valid instance of HTMLObjectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'border' property on 'HTMLObjectElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "border", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLObjectElement.prototype, { + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + data: { enumerable: true }, + type: { enumerable: true }, + name: { enumerable: true }, + useMap: { enumerable: true }, + form: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + contentDocument: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + align: { enumerable: true }, + archive: { enumerable: true }, + code: { enumerable: true }, + declare: { enumerable: true }, + hspace: { enumerable: true }, + standby: { enumerable: true }, + vspace: { enumerable: true }, + codeBase: { enumerable: true }, + codeType: { enumerable: true }, + border: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLObjectElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLObjectElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLObjectElement + }); +}; + +const Impl = require("../nodes/HTMLObjectElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptGroupElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptGroupElement.js new file mode 100644 index 00000000..b7b2c5a6 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptGroupElement.js @@ -0,0 +1,197 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLOptGroupElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLOptGroupElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLOptGroupElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLOptGroupElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLOptGroupElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLOptGroupElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLOptGroupElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get label() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get label' called on an object that is not a valid instance of HTMLOptGroupElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "label"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set label(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set label' called on an object that is not a valid instance of HTMLOptGroupElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'label' property on 'HTMLOptGroupElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "label", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLOptGroupElement.prototype, { + disabled: { enumerable: true }, + label: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLOptGroupElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLOptGroupElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLOptGroupElement + }); +}; + +const Impl = require("../nodes/HTMLOptGroupElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptionElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptionElement.js new file mode 100644 index 00000000..a2b62944 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptionElement.js @@ -0,0 +1,376 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLOptionElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLOptionElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLOptionElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLOptionElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLOptionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get label() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get label' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["label"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set label(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set label' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'label' property on 'HTMLOptionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["label"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get defaultSelected() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultSelected' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "selected"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defaultSelected(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultSelected' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'defaultSelected' property on 'HTMLOptionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "selected", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "selected"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get selected() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selected' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + return esValue[implSymbol]["selected"]; + } + + set selected(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selected' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'selected' property on 'HTMLOptionElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["selected"] = V; + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLOptionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get text() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get text' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["text"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set text(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set text' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'text' property on 'HTMLOptionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["text"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get index() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get index' called on an object that is not a valid instance of HTMLOptionElement." + ); + } + + return esValue[implSymbol]["index"]; + } + } + Object.defineProperties(HTMLOptionElement.prototype, { + disabled: { enumerable: true }, + form: { enumerable: true }, + label: { enumerable: true }, + defaultSelected: { enumerable: true }, + selected: { enumerable: true }, + value: { enumerable: true }, + text: { enumerable: true }, + index: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLOptionElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLOptionElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLOptionElement + }); +}; + +const Impl = require("../nodes/HTMLOptionElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptionsCollection.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptionsCollection.js new file mode 100644 index 00000000..2693e003 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOptionsCollection.js @@ -0,0 +1,537 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLOptionElement = require("./HTMLOptionElement.js"); +const HTMLOptGroupElement = require("./HTMLOptGroupElement.js"); +const HTMLElement = require("./HTMLElement.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLCollection = require("./HTMLCollection.js"); + +const interfaceName = "HTMLOptionsCollection"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLOptionsCollection'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLOptionsCollection"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLCollection._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLOptionsCollection extends globalObject.HTMLCollection { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + add(element) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'add' called on an object that is not a valid instance of HTMLOptionsCollection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'add' on 'HTMLOptionsCollection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (HTMLOptionElement.is(curArg) || HTMLOptGroupElement.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + throw new globalObject.TypeError( + "Failed to execute 'add' on 'HTMLOptionsCollection': parameter 1" + " is not of any supported type." + ); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (HTMLElement.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (typeof curArg === "number") { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'add' on 'HTMLOptionsCollection': parameter 2", + globals: globalObject + }); + } else { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'add' on 'HTMLOptionsCollection': parameter 2", + globals: globalObject + }); + } + } + } else { + curArg = null; + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].add(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + remove(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'remove' called on an object that is not a valid instance of HTMLOptionsCollection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'remove' on 'HTMLOptionsCollection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["long"](curArg, { + context: "Failed to execute 'remove' on 'HTMLOptionsCollection': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].remove(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of HTMLOptionsCollection." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["length"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set length(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set length' called on an object that is not a valid instance of HTMLOptionsCollection." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'length' property on 'HTMLOptionsCollection': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["length"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get selectedIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectedIndex' called on an object that is not a valid instance of HTMLOptionsCollection." + ); + } + + return esValue[implSymbol]["selectedIndex"]; + } + + set selectedIndex(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectedIndex' called on an object that is not a valid instance of HTMLOptionsCollection." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'selectedIndex' property on 'HTMLOptionsCollection': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["selectedIndex"] = V; + } + } + Object.defineProperties(HTMLOptionsCollection.prototype, { + add: { enumerable: true }, + remove: { enumerable: true }, + length: { enumerable: true }, + selectedIndex: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLOptionsCollection", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = HTMLOptionsCollection; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLOptionsCollection + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + const namedValue = target[implSymbol].namedItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + let indexedValue = V; + + if (indexedValue === null || indexedValue === undefined) { + indexedValue = null; + } else { + indexedValue = HTMLOptionElement.convert(globalObject, indexedValue, { + context: "Failed to set the " + index + " property on 'HTMLOptionsCollection': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const creating = !(target[implSymbol].item(index) !== null); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + + return true; + } + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + if (desc.get || desc.set) { + return false; + } + + const index = P >>> 0; + let indexedValue = desc.value; + + if (indexedValue === null || indexedValue === undefined) { + indexedValue = null; + } else { + indexedValue = HTMLOptionElement.convert(globalObject, indexedValue, { + context: "Failed to set the " + index + " property on 'HTMLOptionsCollection': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const creating = !(target[implSymbol].item(index) !== null); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + + return true; + } + if (!utils.hasOwn(target, P)) { + const creating = !(target[implSymbol].namedItem(P) !== null); + if (!creating) { + return false; + } + } + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + if (target[implSymbol].namedItem(P) !== null && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/HTMLOptionsCollection-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLOutputElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOutputElement.js new file mode 100644 index 00000000..faf1f40d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLOutputElement.js @@ -0,0 +1,392 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLOutputElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLOutputElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLOutputElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLOutputElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLOutputElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLOutputElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + get htmlFor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get htmlFor' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return utils.getSameObject(this, "htmlFor", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["htmlFor"]); + }); + } + + set htmlFor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set htmlFor' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + const Q = esValue["htmlFor"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'htmlFor' is not an object"); + } + Reflect.set(Q, "value", V); + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLOutputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return esValue[implSymbol]["type"]; + } + + get defaultValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultValue' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["defaultValue"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defaultValue(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultValue' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'defaultValue' property on 'HTMLOutputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["defaultValue"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLOutputElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLOutputElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + } + Object.defineProperties(HTMLOutputElement.prototype, { + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + htmlFor: { enumerable: true }, + form: { enumerable: true }, + name: { enumerable: true }, + type: { enumerable: true }, + defaultValue: { enumerable: true }, + value: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + labels: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLOutputElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLOutputElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLOutputElement + }); +}; + +const Impl = require("../nodes/HTMLOutputElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLParagraphElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLParagraphElement.js new file mode 100644 index 00000000..4e58b0ab --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLParagraphElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLParagraphElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLParagraphElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLParagraphElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLParagraphElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLParagraphElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLParagraphElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLParagraphElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLParagraphElement.prototype, { + align: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLParagraphElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLParagraphElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLParagraphElement + }); +}; + +const Impl = require("../nodes/HTMLParagraphElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLParamElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLParamElement.js new file mode 100644 index 00000000..02493772 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLParamElement.js @@ -0,0 +1,276 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLParamElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLParamElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLParamElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLParamElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLParamElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "value"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLParamElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "value", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLParamElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get valueType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valueType' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "valuetype"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set valueType(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set valueType' called on an object that is not a valid instance of HTMLParamElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'valueType' property on 'HTMLParamElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "valuetype", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLParamElement.prototype, { + name: { enumerable: true }, + value: { enumerable: true }, + type: { enumerable: true }, + valueType: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLParamElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLParamElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLParamElement + }); +}; + +const Impl = require("../nodes/HTMLParamElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLPictureElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLPictureElement.js new file mode 100644 index 00000000..f42b1e77 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLPictureElement.js @@ -0,0 +1,110 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLPictureElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLPictureElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLPictureElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLPictureElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + } + Object.defineProperties(HTMLPictureElement.prototype, { + [Symbol.toStringTag]: { value: "HTMLPictureElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLPictureElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLPictureElement + }); +}; + +const Impl = require("../nodes/HTMLPictureElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLPreElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLPreElement.js new file mode 100644 index 00000000..7b407974 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLPreElement.js @@ -0,0 +1,158 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseInteger_helpers_strings = require("../helpers/strings.js").parseInteger; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLPreElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLPreElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLPreElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLPreElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLPreElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "width"); + if (value === null) { + return 0; + } + value = parseInteger_helpers_strings(value); + return value !== null && conversions.long(value) === value ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLPreElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'width' property on 'HTMLPreElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", String(V)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLPreElement.prototype, { + width: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLPreElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLPreElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLPreElement + }); +}; + +const Impl = require("../nodes/HTMLPreElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLProgressElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLProgressElement.js new file mode 100644 index 00000000..e818611b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLProgressElement.js @@ -0,0 +1,218 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLProgressElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLProgressElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLProgressElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLProgressElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLProgressElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLProgressElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'value' property on 'HTMLProgressElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get max() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get max' called on an object that is not a valid instance of HTMLProgressElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["max"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set max(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set max' called on an object that is not a valid instance of HTMLProgressElement." + ); + } + + V = conversions["double"](V, { + context: "Failed to set the 'max' property on 'HTMLProgressElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["max"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get position() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get position' called on an object that is not a valid instance of HTMLProgressElement." + ); + } + + return esValue[implSymbol]["position"]; + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLProgressElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + } + Object.defineProperties(HTMLProgressElement.prototype, { + value: { enumerable: true }, + max: { enumerable: true }, + position: { enumerable: true }, + labels: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLProgressElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLProgressElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLProgressElement + }); +}; + +const Impl = require("../nodes/HTMLProgressElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLQuoteElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLQuoteElement.js new file mode 100644 index 00000000..92ebe7e7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLQuoteElement.js @@ -0,0 +1,166 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLQuoteElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLQuoteElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLQuoteElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLQuoteElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get cite() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cite' called on an object that is not a valid instance of HTMLQuoteElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "cite"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set cite(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cite' called on an object that is not a valid instance of HTMLQuoteElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'cite' property on 'HTMLQuoteElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "cite", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLQuoteElement.prototype, { + cite: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLQuoteElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLQuoteElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLQuoteElement + }); +}; + +const Impl = require("../nodes/HTMLQuoteElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLScriptElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLScriptElement.js new file mode 100644 index 00000000..699e5631 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLScriptElement.js @@ -0,0 +1,459 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLScriptElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLScriptElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLScriptElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLScriptElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get defer() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defer' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "defer"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defer(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defer' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'defer' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "defer", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "defer"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get crossOrigin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get crossOrigin' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "crossorigin"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set crossOrigin(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set crossOrigin' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'crossOrigin' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "crossorigin", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get text() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get text' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["text"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set text(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set text' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'text' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["text"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get charset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get charset' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charset"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set charset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set charset' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'charset' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charset", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get event() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get event' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "event"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set event(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set event' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'event' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "event", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get htmlFor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get htmlFor' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "for"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set htmlFor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set htmlFor' called on an object that is not a valid instance of HTMLScriptElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'htmlFor' property on 'HTMLScriptElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "for", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLScriptElement.prototype, { + src: { enumerable: true }, + type: { enumerable: true }, + defer: { enumerable: true }, + crossOrigin: { enumerable: true }, + text: { enumerable: true }, + charset: { enumerable: true }, + event: { enumerable: true }, + htmlFor: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLScriptElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLScriptElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLScriptElement + }); +}; + +const Impl = require("../nodes/HTMLScriptElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLSelectElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSelectElement.js new file mode 100644 index 00000000..12f36ab3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSelectElement.js @@ -0,0 +1,1013 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const HTMLOptionElement = require("./HTMLOptionElement.js"); +const HTMLOptGroupElement = require("./HTMLOptGroupElement.js"); +const HTMLElement = require("./HTMLElement.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "HTMLSelectElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLSelectElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLSelectElement"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLSelectElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'item' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'HTMLSelectElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'HTMLSelectElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'namedItem' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'HTMLSelectElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'HTMLSelectElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].namedItem(...args)); + } + + add(element) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'add' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'add' on 'HTMLSelectElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (HTMLOptionElement.is(curArg) || HTMLOptGroupElement.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else { + throw new globalObject.TypeError( + "Failed to execute 'add' on 'HTMLSelectElement': parameter 1" + " is not of any supported type." + ); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (HTMLElement.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (typeof curArg === "number") { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'add' on 'HTMLSelectElement': parameter 2", + globals: globalObject + }); + } else { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'add' on 'HTMLSelectElement': parameter 2", + globals: globalObject + }); + } + } + } else { + curArg = null; + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].add(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + remove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'remove' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + curArg = conversions["long"](curArg, { + context: "Failed to execute 'remove' on 'HTMLSelectElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].remove(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLSelectElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLSelectElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + get autofocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autofocus' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "autofocus"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autofocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autofocus' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'autofocus' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "autofocus", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "autofocus"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get multiple() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get multiple' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "multiple"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set multiple(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set multiple' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'multiple' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "multiple", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "multiple"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get required() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get required' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "required"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set required(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set required' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'required' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "required", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "required"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get size() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get size' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "size"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set size(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set size' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'size' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "size", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol]["type"]; + } + + get options() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get options' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return utils.getSameObject(this, "options", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["options"]); + }); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["length"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set length(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set length' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'length' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["length"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get selectedOptions() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectedOptions' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return utils.getSameObject(this, "selectedOptions", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["selectedOptions"]); + }); + } + + get selectedIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectedIndex' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol]["selectedIndex"]; + } + + set selectedIndex(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectedIndex' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'selectedIndex' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["selectedIndex"] = V; + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol]["value"]; + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLSelectElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["value"] = V; + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLSelectElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + } + Object.defineProperties(HTMLSelectElement.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + add: { enumerable: true }, + remove: { enumerable: true }, + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + autofocus: { enumerable: true }, + disabled: { enumerable: true }, + form: { enumerable: true }, + multiple: { enumerable: true }, + name: { enumerable: true }, + required: { enumerable: true }, + size: { enumerable: true }, + type: { enumerable: true }, + options: { enumerable: true }, + length: { enumerable: true }, + selectedOptions: { enumerable: true }, + selectedIndex: { enumerable: true }, + value: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + labels: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLSelectElement", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = HTMLSelectElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLSelectElement + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + let indexedValue = V; + + if (indexedValue === null || indexedValue === undefined) { + indexedValue = null; + } else { + indexedValue = HTMLOptionElement.convert(globalObject, indexedValue, { + context: "Failed to set the " + index + " property on 'HTMLSelectElement': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const creating = !(target[implSymbol].item(index) !== null); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + + return true; + } + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + if (desc.get || desc.set) { + return false; + } + + const index = P >>> 0; + let indexedValue = desc.value; + + if (indexedValue === null || indexedValue === undefined) { + indexedValue = null; + } else { + indexedValue = HTMLOptionElement.convert(globalObject, indexedValue, { + context: "Failed to set the " + index + " property on 'HTMLSelectElement': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const creating = !(target[implSymbol].item(index) !== null); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + + return true; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/HTMLSelectElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLSlotElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSlotElement.js new file mode 100644 index 00000000..0202b9e3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSlotElement.js @@ -0,0 +1,192 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const AssignedNodesOptions = require("./AssignedNodesOptions.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLSlotElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLSlotElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLSlotElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLSlotElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + assignedNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'assignedNodes' called on an object that is not a valid instance of HTMLSlotElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = AssignedNodesOptions.convert(globalObject, curArg, { + context: "Failed to execute 'assignedNodes' on 'HTMLSlotElement': parameter 1" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].assignedNodes(...args)); + } + + assignedElements() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'assignedElements' called on an object that is not a valid instance of HTMLSlotElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = AssignedNodesOptions.convert(globalObject, curArg, { + context: "Failed to execute 'assignedElements' on 'HTMLSlotElement': parameter 1" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].assignedElements(...args)); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLSlotElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLSlotElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLSlotElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLSlotElement.prototype, { + assignedNodes: { enumerable: true }, + assignedElements: { enumerable: true }, + name: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLSlotElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLSlotElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLSlotElement + }); +}; + +const Impl = require("../nodes/HTMLSlotElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLSourceElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSourceElement.js new file mode 100644 index 00000000..34d6816e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSourceElement.js @@ -0,0 +1,330 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLSourceElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLSourceElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLSourceElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLSourceElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLSourceElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLSourceElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get srcset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get srcset' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "srcset"); + return value === null ? "" : conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set srcset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set srcset' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'srcset' property on 'HTMLSourceElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "srcset", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get sizes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get sizes' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "sizes"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set sizes(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set sizes' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'sizes' property on 'HTMLSourceElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "sizes", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get media() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get media' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "media"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set media(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set media' called on an object that is not a valid instance of HTMLSourceElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'media' property on 'HTMLSourceElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "media", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLSourceElement.prototype, { + src: { enumerable: true }, + type: { enumerable: true }, + srcset: { enumerable: true }, + sizes: { enumerable: true }, + media: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLSourceElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLSourceElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLSourceElement + }); +}; + +const Impl = require("../nodes/HTMLSourceElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLSpanElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSpanElement.js new file mode 100644 index 00000000..47553acd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLSpanElement.js @@ -0,0 +1,110 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLSpanElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLSpanElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLSpanElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLSpanElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + } + Object.defineProperties(HTMLSpanElement.prototype, { + [Symbol.toStringTag]: { value: "HTMLSpanElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLSpanElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLSpanElement + }); +}; + +const Impl = require("../nodes/HTMLSpanElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLStyleElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLStyleElement.js new file mode 100644 index 00000000..e7d703bb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLStyleElement.js @@ -0,0 +1,207 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLStyleElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLStyleElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLStyleElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLStyleElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get media() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get media' called on an object that is not a valid instance of HTMLStyleElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "media"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set media(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set media' called on an object that is not a valid instance of HTMLStyleElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'media' property on 'HTMLStyleElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "media", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLStyleElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLStyleElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLStyleElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get sheet() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get sheet' called on an object that is not a valid instance of HTMLStyleElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["sheet"]); + } + } + Object.defineProperties(HTMLStyleElement.prototype, { + media: { enumerable: true }, + type: { enumerable: true }, + sheet: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLStyleElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLStyleElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLStyleElement + }); +}; + +const Impl = require("../nodes/HTMLStyleElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableCaptionElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableCaptionElement.js new file mode 100644 index 00000000..7f0288a9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableCaptionElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTableCaptionElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTableCaptionElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTableCaptionElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTableCaptionElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLTableCaptionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLTableCaptionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLTableCaptionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTableCaptionElement.prototype, { + align: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTableCaptionElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTableCaptionElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTableCaptionElement + }); +}; + +const Impl = require("../nodes/HTMLTableCaptionElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableCellElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableCellElement.js new file mode 100644 index 00000000..5c5fa009 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableCellElement.js @@ -0,0 +1,700 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTableCellElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTableCellElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTableCellElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTableCellElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get colSpan() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get colSpan' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["colSpan"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set colSpan(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set colSpan' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'colSpan' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["colSpan"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rowSpan() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rowSpan' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["rowSpan"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rowSpan(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rowSpan' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'rowSpan' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["rowSpan"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get headers() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get headers' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "headers"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set headers(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set headers' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'headers' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "headers", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get cellIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cellIndex' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + return esValue[implSymbol]["cellIndex"]; + } + + get scope() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get scope' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["scope"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set scope(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set scope' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'scope' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["scope"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get abbr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get abbr' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "abbr"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set abbr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set abbr' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'abbr' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "abbr", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get axis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get axis' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "axis"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set axis(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set axis' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'axis' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "axis", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "height"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'height' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "height", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get ch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ch' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "char"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set ch(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ch' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'ch' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "char", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get chOff() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get chOff' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charoff"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set chOff(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set chOff' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'chOff' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charoff", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get noWrap() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get noWrap' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "nowrap"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set noWrap(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set noWrap' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'noWrap' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "nowrap", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "nowrap"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vAlign() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vAlign' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "valign"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vAlign(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vAlign' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'vAlign' property on 'HTMLTableCellElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "valign", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get bgColor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bgColor' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "bgcolor"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set bgColor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set bgColor' called on an object that is not a valid instance of HTMLTableCellElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'bgColor' property on 'HTMLTableCellElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "bgcolor", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTableCellElement.prototype, { + colSpan: { enumerable: true }, + rowSpan: { enumerable: true }, + headers: { enumerable: true }, + cellIndex: { enumerable: true }, + scope: { enumerable: true }, + abbr: { enumerable: true }, + align: { enumerable: true }, + axis: { enumerable: true }, + height: { enumerable: true }, + width: { enumerable: true }, + ch: { enumerable: true }, + chOff: { enumerable: true }, + noWrap: { enumerable: true }, + vAlign: { enumerable: true }, + bgColor: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTableCellElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTableCellElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTableCellElement + }); +}; + +const Impl = require("../nodes/HTMLTableCellElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableColElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableColElement.js new file mode 100644 index 00000000..addf66bf --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableColElement.js @@ -0,0 +1,364 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTableColElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTableColElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTableColElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTableColElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get span() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get span' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "span"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set span(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set span' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'span' property on 'HTMLTableColElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "span", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLTableColElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get ch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ch' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "char"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set ch(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ch' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'ch' property on 'HTMLTableColElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "char", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get chOff() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get chOff' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charoff"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set chOff(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set chOff' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'chOff' property on 'HTMLTableColElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charoff", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vAlign() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vAlign' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "valign"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vAlign(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vAlign' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'vAlign' property on 'HTMLTableColElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "valign", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLTableColElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLTableColElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTableColElement.prototype, { + span: { enumerable: true }, + align: { enumerable: true }, + ch: { enumerable: true }, + chOff: { enumerable: true }, + vAlign: { enumerable: true }, + width: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTableColElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTableColElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTableColElement + }); +}; + +const Impl = require("../nodes/HTMLTableColElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableElement.js new file mode 100644 index 00000000..bcd7a53c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableElement.js @@ -0,0 +1,799 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const HTMLTableCaptionElement = require("./HTMLTableCaptionElement.js"); +const HTMLTableSectionElement = require("./HTMLTableSectionElement.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTableElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTableElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTableElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTableElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + createCaption() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createCaption' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createCaption()); + } + + deleteCaption() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteCaption' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteCaption(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + createTHead() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createTHead' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createTHead()); + } + + deleteTHead() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteTHead' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteTHead(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + createTFoot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createTFoot' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createTFoot()); + } + + deleteTFoot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteTFoot' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteTFoot(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + createTBody() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createTBody' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createTBody()); + } + + insertRow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertRow' called on an object that is not a valid instance of HTMLTableElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'insertRow' on 'HTMLTableElement': parameter 1", + globals: globalObject + }); + } else { + curArg = -1; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].insertRow(...args)); + } + + deleteRow(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteRow' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'deleteRow' on 'HTMLTableElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["long"](curArg, { + context: "Failed to execute 'deleteRow' on 'HTMLTableElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteRow(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get caption() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get caption' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol]["caption"]); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set caption(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set caption' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = HTMLTableCaptionElement.convert(globalObject, V, { + context: "Failed to set the 'caption' property on 'HTMLTableElement': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["caption"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get tHead() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tHead' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol]["tHead"]); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set tHead(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set tHead' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = HTMLTableSectionElement.convert(globalObject, V, { + context: "Failed to set the 'tHead' property on 'HTMLTableElement': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["tHead"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get tFoot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tFoot' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol]["tFoot"]); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set tFoot(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set tFoot' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = HTMLTableSectionElement.convert(globalObject, V, { + context: "Failed to set the 'tFoot' property on 'HTMLTableElement': The provided value" + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["tFoot"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get tBodies() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tBodies' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + return utils.getSameObject(this, "tBodies", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["tBodies"]); + }); + } + + get rows() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rows' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + return utils.getSameObject(this, "rows", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["rows"]); + }); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLTableElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get border() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get border' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "border"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set border(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set border' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'border' property on 'HTMLTableElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "border", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get frame() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get frame' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "frame"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set frame(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set frame' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'frame' property on 'HTMLTableElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "frame", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rules() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rules' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "rules"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rules(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rules' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'rules' property on 'HTMLTableElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "rules", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get summary() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get summary' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "summary"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set summary(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set summary' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'summary' property on 'HTMLTableElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "summary", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "width"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'width' property on 'HTMLTableElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "width", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get bgColor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bgColor' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "bgcolor"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set bgColor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set bgColor' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'bgColor' property on 'HTMLTableElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "bgcolor", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get cellPadding() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cellPadding' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "cellpadding"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set cellPadding(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cellPadding' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'cellPadding' property on 'HTMLTableElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "cellpadding", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get cellSpacing() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cellSpacing' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "cellspacing"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set cellSpacing(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cellSpacing' called on an object that is not a valid instance of HTMLTableElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'cellSpacing' property on 'HTMLTableElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "cellspacing", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTableElement.prototype, { + createCaption: { enumerable: true }, + deleteCaption: { enumerable: true }, + createTHead: { enumerable: true }, + deleteTHead: { enumerable: true }, + createTFoot: { enumerable: true }, + deleteTFoot: { enumerable: true }, + createTBody: { enumerable: true }, + insertRow: { enumerable: true }, + deleteRow: { enumerable: true }, + caption: { enumerable: true }, + tHead: { enumerable: true }, + tFoot: { enumerable: true }, + tBodies: { enumerable: true }, + rows: { enumerable: true }, + align: { enumerable: true }, + border: { enumerable: true }, + frame: { enumerable: true }, + rules: { enumerable: true }, + summary: { enumerable: true }, + width: { enumerable: true }, + bgColor: { enumerable: true }, + cellPadding: { enumerable: true }, + cellSpacing: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTableElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTableElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTableElement + }); +}; + +const Impl = require("../nodes/HTMLTableElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableRowElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableRowElement.js new file mode 100644 index 00000000..17171a0f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableRowElement.js @@ -0,0 +1,414 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTableRowElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTableRowElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTableRowElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTableRowElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + insertCell() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertCell' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'insertCell' on 'HTMLTableRowElement': parameter 1", + globals: globalObject + }); + } else { + curArg = -1; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].insertCell(...args)); + } + + deleteCell(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteCell' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'deleteCell' on 'HTMLTableRowElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["long"](curArg, { + context: "Failed to execute 'deleteCell' on 'HTMLTableRowElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteCell(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rowIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rowIndex' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + return esValue[implSymbol]["rowIndex"]; + } + + get sectionRowIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get sectionRowIndex' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + return esValue[implSymbol]["sectionRowIndex"]; + } + + get cells() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cells' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + return utils.getSameObject(this, "cells", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["cells"]); + }); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLTableRowElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get ch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ch' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "char"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set ch(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ch' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'ch' property on 'HTMLTableRowElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "char", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get chOff() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get chOff' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charoff"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set chOff(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set chOff' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'chOff' property on 'HTMLTableRowElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charoff", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vAlign() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vAlign' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "valign"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vAlign(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vAlign' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'vAlign' property on 'HTMLTableRowElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "valign", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get bgColor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bgColor' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "bgcolor"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set bgColor(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set bgColor' called on an object that is not a valid instance of HTMLTableRowElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'bgColor' property on 'HTMLTableRowElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "bgcolor", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTableRowElement.prototype, { + insertCell: { enumerable: true }, + deleteCell: { enumerable: true }, + rowIndex: { enumerable: true }, + sectionRowIndex: { enumerable: true }, + cells: { enumerable: true }, + align: { enumerable: true }, + ch: { enumerable: true }, + chOff: { enumerable: true }, + vAlign: { enumerable: true }, + bgColor: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTableRowElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTableRowElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTableRowElement + }); +}; + +const Impl = require("../nodes/HTMLTableRowElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableSectionElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableSectionElement.js new file mode 100644 index 00000000..5789ff8e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTableSectionElement.js @@ -0,0 +1,346 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTableSectionElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTableSectionElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTableSectionElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTableSectionElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + insertRow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertRow' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'insertRow' on 'HTMLTableSectionElement': parameter 1", + globals: globalObject + }); + } else { + curArg = -1; + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].insertRow(...args)); + } + + deleteRow(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteRow' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["long"](curArg, { + context: "Failed to execute 'deleteRow' on 'HTMLTableSectionElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteRow(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rows() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rows' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + return utils.getSameObject(this, "rows", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["rows"]); + }); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "align"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'align' property on 'HTMLTableSectionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "align", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get ch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ch' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "char"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set ch(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ch' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'ch' property on 'HTMLTableSectionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "char", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get chOff() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get chOff' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "charoff"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set chOff(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set chOff' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'chOff' property on 'HTMLTableSectionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "charoff", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get vAlign() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vAlign' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "valign"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set vAlign(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set vAlign' called on an object that is not a valid instance of HTMLTableSectionElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'vAlign' property on 'HTMLTableSectionElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "valign", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTableSectionElement.prototype, { + insertRow: { enumerable: true }, + deleteRow: { enumerable: true }, + rows: { enumerable: true }, + align: { enumerable: true }, + ch: { enumerable: true }, + chOff: { enumerable: true }, + vAlign: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTableSectionElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTableSectionElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTableSectionElement + }); +}; + +const Impl = require("../nodes/HTMLTableSectionElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTemplateElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTemplateElement.js new file mode 100644 index 00000000..6d3f6c30 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTemplateElement.js @@ -0,0 +1,123 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTemplateElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTemplateElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTemplateElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTemplateElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get content() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get content' called on an object that is not a valid instance of HTMLTemplateElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["content"]); + } + } + Object.defineProperties(HTMLTemplateElement.prototype, { + content: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTemplateElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTemplateElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTemplateElement + }); +}; + +const Impl = require("../nodes/HTMLTemplateElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTextAreaElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTextAreaElement.js new file mode 100644 index 00000000..e38687ed --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTextAreaElement.js @@ -0,0 +1,1171 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const SelectionMode = require("./SelectionMode.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseInteger_helpers_strings = require("../helpers/strings.js").parseInteger; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTextAreaElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTextAreaElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTextAreaElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTextAreaElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + checkValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'checkValidity' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol].checkValidity(); + } + + reportValidity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'reportValidity' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol].reportValidity(); + } + + setCustomValidity(error) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setCustomValidity' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setCustomValidity' on 'HTMLTextAreaElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setCustomValidity' on 'HTMLTextAreaElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setCustomValidity(...args); + } + + select() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'select' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol].select(); + } + + setRangeText(replacement) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setRangeText' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setRangeText' on 'HTMLTextAreaElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + break; + case 2: + throw new globalObject.TypeError( + `Failed to execute 'setRangeText' on 'HTMLTextAreaElement': only ${arguments.length} arguments present.` + ); + break; + case 3: + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = SelectionMode.convert(globalObject, curArg, { + context: "Failed to execute 'setRangeText' on 'HTMLTextAreaElement': parameter 4" + }); + } else { + curArg = "preserve"; + } + args.push(curArg); + } + } + return esValue[implSymbol].setRangeText(...args); + } + + setSelectionRange(start, end) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setSelectionRange' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setSelectionRange' on 'HTMLTextAreaElement': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setSelectionRange' on 'HTMLTextAreaElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setSelectionRange' on 'HTMLTextAreaElement': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setSelectionRange' on 'HTMLTextAreaElement': parameter 3", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].setSelectionRange(...args); + } + + get autocomplete() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autocomplete' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "autocomplete"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autocomplete(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autocomplete' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'autocomplete' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "autocomplete", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get autofocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get autofocus' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "autofocus"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set autofocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set autofocus' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'autofocus' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "autofocus", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "autofocus"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get cols() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cols' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["cols"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set cols(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set cols' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'cols' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["cols"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get dirName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dirName' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "dirname"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set dirName(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set dirName' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'dirName' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "dirname", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get disabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get disabled' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "disabled"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set disabled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set disabled' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'disabled' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "disabled", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "disabled"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get form() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get form' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["form"]); + } + + get inputMode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get inputMode' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "inputmode"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set inputMode(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set inputMode' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'inputMode' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "inputmode", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get maxLength() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get maxLength' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "maxlength"); + if (value === null) { + return 0; + } + value = parseInteger_helpers_strings(value); + return value !== null && conversions.long(value) === value ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set maxLength(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set maxLength' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'maxLength' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "maxlength", String(V)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get minLength() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get minLength' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "minlength"); + if (value === null) { + return 0; + } + value = parseInteger_helpers_strings(value); + return value !== null && conversions.long(value) === value ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set minLength(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set minLength' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'minLength' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "minlength", String(V)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get name' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "name"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set name(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set name' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'name' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "name", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get placeholder() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get placeholder' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "placeholder"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set placeholder(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set placeholder' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'placeholder' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "placeholder", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get readOnly() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readOnly' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "readonly"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set readOnly(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set readOnly' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'readOnly' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "readonly", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "readonly"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get required() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get required' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "required"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set required(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set required' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'required' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "required", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "required"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get rows() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rows' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["rows"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set rows(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set rows' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'rows' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["rows"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get wrap() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get wrap' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "wrap"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set wrap(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set wrap' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'wrap' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "wrap", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["type"]; + } + + get defaultValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get defaultValue' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["defaultValue"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set defaultValue(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set defaultValue' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'defaultValue' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["defaultValue"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["value"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["value"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get textLength() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get textLength' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["textLength"]; + } + + get willValidate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get willValidate' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["willValidate"]; + } + + get validity() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validity' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["validity"]); + } + + get validationMessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get validationMessage' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["validationMessage"]; + } + + get labels() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get labels' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["labels"]); + } + + get selectionStart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectionStart' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["selectionStart"]; + } + + set selectionStart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectionStart' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'selectionStart' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["selectionStart"] = V; + } + + get selectionEnd() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectionEnd' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["selectionEnd"]; + } + + set selectionEnd(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectionEnd' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'selectionEnd' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["selectionEnd"] = V; + } + + get selectionDirection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get selectionDirection' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + return esValue[implSymbol]["selectionDirection"]; + } + + set selectionDirection(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set selectionDirection' called on an object that is not a valid instance of HTMLTextAreaElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'selectionDirection' property on 'HTMLTextAreaElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["selectionDirection"] = V; + } + } + Object.defineProperties(HTMLTextAreaElement.prototype, { + checkValidity: { enumerable: true }, + reportValidity: { enumerable: true }, + setCustomValidity: { enumerable: true }, + select: { enumerable: true }, + setRangeText: { enumerable: true }, + setSelectionRange: { enumerable: true }, + autocomplete: { enumerable: true }, + autofocus: { enumerable: true }, + cols: { enumerable: true }, + dirName: { enumerable: true }, + disabled: { enumerable: true }, + form: { enumerable: true }, + inputMode: { enumerable: true }, + maxLength: { enumerable: true }, + minLength: { enumerable: true }, + name: { enumerable: true }, + placeholder: { enumerable: true }, + readOnly: { enumerable: true }, + required: { enumerable: true }, + rows: { enumerable: true }, + wrap: { enumerable: true }, + type: { enumerable: true }, + defaultValue: { enumerable: true }, + value: { enumerable: true }, + textLength: { enumerable: true }, + willValidate: { enumerable: true }, + validity: { enumerable: true }, + validationMessage: { enumerable: true }, + labels: { enumerable: true }, + selectionStart: { enumerable: true }, + selectionEnd: { enumerable: true }, + selectionDirection: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTextAreaElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTextAreaElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTextAreaElement + }); +}; + +const Impl = require("../nodes/HTMLTextAreaElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTimeElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTimeElement.js new file mode 100644 index 00000000..79d0782f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTimeElement.js @@ -0,0 +1,153 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTimeElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTimeElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTimeElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTimeElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get dateTime() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dateTime' called on an object that is not a valid instance of HTMLTimeElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "datetime"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set dateTime(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set dateTime' called on an object that is not a valid instance of HTMLTimeElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'dateTime' property on 'HTMLTimeElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "datetime", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTimeElement.prototype, { + dateTime: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTimeElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTimeElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTimeElement + }); +}; + +const Impl = require("../nodes/HTMLTimeElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTitleElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTitleElement.js new file mode 100644 index 00000000..a4961507 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTitleElement.js @@ -0,0 +1,152 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTitleElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTitleElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTitleElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTitleElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get text() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get text' called on an object that is not a valid instance of HTMLTitleElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["text"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set text(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set text' called on an object that is not a valid instance of HTMLTitleElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'text' property on 'HTMLTitleElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["text"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLTitleElement.prototype, { + text: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTitleElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLTitleElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTitleElement + }); +}; + +const Impl = require("../nodes/HTMLTitleElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLTrackElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTrackElement.js new file mode 100644 index 00000000..d2297820 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLTrackElement.js @@ -0,0 +1,356 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLTrackElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLTrackElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLTrackElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLTrackElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get kind() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get kind' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "kind"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set kind(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set kind' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'kind' property on 'HTMLTrackElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "kind", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get src() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get src' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "src"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set src(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set src' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'src' property on 'HTMLTrackElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "src", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get srclang() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get srclang' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "srclang"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set srclang(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set srclang' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'srclang' property on 'HTMLTrackElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "srclang", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get label() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get label' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "label"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set label(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set label' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'label' property on 'HTMLTrackElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "label", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get default() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get default' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "default"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set default(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set default' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'default' property on 'HTMLTrackElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "default", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "default"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get readyState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readyState' called on an object that is not a valid instance of HTMLTrackElement." + ); + } + + return esValue[implSymbol]["readyState"]; + } + } + Object.defineProperties(HTMLTrackElement.prototype, { + kind: { enumerable: true }, + src: { enumerable: true }, + srclang: { enumerable: true }, + label: { enumerable: true }, + default: { enumerable: true }, + readyState: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLTrackElement", configurable: true }, + NONE: { value: 0, enumerable: true }, + LOADING: { value: 1, enumerable: true }, + LOADED: { value: 2, enumerable: true }, + ERROR: { value: 3, enumerable: true } + }); + Object.defineProperties(HTMLTrackElement, { + NONE: { value: 0, enumerable: true }, + LOADING: { value: 1, enumerable: true }, + LOADED: { value: 2, enumerable: true }, + ERROR: { value: 3, enumerable: true } + }); + ctorRegistry[interfaceName] = HTMLTrackElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLTrackElement + }); +}; + +const Impl = require("../nodes/HTMLTrackElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLUListElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLUListElement.js new file mode 100644 index 00000000..1ca4c431 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLUListElement.js @@ -0,0 +1,197 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLUListElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLUListElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLUListElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLUListElement extends globalObject.HTMLElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get compact() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get compact' called on an object that is not a valid instance of HTMLUListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "compact"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set compact(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set compact' called on an object that is not a valid instance of HTMLUListElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'compact' property on 'HTMLUListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "compact", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "compact"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of HTMLUListElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "type"); + return value === null ? "" : value; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set type(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set type' called on an object that is not a valid instance of HTMLUListElement." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'type' property on 'HTMLUListElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "type", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLUListElement.prototype, { + compact: { enumerable: true }, + type: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLUListElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLUListElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLUListElement + }); +}; + +const Impl = require("../nodes/HTMLUListElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLUnknownElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLUnknownElement.js new file mode 100644 index 00000000..7b3a0547 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLUnknownElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLElement = require("./HTMLElement.js"); + +const interfaceName = "HTMLUnknownElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLUnknownElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLUnknownElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLUnknownElement extends globalObject.HTMLElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(HTMLUnknownElement.prototype, { + [Symbol.toStringTag]: { value: "HTMLUnknownElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLUnknownElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLUnknownElement + }); +}; + +const Impl = require("../nodes/HTMLUnknownElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HTMLVideoElement.js b/node_modules/jsdom/lib/jsdom/living/generated/HTMLVideoElement.js new file mode 100644 index 00000000..5a2cbdf0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HTMLVideoElement.js @@ -0,0 +1,329 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLConstructor_helpers_html_constructor = require("../helpers/html-constructor.js").HTMLConstructor; +const parseNonNegativeInteger_helpers_strings = require("../helpers/strings.js").parseNonNegativeInteger; +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const parseURLToResultingURLRecord_helpers_document_base_url = + require("../helpers/document-base-url.js").parseURLToResultingURLRecord; +const serializeURLwhatwg_url = require("whatwg-url").serializeURL; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const HTMLMediaElement = require("./HTMLMediaElement.js"); + +const interfaceName = "HTMLVideoElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HTMLVideoElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HTMLVideoElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + HTMLMediaElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HTMLVideoElement extends globalObject.HTMLMediaElement { + constructor() { + return HTMLConstructor_helpers_html_constructor(globalObject, interfaceName, new.target); + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "width"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set width' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'width' property on 'HTMLVideoElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "width", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + let value = esValue[implSymbol].getAttributeNS(null, "height"); + if (value === null) { + return 0; + } + value = parseNonNegativeInteger_helpers_strings(value); + return value !== null && value >= 0 && value <= 2147483647 ? value : 0; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set height' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'height' property on 'HTMLVideoElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const n = V <= 2147483647 ? V : 0; + esValue[implSymbol].setAttributeNS(null, "height", String(n)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get videoWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get videoWidth' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + return esValue[implSymbol]["videoWidth"]; + } + + get videoHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get videoHeight' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + return esValue[implSymbol]["videoHeight"]; + } + + get poster() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get poster' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + const value = esValue[implSymbol].getAttributeNS(null, "poster"); + if (value === null) { + return ""; + } + const urlRecord = parseURLToResultingURLRecord_helpers_document_base_url( + value, + esValue[implSymbol]._ownerDocument + ); + if (urlRecord !== null) { + return serializeURLwhatwg_url(urlRecord); + } + return conversions.USVString(value); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set poster(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set poster' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'poster' property on 'HTMLVideoElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol].setAttributeNS(null, "poster", V); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get playsInline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get playsInline' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].hasAttributeNS(null, "playsinline"); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set playsInline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set playsInline' called on an object that is not a valid instance of HTMLVideoElement." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'playsInline' property on 'HTMLVideoElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + if (V) { + esValue[implSymbol].setAttributeNS(null, "playsinline", ""); + } else { + esValue[implSymbol].removeAttributeNS(null, "playsinline"); + } + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(HTMLVideoElement.prototype, { + width: { enumerable: true }, + height: { enumerable: true }, + videoWidth: { enumerable: true }, + videoHeight: { enumerable: true }, + poster: { enumerable: true }, + playsInline: { enumerable: true }, + [Symbol.toStringTag]: { value: "HTMLVideoElement", configurable: true } + }); + ctorRegistry[interfaceName] = HTMLVideoElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HTMLVideoElement + }); +}; + +const Impl = require("../nodes/HTMLVideoElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HashChangeEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/HashChangeEvent.js new file mode 100644 index 00000000..ceb7034b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HashChangeEvent.js @@ -0,0 +1,157 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HashChangeEventInit = require("./HashChangeEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "HashChangeEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'HashChangeEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["HashChangeEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class HashChangeEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'HashChangeEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'HashChangeEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = HashChangeEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'HashChangeEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get oldURL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oldURL' called on an object that is not a valid instance of HashChangeEvent." + ); + } + + return esValue[implSymbol]["oldURL"]; + } + + get newURL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get newURL' called on an object that is not a valid instance of HashChangeEvent." + ); + } + + return esValue[implSymbol]["newURL"]; + } + } + Object.defineProperties(HashChangeEvent.prototype, { + oldURL: { enumerable: true }, + newURL: { enumerable: true }, + [Symbol.toStringTag]: { value: "HashChangeEvent", configurable: true } + }); + ctorRegistry[interfaceName] = HashChangeEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: HashChangeEvent + }); +}; + +const Impl = require("../events/HashChangeEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/HashChangeEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/HashChangeEventInit.js new file mode 100644 index 00000000..8bce20d2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/HashChangeEventInit.js @@ -0,0 +1,50 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "newURL"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { + context: context + " has member 'newURL' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "oldURL"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { + context: context + " has member 'oldURL' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Headers.js b/node_modules/jsdom/lib/jsdom/living/generated/Headers.js new file mode 100644 index 00000000..3c2d3de0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Headers.js @@ -0,0 +1,408 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Function = require("./Function.js"); +const newObjectInRealm = utils.newObjectInRealm; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Headers"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Headers'.`); +}; + +exports.createDefaultIterator = (globalObject, target, kind) => { + const ctorRegistry = globalObject[ctorRegistrySymbol]; + const iteratorPrototype = ctorRegistry["Headers Iterator"]; + const iterator = Object.create(iteratorPrototype); + Object.defineProperty(iterator, utils.iterInternalSymbol, { + value: { target, kind, index: 0 }, + configurable: true + }); + return iterator; +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Headers"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Headers { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + if (utils.isObject(curArg)) { + if (curArg[Symbol.iterator] !== undefined) { + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError( + "Failed to construct 'Headers': parameter 1" + " sequence" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + if (!utils.isObject(nextItem)) { + throw new globalObject.TypeError( + "Failed to construct 'Headers': parameter 1" + + " sequence" + + "'s element" + + " is not an iterable object." + ); + } else { + const V = []; + const tmp = nextItem; + for (let nextItem of tmp) { + nextItem = conversions["ByteString"](nextItem, { + context: + "Failed to construct 'Headers': parameter 1" + " sequence" + "'s element" + "'s element", + globals: globalObject + }); + + V.push(nextItem); + } + nextItem = V; + } + + V.push(nextItem); + } + curArg = V; + } + } else { + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError( + "Failed to construct 'Headers': parameter 1" + " record" + " is not an object." + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + + typedKey = conversions["ByteString"](typedKey, { + context: "Failed to construct 'Headers': parameter 1" + " record" + "'s key", + globals: globalObject + }); + + let typedValue = curArg[key]; + + typedValue = conversions["ByteString"](typedValue, { + context: "Failed to construct 'Headers': parameter 1" + " record" + "'s value", + globals: globalObject + }); + + result[typedKey] = typedValue; + } + } + curArg = result; + } + } + } else { + throw new globalObject.TypeError( + "Failed to construct 'Headers': parameter 1" + " is not of any supported type." + ); + } + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + append(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'append' called on an object that is not a valid instance of Headers."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'append' on 'Headers': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'append' on 'Headers': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'append' on 'Headers': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].append(...args); + } + + delete(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'delete' called on an object that is not a valid instance of Headers."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'delete' on 'Headers': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'delete' on 'Headers': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].delete(...args); + } + + get(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get' called on an object that is not a valid instance of Headers."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'get' on 'Headers': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'get' on 'Headers': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].get(...args); + } + + has(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'has' called on an object that is not a valid instance of Headers."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'has' on 'Headers': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'has' on 'Headers': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].has(...args); + } + + set(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set' called on an object that is not a valid instance of Headers."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'set' on 'Headers': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'set' on 'Headers': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'set' on 'Headers': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].set(...args); + } + + keys() { + if (!exports.is(this)) { + throw new globalObject.TypeError("'keys' called on an object that is not a valid instance of Headers."); + } + return exports.createDefaultIterator(globalObject, this, "key"); + } + + values() { + if (!exports.is(this)) { + throw new globalObject.TypeError("'values' called on an object that is not a valid instance of Headers."); + } + return exports.createDefaultIterator(globalObject, this, "value"); + } + + entries() { + if (!exports.is(this)) { + throw new globalObject.TypeError("'entries' called on an object that is not a valid instance of Headers."); + } + return exports.createDefaultIterator(globalObject, this, "key+value"); + } + + forEach(callback) { + if (!exports.is(this)) { + throw new globalObject.TypeError("'forEach' called on an object that is not a valid instance of Headers."); + } + if (arguments.length < 1) { + throw new globalObject.TypeError( + "Failed to execute 'forEach' on 'iterable': 1 argument required, but only 0 present." + ); + } + callback = Function.convert(globalObject, callback, { + context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1" + }); + const thisArg = arguments[1]; + let pairs = Array.from(this[implSymbol]); + let i = 0; + while (i < pairs.length) { + const [key, value] = pairs[i].map(utils.tryWrapperForImpl); + callback.call(thisArg, value, key, this); + pairs = Array.from(this[implSymbol]); + i++; + } + } + } + Object.defineProperties(Headers.prototype, { + append: { enumerable: true }, + delete: { enumerable: true }, + get: { enumerable: true }, + has: { enumerable: true }, + set: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + forEach: { enumerable: true }, + [Symbol.toStringTag]: { value: "Headers", configurable: true }, + [Symbol.iterator]: { value: Headers.prototype.entries, configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = Headers; + + ctorRegistry["Headers Iterator"] = Object.create(ctorRegistry["%IteratorPrototype%"], { + [Symbol.toStringTag]: { + configurable: true, + value: "Headers Iterator" + } + }); + utils.define(ctorRegistry["Headers Iterator"], { + next() { + const internal = this && this[utils.iterInternalSymbol]; + if (!internal) { + throw new globalObject.TypeError("next() called on a value that is not a Headers iterator object"); + } + + const { target, kind, index } = internal; + const values = Array.from(target[implSymbol]); + const len = values.length; + if (index >= len) { + return newObjectInRealm(globalObject, { value: undefined, done: true }); + } + + const pair = values[index]; + internal.index = index + 1; + return newObjectInRealm(globalObject, utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind)); + } + }); + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Headers + }); +}; + +const Impl = require("../fetch/Headers-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/History.js b/node_modules/jsdom/lib/jsdom/living/generated/History.js new file mode 100644 index 00000000..39f6c579 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/History.js @@ -0,0 +1,266 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "History"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'History'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["History"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class History { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + go() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'go' called on an object that is not a valid instance of History."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'go' on 'History': parameter 1", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].go(...args); + } + + back() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'back' called on an object that is not a valid instance of History."); + } + + return esValue[implSymbol].back(); + } + + forward() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'forward' called on an object that is not a valid instance of History."); + } + + return esValue[implSymbol].forward(); + } + + pushState(data, title) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'pushState' called on an object that is not a valid instance of History."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'pushState' on 'History': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["any"](curArg, { + context: "Failed to execute 'pushState' on 'History': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'pushState' on 'History': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'pushState' on 'History': parameter 3", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].pushState(...args); + } + + replaceState(data, title) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'replaceState' called on an object that is not a valid instance of History."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'replaceState' on 'History': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["any"](curArg, { + context: "Failed to execute 'replaceState' on 'History': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceState' on 'History': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'replaceState' on 'History': parameter 3", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].replaceState(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of History."); + } + + return esValue[implSymbol]["length"]; + } + + get state() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get state' called on an object that is not a valid instance of History."); + } + + return esValue[implSymbol]["state"]; + } + } + Object.defineProperties(History.prototype, { + go: { enumerable: true }, + back: { enumerable: true }, + forward: { enumerable: true }, + pushState: { enumerable: true }, + replaceState: { enumerable: true }, + length: { enumerable: true }, + state: { enumerable: true }, + [Symbol.toStringTag]: { value: "History", configurable: true } + }); + ctorRegistry[interfaceName] = History; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: History + }); +}; + +const Impl = require("../window/History-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/InputEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/InputEvent.js new file mode 100644 index 00000000..ca8c6c21 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/InputEvent.js @@ -0,0 +1,168 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const InputEventInit = require("./InputEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "InputEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'InputEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["InputEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class InputEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'InputEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'InputEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = InputEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'InputEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get data() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get data' called on an object that is not a valid instance of InputEvent."); + } + + return esValue[implSymbol]["data"]; + } + + get isComposing() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isComposing' called on an object that is not a valid instance of InputEvent." + ); + } + + return esValue[implSymbol]["isComposing"]; + } + + get inputType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get inputType' called on an object that is not a valid instance of InputEvent." + ); + } + + return esValue[implSymbol]["inputType"]; + } + } + Object.defineProperties(InputEvent.prototype, { + data: { enumerable: true }, + isComposing: { enumerable: true }, + inputType: { enumerable: true }, + [Symbol.toStringTag]: { value: "InputEvent", configurable: true } + }); + ctorRegistry[interfaceName] = InputEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: InputEvent + }); +}; + +const Impl = require("../events/InputEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/InputEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/InputEventInit.js new file mode 100644 index 00000000..480be505 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/InputEventInit.js @@ -0,0 +1,68 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const UIEventInit = require("./UIEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + UIEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "data"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { + context: context + " has member 'data' that", + globals: globalObject + }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "inputType"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'inputType' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "isComposing"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'isComposing' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/KeyboardEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/KeyboardEvent.js new file mode 100644 index 00000000..4d54d279 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/KeyboardEvent.js @@ -0,0 +1,445 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const KeyboardEventInit = require("./KeyboardEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "KeyboardEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'KeyboardEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["KeyboardEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class KeyboardEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'KeyboardEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'KeyboardEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = KeyboardEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'KeyboardEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + getModifierState(keyArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getModifierState' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getModifierState' on 'KeyboardEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getModifierState' on 'KeyboardEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getModifierState(...args); + } + + initKeyboardEvent(typeArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initKeyboardEvent' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 5", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + { + let curArg = arguments[5]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 6", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[6]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 7", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[7]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 8", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[8]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 9", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[9]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initKeyboardEvent' on 'KeyboardEvent': parameter 10", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + return esValue[implSymbol].initKeyboardEvent(...args); + } + + get key() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get key' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["key"]; + } + + get code() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get code' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["code"]; + } + + get location() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get location' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["location"]; + } + + get ctrlKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ctrlKey' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["ctrlKey"]; + } + + get shiftKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shiftKey' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["shiftKey"]; + } + + get altKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get altKey' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["altKey"]; + } + + get metaKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get metaKey' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["metaKey"]; + } + + get repeat() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get repeat' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["repeat"]; + } + + get isComposing() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isComposing' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["isComposing"]; + } + + get charCode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get charCode' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["charCode"]; + } + + get keyCode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get keyCode' called on an object that is not a valid instance of KeyboardEvent." + ); + } + + return esValue[implSymbol]["keyCode"]; + } + } + Object.defineProperties(KeyboardEvent.prototype, { + getModifierState: { enumerable: true }, + initKeyboardEvent: { enumerable: true }, + key: { enumerable: true }, + code: { enumerable: true }, + location: { enumerable: true }, + ctrlKey: { enumerable: true }, + shiftKey: { enumerable: true }, + altKey: { enumerable: true }, + metaKey: { enumerable: true }, + repeat: { enumerable: true }, + isComposing: { enumerable: true }, + charCode: { enumerable: true }, + keyCode: { enumerable: true }, + [Symbol.toStringTag]: { value: "KeyboardEvent", configurable: true }, + DOM_KEY_LOCATION_STANDARD: { value: 0x00, enumerable: true }, + DOM_KEY_LOCATION_LEFT: { value: 0x01, enumerable: true }, + DOM_KEY_LOCATION_RIGHT: { value: 0x02, enumerable: true }, + DOM_KEY_LOCATION_NUMPAD: { value: 0x03, enumerable: true } + }); + Object.defineProperties(KeyboardEvent, { + DOM_KEY_LOCATION_STANDARD: { value: 0x00, enumerable: true }, + DOM_KEY_LOCATION_LEFT: { value: 0x01, enumerable: true }, + DOM_KEY_LOCATION_RIGHT: { value: 0x02, enumerable: true }, + DOM_KEY_LOCATION_NUMPAD: { value: 0x03, enumerable: true } + }); + ctorRegistry[interfaceName] = KeyboardEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: KeyboardEvent + }); +}; + +const Impl = require("../events/KeyboardEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/KeyboardEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/KeyboardEventInit.js new file mode 100644 index 00000000..9094ed37 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/KeyboardEventInit.js @@ -0,0 +1,116 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventModifierInit = require("./EventModifierInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventModifierInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "charCode"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'charCode' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "code"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { context: context + " has member 'code' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "isComposing"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'isComposing' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "key"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { context: context + " has member 'key' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "keyCode"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'keyCode' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "location"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'location' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "repeat"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'repeat' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Location.js b/node_modules/jsdom/lib/jsdom/living/generated/Location.js new file mode 100644 index 00000000..fc4d1dd4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Location.js @@ -0,0 +1,404 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Location"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Location'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Location"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +function getUnforgeables(globalObject) { + let unforgeables = unforgeablesMap.get(globalObject); + if (unforgeables === undefined) { + unforgeables = Object.create(null); + utils.define(unforgeables, { + assign(url) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'assign' called on an object that is not a valid instance of Location."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'assign' on 'Location': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'assign' on 'Location': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].assign(...args); + }, + replace(url) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'replace' called on an object that is not a valid instance of Location."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'replace' on 'Location': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'replace' on 'Location': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].replace(...args); + }, + reload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'reload' called on an object that is not a valid instance of Location."); + } + + return esValue[implSymbol].reload(); + }, + get href() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get href' called on an object that is not a valid instance of Location."); + } + + return esValue[implSymbol]["href"]; + }, + set href(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set href' called on an object that is not a valid instance of Location."); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'href' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["href"] = V; + }, + toString() { + const esValue = this; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of Location."); + } + + return esValue[implSymbol]["href"]; + }, + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get origin' called on an object that is not a valid instance of Location." + ); + } + + return esValue[implSymbol]["origin"]; + }, + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get protocol' called on an object that is not a valid instance of Location." + ); + } + + return esValue[implSymbol]["protocol"]; + }, + set protocol(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set protocol' called on an object that is not a valid instance of Location." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'protocol' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["protocol"] = V; + }, + get host() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of Location."); + } + + return esValue[implSymbol]["host"]; + }, + set host(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set host' called on an object that is not a valid instance of Location."); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'host' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["host"] = V; + }, + get hostname() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hostname' called on an object that is not a valid instance of Location." + ); + } + + return esValue[implSymbol]["hostname"]; + }, + set hostname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set hostname' called on an object that is not a valid instance of Location." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'hostname' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["hostname"] = V; + }, + get port() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get port' called on an object that is not a valid instance of Location."); + } + + return esValue[implSymbol]["port"]; + }, + set port(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set port' called on an object that is not a valid instance of Location."); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'port' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["port"] = V; + }, + get pathname() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pathname' called on an object that is not a valid instance of Location." + ); + } + + return esValue[implSymbol]["pathname"]; + }, + set pathname(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set pathname' called on an object that is not a valid instance of Location." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'pathname' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["pathname"] = V; + }, + get search() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get search' called on an object that is not a valid instance of Location." + ); + } + + return esValue[implSymbol]["search"]; + }, + set search(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set search' called on an object that is not a valid instance of Location." + ); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'search' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["search"] = V; + }, + get hash() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get hash' called on an object that is not a valid instance of Location."); + } + + return esValue[implSymbol]["hash"]; + }, + set hash(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set hash' called on an object that is not a valid instance of Location."); + } + + V = conversions["USVString"](V, { + context: "Failed to set the 'hash' property on 'Location': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["hash"] = V; + } + }); + Object.defineProperties(unforgeables, { + assign: { configurable: false, writable: false }, + replace: { configurable: false, writable: false }, + reload: { configurable: false, writable: false }, + href: { configurable: false }, + toString: { configurable: false, writable: false }, + origin: { configurable: false }, + protocol: { configurable: false }, + host: { configurable: false }, + hostname: { configurable: false }, + port: { configurable: false }, + pathname: { configurable: false }, + search: { configurable: false }, + hash: { configurable: false } + }); + unforgeablesMap.set(globalObject, unforgeables); + } + return unforgeables; +} + +exports._internalSetup = (wrapper, globalObject) => { + utils.define(wrapper, getUnforgeables(globalObject)); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const unforgeablesMap = new WeakMap(); +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Location { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(Location.prototype, { [Symbol.toStringTag]: { value: "Location", configurable: true } }); + ctorRegistry[interfaceName] = Location; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Location + }); +}; + +const Impl = require("../window/Location-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MessageEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/MessageEvent.js new file mode 100644 index 00000000..c7e35af6 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MessageEvent.js @@ -0,0 +1,317 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const MessageEventInit = require("./MessageEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "MessageEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'MessageEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["MessageEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker", "AudioWorklet"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MessageEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'MessageEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'MessageEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = MessageEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'MessageEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initMessageEvent(type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initMessageEvent' called on an object that is not a valid instance of MessageEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initMessageEvent' on 'MessageEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions["any"](curArg, { + context: "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 4", + globals: globalObject + }); + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 5", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + { + let curArg = arguments[5]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 6", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + { + let curArg = arguments[6]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[7]; + if (curArg !== undefined) { + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError( + "Failed to execute 'initMessageEvent' on 'MessageEvent': parameter 8" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + curArg = V; + } + } else { + curArg = []; + } + args.push(curArg); + } + return esValue[implSymbol].initMessageEvent(...args); + } + + get data() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get data' called on an object that is not a valid instance of MessageEvent." + ); + } + + return esValue[implSymbol]["data"]; + } + + get origin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get origin' called on an object that is not a valid instance of MessageEvent." + ); + } + + return esValue[implSymbol]["origin"]; + } + + get lastEventId() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lastEventId' called on an object that is not a valid instance of MessageEvent." + ); + } + + return esValue[implSymbol]["lastEventId"]; + } + + get source() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get source' called on an object that is not a valid instance of MessageEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["source"]); + } + + get ports() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ports' called on an object that is not a valid instance of MessageEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ports"]); + } + } + Object.defineProperties(MessageEvent.prototype, { + initMessageEvent: { enumerable: true }, + data: { enumerable: true }, + origin: { enumerable: true }, + lastEventId: { enumerable: true }, + source: { enumerable: true }, + ports: { enumerable: true }, + [Symbol.toStringTag]: { value: "MessageEvent", configurable: true } + }); + ctorRegistry[interfaceName] = MessageEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MessageEvent + }); +}; + +const Impl = require("../events/MessageEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MessageEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/MessageEventInit.js new file mode 100644 index 00000000..0e84b442 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MessageEventInit.js @@ -0,0 +1,100 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "data"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["any"](value, { context: context + " has member 'data' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "lastEventId"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'lastEventId' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "origin"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { + context: context + " has member 'origin' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "ports"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'ports' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "source"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = utils.tryImplForWrapper(value); + } + ret[key] = value; + } else { + ret[key] = null; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MimeType.js b/node_modules/jsdom/lib/jsdom/living/generated/MimeType.js new file mode 100644 index 00000000..5cc011e7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MimeType.js @@ -0,0 +1,156 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "MimeType"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'MimeType'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["MimeType"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MimeType { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of MimeType."); + } + + return esValue[implSymbol]["type"]; + } + + get description() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get description' called on an object that is not a valid instance of MimeType." + ); + } + + return esValue[implSymbol]["description"]; + } + + get suffixes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get suffixes' called on an object that is not a valid instance of MimeType." + ); + } + + return esValue[implSymbol]["suffixes"]; + } + + get enabledPlugin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get enabledPlugin' called on an object that is not a valid instance of MimeType." + ); + } + + return esValue[implSymbol]["enabledPlugin"]; + } + } + Object.defineProperties(MimeType.prototype, { + type: { enumerable: true }, + description: { enumerable: true }, + suffixes: { enumerable: true }, + enabledPlugin: { enumerable: true }, + [Symbol.toStringTag]: { value: "MimeType", configurable: true } + }); + ctorRegistry[interfaceName] = MimeType; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MimeType + }); +}; + +const Impl = require("../navigator/MimeType-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MimeTypeArray.js b/node_modules/jsdom/lib/jsdom/living/generated/MimeTypeArray.js new file mode 100644 index 00000000..fd6d1a14 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MimeTypeArray.js @@ -0,0 +1,352 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "MimeTypeArray"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'MimeTypeArray'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["MimeTypeArray"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MimeTypeArray { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of MimeTypeArray."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'MimeTypeArray': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'MimeTypeArray': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].item(...args); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'namedItem' called on an object that is not a valid instance of MimeTypeArray." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'MimeTypeArray': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'MimeTypeArray': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].namedItem(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of MimeTypeArray." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(MimeTypeArray.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "MimeTypeArray", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = MimeTypeArray; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MimeTypeArray + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../navigator/MimeTypeArray-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js new file mode 100644 index 00000000..5c3aaa60 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js @@ -0,0 +1,499 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const MouseEventInit = require("./MouseEventInit.js"); +const EventTarget = require("./EventTarget.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "MouseEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'MouseEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["MouseEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MouseEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'MouseEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'MouseEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = MouseEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'MouseEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + getModifierState(keyArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getModifierState' called on an object that is not a valid instance of MouseEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getModifierState' on 'MouseEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getModifierState' on 'MouseEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getModifierState(...args); + } + + initMouseEvent(typeArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initMouseEvent' called on an object that is not a valid instance of MouseEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initMouseEvent' on 'MouseEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 5", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[5]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 6", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[6]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 7", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[7]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 8", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[8]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 9", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[9]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 10", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[10]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 11", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[11]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 12", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[12]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 13", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[13]; + if (curArg !== undefined) { + curArg = conversions["short"](curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 14", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + { + let curArg = arguments[14]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = EventTarget.convert(globalObject, curArg, { + context: "Failed to execute 'initMouseEvent' on 'MouseEvent': parameter 15" + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].initMouseEvent(...args); + } + + get screenX() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get screenX' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["screenX"]; + } + + get screenY() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get screenY' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["screenY"]; + } + + get clientX() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clientX' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["clientX"]; + } + + get clientY() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get clientY' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["clientY"]; + } + + get ctrlKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ctrlKey' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["ctrlKey"]; + } + + get shiftKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shiftKey' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["shiftKey"]; + } + + get altKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get altKey' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["altKey"]; + } + + get metaKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get metaKey' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["metaKey"]; + } + + get button() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get button' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["button"]; + } + + get buttons() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get buttons' called on an object that is not a valid instance of MouseEvent." + ); + } + + return esValue[implSymbol]["buttons"]; + } + + get relatedTarget() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get relatedTarget' called on an object that is not a valid instance of MouseEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["relatedTarget"]); + } + } + Object.defineProperties(MouseEvent.prototype, { + getModifierState: { enumerable: true }, + initMouseEvent: { enumerable: true }, + screenX: { enumerable: true }, + screenY: { enumerable: true }, + clientX: { enumerable: true }, + clientY: { enumerable: true }, + ctrlKey: { enumerable: true }, + shiftKey: { enumerable: true }, + altKey: { enumerable: true }, + metaKey: { enumerable: true }, + button: { enumerable: true }, + buttons: { enumerable: true }, + relatedTarget: { enumerable: true }, + [Symbol.toStringTag]: { value: "MouseEvent", configurable: true } + }); + ctorRegistry[interfaceName] = MouseEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MouseEvent + }); +}; + +const Impl = require("../events/MouseEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MouseEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/MouseEventInit.js new file mode 100644 index 00000000..a5c5a886 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MouseEventInit.js @@ -0,0 +1,111 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventTarget = require("./EventTarget.js"); +const EventModifierInit = require("./EventModifierInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventModifierInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "button"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["short"](value, { context: context + " has member 'button' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "buttons"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned short"](value, { + context: context + " has member 'buttons' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "clientX"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'clientX' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "clientY"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'clientY' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "relatedTarget"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = EventTarget.convert(globalObject, value, { context: context + " has member 'relatedTarget' that" }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "screenX"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'screenX' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "screenY"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'screenY' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MutationCallback.js b/node_modules/jsdom/lib/jsdom/living/generated/MutationCallback.js new file mode 100644 index 00000000..dec585c4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MutationCallback.js @@ -0,0 +1,34 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (typeof value !== "function") { + throw new globalObject.TypeError(context + " is not a function"); + } + + function invokeTheCallbackFunction(mutations, observer) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + mutations = utils.tryWrapperForImpl(mutations); + + observer = utils.tryWrapperForImpl(observer); + + callResult = Reflect.apply(value, thisArg, [mutations, observer]); + } + + invokeTheCallbackFunction.construct = (mutations, observer) => { + mutations = utils.tryWrapperForImpl(mutations); + + observer = utils.tryWrapperForImpl(observer); + + let callResult = Reflect.construct(value, [mutations, observer]); + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MutationObserver.js b/node_modules/jsdom/lib/jsdom/living/generated/MutationObserver.js new file mode 100644 index 00000000..ffeb71fa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MutationObserver.js @@ -0,0 +1,178 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const MutationCallback = require("./MutationCallback.js"); +const Node = require("./Node.js"); +const MutationObserverInit = require("./MutationObserverInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "MutationObserver"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'MutationObserver'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["MutationObserver"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MutationObserver { + constructor(callback) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'MutationObserver': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = MutationCallback.convert(globalObject, curArg, { + context: "Failed to construct 'MutationObserver': parameter 1" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + observe(target) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'observe' called on an object that is not a valid instance of MutationObserver." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'observe' on 'MutationObserver': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'observe' on 'MutationObserver': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = MutationObserverInit.convert(globalObject, curArg, { + context: "Failed to execute 'observe' on 'MutationObserver': parameter 2" + }); + args.push(curArg); + } + return esValue[implSymbol].observe(...args); + } + + disconnect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'disconnect' called on an object that is not a valid instance of MutationObserver." + ); + } + + return esValue[implSymbol].disconnect(); + } + + takeRecords() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'takeRecords' called on an object that is not a valid instance of MutationObserver." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].takeRecords()); + } + } + Object.defineProperties(MutationObserver.prototype, { + observe: { enumerable: true }, + disconnect: { enumerable: true }, + takeRecords: { enumerable: true }, + [Symbol.toStringTag]: { value: "MutationObserver", configurable: true } + }); + ctorRegistry[interfaceName] = MutationObserver; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MutationObserver + }); +}; + +const Impl = require("../mutation-observer/MutationObserver-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MutationObserverInit.js b/node_modules/jsdom/lib/jsdom/living/generated/MutationObserverInit.js new file mode 100644 index 00000000..7efca69e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MutationObserverInit.js @@ -0,0 +1,121 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "attributeFilter"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError( + context + " has member 'attributeFilter' that" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = conversions["DOMString"](nextItem, { + context: context + " has member 'attributeFilter' that" + "'s element", + globals: globalObject + }); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } + } + + { + const key = "attributeOldValue"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'attributeOldValue' that", + globals: globalObject + }); + + ret[key] = value; + } + } + + { + const key = "attributes"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'attributes' that", + globals: globalObject + }); + + ret[key] = value; + } + } + + { + const key = "characterData"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'characterData' that", + globals: globalObject + }); + + ret[key] = value; + } + } + + { + const key = "characterDataOldValue"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'characterDataOldValue' that", + globals: globalObject + }); + + ret[key] = value; + } + } + + { + const key = "childList"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'childList' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "subtree"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'subtree' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/MutationRecord.js b/node_modules/jsdom/lib/jsdom/living/generated/MutationRecord.js new file mode 100644 index 00000000..c91d42cb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/MutationRecord.js @@ -0,0 +1,229 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "MutationRecord"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'MutationRecord'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["MutationRecord"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class MutationRecord { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get type' called on an object that is not a valid instance of MutationRecord." + ); + } + + return esValue[implSymbol]["type"]; + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of MutationRecord." + ); + } + + return utils.getSameObject(this, "target", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["target"]); + }); + } + + get addedNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get addedNodes' called on an object that is not a valid instance of MutationRecord." + ); + } + + return utils.getSameObject(this, "addedNodes", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["addedNodes"]); + }); + } + + get removedNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get removedNodes' called on an object that is not a valid instance of MutationRecord." + ); + } + + return utils.getSameObject(this, "removedNodes", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["removedNodes"]); + }); + } + + get previousSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get previousSibling' called on an object that is not a valid instance of MutationRecord." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["previousSibling"]); + } + + get nextSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get nextSibling' called on an object that is not a valid instance of MutationRecord." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["nextSibling"]); + } + + get attributeName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get attributeName' called on an object that is not a valid instance of MutationRecord." + ); + } + + return esValue[implSymbol]["attributeName"]; + } + + get attributeNamespace() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get attributeNamespace' called on an object that is not a valid instance of MutationRecord." + ); + } + + return esValue[implSymbol]["attributeNamespace"]; + } + + get oldValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oldValue' called on an object that is not a valid instance of MutationRecord." + ); + } + + return esValue[implSymbol]["oldValue"]; + } + } + Object.defineProperties(MutationRecord.prototype, { + type: { enumerable: true }, + target: { enumerable: true }, + addedNodes: { enumerable: true }, + removedNodes: { enumerable: true }, + previousSibling: { enumerable: true }, + nextSibling: { enumerable: true }, + attributeName: { enumerable: true }, + attributeNamespace: { enumerable: true }, + oldValue: { enumerable: true }, + [Symbol.toStringTag]: { value: "MutationRecord", configurable: true } + }); + ctorRegistry[interfaceName] = MutationRecord; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MutationRecord + }); +}; + +const Impl = require("../mutation-observer/MutationRecord-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/NamedNodeMap.js b/node_modules/jsdom/lib/jsdom/living/generated/NamedNodeMap.js new file mode 100644 index 00000000..d55bc2ee --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/NamedNodeMap.js @@ -0,0 +1,553 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Attr = require("./Attr.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "NamedNodeMap"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'NamedNodeMap'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["NamedNodeMap"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class NamedNodeMap { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of NamedNodeMap."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'NamedNodeMap': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'NamedNodeMap': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + getNamedItem(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getNamedItem' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getNamedItem' on 'NamedNodeMap': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getNamedItem' on 'NamedNodeMap': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getNamedItem(...args)); + } + + getNamedItemNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getNamedItemNS' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'getNamedItemNS' on 'NamedNodeMap': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getNamedItemNS' on 'NamedNodeMap': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getNamedItemNS' on 'NamedNodeMap': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getNamedItemNS(...args)); + } + + setNamedItem(attr) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setNamedItem' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setNamedItem' on 'NamedNodeMap': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Attr.convert(globalObject, curArg, { + context: "Failed to execute 'setNamedItem' on 'NamedNodeMap': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].setNamedItem(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + setNamedItemNS(attr) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setNamedItemNS' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setNamedItemNS' on 'NamedNodeMap': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Attr.convert(globalObject, curArg, { + context: "Failed to execute 'setNamedItemNS' on 'NamedNodeMap': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].setNamedItemNS(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + removeNamedItem(qualifiedName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeNamedItem' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeNamedItem' on 'NamedNodeMap': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeNamedItem' on 'NamedNodeMap': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].removeNamedItem(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + removeNamedItemNS(namespace, localName) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeNamedItemNS' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].removeNamedItemNS(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of NamedNodeMap." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(NamedNodeMap.prototype, { + item: { enumerable: true }, + getNamedItem: { enumerable: true }, + getNamedItemNS: { enumerable: true }, + setNamedItem: { enumerable: true }, + setNamedItemNS: { enumerable: true }, + removeNamedItem: { enumerable: true }, + removeNamedItemNS: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "NamedNodeMap", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = NamedNodeMap; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NamedNodeMap + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + const namedValue = target[implSymbol].getNamedItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: false, + enumerable: false, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + if (!utils.hasOwn(target, P)) { + const creating = !(target[implSymbol].getNamedItem(P) !== null); + if (!creating) { + return false; + } + } + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + if (target[implSymbol].getNamedItem(P) !== null && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../attributes/NamedNodeMap-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Navigator.js b/node_modules/jsdom/lib/jsdom/living/generated/Navigator.js new file mode 100644 index 00000000..4d475293 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Navigator.js @@ -0,0 +1,326 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Navigator"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Navigator'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Navigator"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Navigator { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + javaEnabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'javaEnabled' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol].javaEnabled(); + } + + get appCodeName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get appCodeName' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["appCodeName"]; + } + + get appName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get appName' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["appName"]; + } + + get appVersion() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get appVersion' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["appVersion"]; + } + + get platform() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get platform' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["platform"]; + } + + get product() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get product' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["product"]; + } + + get productSub() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get productSub' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["productSub"]; + } + + get userAgent() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get userAgent' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["userAgent"]; + } + + get vendor() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get vendor' called on an object that is not a valid instance of Navigator."); + } + + return esValue[implSymbol]["vendor"]; + } + + get vendorSub() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get vendorSub' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["vendorSub"]; + } + + get language() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get language' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["language"]; + } + + get languages() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get languages' called on an object that is not a valid instance of Navigator." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["languages"]); + } + + get onLine() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onLine' called on an object that is not a valid instance of Navigator."); + } + + return esValue[implSymbol]["onLine"]; + } + + get cookieEnabled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get cookieEnabled' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["cookieEnabled"]; + } + + get plugins() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get plugins' called on an object that is not a valid instance of Navigator." + ); + } + + return utils.getSameObject(this, "plugins", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["plugins"]); + }); + } + + get mimeTypes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get mimeTypes' called on an object that is not a valid instance of Navigator." + ); + } + + return utils.getSameObject(this, "mimeTypes", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["mimeTypes"]); + }); + } + + get hardwareConcurrency() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get hardwareConcurrency' called on an object that is not a valid instance of Navigator." + ); + } + + return esValue[implSymbol]["hardwareConcurrency"]; + } + } + Object.defineProperties(Navigator.prototype, { + javaEnabled: { enumerable: true }, + appCodeName: { enumerable: true }, + appName: { enumerable: true }, + appVersion: { enumerable: true }, + platform: { enumerable: true }, + product: { enumerable: true }, + productSub: { enumerable: true }, + userAgent: { enumerable: true }, + vendor: { enumerable: true }, + vendorSub: { enumerable: true }, + language: { enumerable: true }, + languages: { enumerable: true }, + onLine: { enumerable: true }, + cookieEnabled: { enumerable: true }, + plugins: { enumerable: true }, + mimeTypes: { enumerable: true }, + hardwareConcurrency: { enumerable: true }, + [Symbol.toStringTag]: { value: "Navigator", configurable: true } + }); + ctorRegistry[interfaceName] = Navigator; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Navigator + }); +}; + +const Impl = require("../navigator/Navigator-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Node.js b/node_modules/jsdom/lib/jsdom/living/generated/Node.js new file mode 100644 index 00000000..57939252 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Node.js @@ -0,0 +1,763 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const GetRootNodeOptions = require("./GetRootNodeOptions.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "Node"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Node'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Node"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Node extends globalObject.EventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + getRootNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getRootNode' called on an object that is not a valid instance of Node."); + } + const args = []; + { + let curArg = arguments[0]; + curArg = GetRootNodeOptions.convert(globalObject, curArg, { + context: "Failed to execute 'getRootNode' on 'Node': parameter 1" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getRootNode(...args)); + } + + hasChildNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'hasChildNodes' called on an object that is not a valid instance of Node."); + } + + return esValue[implSymbol].hasChildNodes(); + } + + normalize() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'normalize' called on an object that is not a valid instance of Node."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].normalize(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + cloneNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'cloneNode' called on an object that is not a valid instance of Node."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'cloneNode' on 'Node': parameter 1", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].cloneNode(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + isEqualNode(otherNode) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'isEqualNode' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'isEqualNode' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'isEqualNode' on 'Node': parameter 1" + }); + } + args.push(curArg); + } + return esValue[implSymbol].isEqualNode(...args); + } + + isSameNode(otherNode) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'isSameNode' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'isSameNode' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'isSameNode' on 'Node': parameter 1" + }); + } + args.push(curArg); + } + return esValue[implSymbol].isSameNode(...args); + } + + compareDocumentPosition(other) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'compareDocumentPosition' called on an object that is not a valid instance of Node." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'compareDocumentPosition' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'compareDocumentPosition' on 'Node': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].compareDocumentPosition(...args); + } + + contains(other) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'contains' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'contains' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'contains' on 'Node': parameter 1" + }); + } + args.push(curArg); + } + return esValue[implSymbol].contains(...args); + } + + lookupPrefix(namespace) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'lookupPrefix' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'lookupPrefix' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'lookupPrefix' on 'Node': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].lookupPrefix(...args); + } + + lookupNamespaceURI(prefix) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'lookupNamespaceURI' called on an object that is not a valid instance of Node." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'lookupNamespaceURI' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'lookupNamespaceURI' on 'Node': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].lookupNamespaceURI(...args); + } + + isDefaultNamespace(namespace) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'isDefaultNamespace' called on an object that is not a valid instance of Node." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'isDefaultNamespace' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'isDefaultNamespace' on 'Node': parameter 1", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].isDefaultNamespace(...args); + } + + insertBefore(node, child) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'insertBefore' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'insertBefore' on 'Node': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'insertBefore' on 'Node': parameter 2" + }); + } + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].insertBefore(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + appendChild(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'appendChild' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'appendChild' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'appendChild' on 'Node': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].appendChild(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + replaceChild(node, child) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'replaceChild' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'replaceChild' on 'Node': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'replaceChild' on 'Node': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'replaceChild' on 'Node': parameter 2" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].replaceChild(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + removeChild(child) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'removeChild' called on an object that is not a valid instance of Node."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeChild' on 'Node': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'removeChild' on 'Node': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].removeChild(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get nodeType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get nodeType' called on an object that is not a valid instance of Node."); + } + + return esValue[implSymbol]["nodeType"]; + } + + get nodeName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get nodeName' called on an object that is not a valid instance of Node."); + } + + return esValue[implSymbol]["nodeName"]; + } + + get baseURI() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get baseURI' called on an object that is not a valid instance of Node."); + } + + return esValue[implSymbol]["baseURI"]; + } + + get isConnected() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get isConnected' called on an object that is not a valid instance of Node."); + } + + return esValue[implSymbol]["isConnected"]; + } + + get ownerDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ownerDocument' called on an object that is not a valid instance of Node." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ownerDocument"]); + } + + get parentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get parentNode' called on an object that is not a valid instance of Node."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["parentNode"]); + } + + get parentElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get parentElement' called on an object that is not a valid instance of Node." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["parentElement"]); + } + + get childNodes() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get childNodes' called on an object that is not a valid instance of Node."); + } + + return utils.getSameObject(this, "childNodes", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["childNodes"]); + }); + } + + get firstChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get firstChild' called on an object that is not a valid instance of Node."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["firstChild"]); + } + + get lastChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get lastChild' called on an object that is not a valid instance of Node."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["lastChild"]); + } + + get previousSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get previousSibling' called on an object that is not a valid instance of Node." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["previousSibling"]); + } + + get nextSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get nextSibling' called on an object that is not a valid instance of Node."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["nextSibling"]); + } + + get nodeValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get nodeValue' called on an object that is not a valid instance of Node."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["nodeValue"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set nodeValue(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set nodeValue' called on an object that is not a valid instance of Node."); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'nodeValue' property on 'Node': The provided value", + globals: globalObject + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["nodeValue"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get textContent() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get textContent' called on an object that is not a valid instance of Node."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["textContent"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set textContent(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set textContent' called on an object that is not a valid instance of Node."); + } + + if (V === null || V === undefined) { + V = null; + } else { + V = conversions["DOMString"](V, { + context: "Failed to set the 'textContent' property on 'Node': The provided value", + globals: globalObject + }); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["textContent"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(Node.prototype, { + getRootNode: { enumerable: true }, + hasChildNodes: { enumerable: true }, + normalize: { enumerable: true }, + cloneNode: { enumerable: true }, + isEqualNode: { enumerable: true }, + isSameNode: { enumerable: true }, + compareDocumentPosition: { enumerable: true }, + contains: { enumerable: true }, + lookupPrefix: { enumerable: true }, + lookupNamespaceURI: { enumerable: true }, + isDefaultNamespace: { enumerable: true }, + insertBefore: { enumerable: true }, + appendChild: { enumerable: true }, + replaceChild: { enumerable: true }, + removeChild: { enumerable: true }, + nodeType: { enumerable: true }, + nodeName: { enumerable: true }, + baseURI: { enumerable: true }, + isConnected: { enumerable: true }, + ownerDocument: { enumerable: true }, + parentNode: { enumerable: true }, + parentElement: { enumerable: true }, + childNodes: { enumerable: true }, + firstChild: { enumerable: true }, + lastChild: { enumerable: true }, + previousSibling: { enumerable: true }, + nextSibling: { enumerable: true }, + nodeValue: { enumerable: true }, + textContent: { enumerable: true }, + [Symbol.toStringTag]: { value: "Node", configurable: true }, + ELEMENT_NODE: { value: 1, enumerable: true }, + ATTRIBUTE_NODE: { value: 2, enumerable: true }, + TEXT_NODE: { value: 3, enumerable: true }, + CDATA_SECTION_NODE: { value: 4, enumerable: true }, + ENTITY_REFERENCE_NODE: { value: 5, enumerable: true }, + ENTITY_NODE: { value: 6, enumerable: true }, + PROCESSING_INSTRUCTION_NODE: { value: 7, enumerable: true }, + COMMENT_NODE: { value: 8, enumerable: true }, + DOCUMENT_NODE: { value: 9, enumerable: true }, + DOCUMENT_TYPE_NODE: { value: 10, enumerable: true }, + DOCUMENT_FRAGMENT_NODE: { value: 11, enumerable: true }, + NOTATION_NODE: { value: 12, enumerable: true }, + DOCUMENT_POSITION_DISCONNECTED: { value: 0x01, enumerable: true }, + DOCUMENT_POSITION_PRECEDING: { value: 0x02, enumerable: true }, + DOCUMENT_POSITION_FOLLOWING: { value: 0x04, enumerable: true }, + DOCUMENT_POSITION_CONTAINS: { value: 0x08, enumerable: true }, + DOCUMENT_POSITION_CONTAINED_BY: { value: 0x10, enumerable: true }, + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: { value: 0x20, enumerable: true } + }); + Object.defineProperties(Node, { + ELEMENT_NODE: { value: 1, enumerable: true }, + ATTRIBUTE_NODE: { value: 2, enumerable: true }, + TEXT_NODE: { value: 3, enumerable: true }, + CDATA_SECTION_NODE: { value: 4, enumerable: true }, + ENTITY_REFERENCE_NODE: { value: 5, enumerable: true }, + ENTITY_NODE: { value: 6, enumerable: true }, + PROCESSING_INSTRUCTION_NODE: { value: 7, enumerable: true }, + COMMENT_NODE: { value: 8, enumerable: true }, + DOCUMENT_NODE: { value: 9, enumerable: true }, + DOCUMENT_TYPE_NODE: { value: 10, enumerable: true }, + DOCUMENT_FRAGMENT_NODE: { value: 11, enumerable: true }, + NOTATION_NODE: { value: 12, enumerable: true }, + DOCUMENT_POSITION_DISCONNECTED: { value: 0x01, enumerable: true }, + DOCUMENT_POSITION_PRECEDING: { value: 0x02, enumerable: true }, + DOCUMENT_POSITION_FOLLOWING: { value: 0x04, enumerable: true }, + DOCUMENT_POSITION_CONTAINS: { value: 0x08, enumerable: true }, + DOCUMENT_POSITION_CONTAINED_BY: { value: 0x10, enumerable: true }, + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: { value: 0x20, enumerable: true } + }); + ctorRegistry[interfaceName] = Node; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Node + }); +}; + +const Impl = require("../nodes/Node-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/NodeFilter.js b/node_modules/jsdom/lib/jsdom/living/generated/NodeFilter.js new file mode 100644 index 00000000..e7c28407 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/NodeFilter.js @@ -0,0 +1,75 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + function callTheUserObjectsOperation(node) { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; + + if (typeof O !== "function") { + X = O["acceptNode"]; + if (typeof X !== "function") { + throw new globalObject.TypeError(`${context} does not correctly implement NodeFilter.`); + } + thisArg = O; + } + + node = utils.tryWrapperForImpl(node); + + let callResult = Reflect.apply(X, thisArg, [node]); + + callResult = conversions["unsigned short"](callResult, { context: context, globals: globalObject }); + + return callResult; + } + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + const NodeFilter = () => { + throw new globalObject.TypeError("Illegal invocation"); + }; + + Object.defineProperties(NodeFilter, { + FILTER_ACCEPT: { value: 1, enumerable: true }, + FILTER_REJECT: { value: 2, enumerable: true }, + FILTER_SKIP: { value: 3, enumerable: true }, + SHOW_ALL: { value: 0xffffffff, enumerable: true }, + SHOW_ELEMENT: { value: 0x1, enumerable: true }, + SHOW_ATTRIBUTE: { value: 0x2, enumerable: true }, + SHOW_TEXT: { value: 0x4, enumerable: true }, + SHOW_CDATA_SECTION: { value: 0x8, enumerable: true }, + SHOW_ENTITY_REFERENCE: { value: 0x10, enumerable: true }, + SHOW_ENTITY: { value: 0x20, enumerable: true }, + SHOW_PROCESSING_INSTRUCTION: { value: 0x40, enumerable: true }, + SHOW_COMMENT: { value: 0x80, enumerable: true }, + SHOW_DOCUMENT: { value: 0x100, enumerable: true }, + SHOW_DOCUMENT_TYPE: { value: 0x200, enumerable: true }, + SHOW_DOCUMENT_FRAGMENT: { value: 0x400, enumerable: true }, + SHOW_NOTATION: { value: 0x800, enumerable: true } + }); + + Object.defineProperty(globalObject, "NodeFilter", { + configurable: true, + writable: true, + value: NodeFilter + }); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/NodeIterator.js b/node_modules/jsdom/lib/jsdom/living/generated/NodeIterator.js new file mode 100644 index 00000000..872bdf03 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/NodeIterator.js @@ -0,0 +1,207 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "NodeIterator"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'NodeIterator'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["NodeIterator"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class NodeIterator { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + nextNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'nextNode' called on an object that is not a valid instance of NodeIterator." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].nextNode()); + } + + previousNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'previousNode' called on an object that is not a valid instance of NodeIterator." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].previousNode()); + } + + detach() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'detach' called on an object that is not a valid instance of NodeIterator."); + } + + return esValue[implSymbol].detach(); + } + + get root() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get root' called on an object that is not a valid instance of NodeIterator." + ); + } + + return utils.getSameObject(this, "root", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["root"]); + }); + } + + get referenceNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get referenceNode' called on an object that is not a valid instance of NodeIterator." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["referenceNode"]); + } + + get pointerBeforeReferenceNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pointerBeforeReferenceNode' called on an object that is not a valid instance of NodeIterator." + ); + } + + return esValue[implSymbol]["pointerBeforeReferenceNode"]; + } + + get whatToShow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get whatToShow' called on an object that is not a valid instance of NodeIterator." + ); + } + + return esValue[implSymbol]["whatToShow"]; + } + + get filter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get filter' called on an object that is not a valid instance of NodeIterator." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["filter"]); + } + } + Object.defineProperties(NodeIterator.prototype, { + nextNode: { enumerable: true }, + previousNode: { enumerable: true }, + detach: { enumerable: true }, + root: { enumerable: true }, + referenceNode: { enumerable: true }, + pointerBeforeReferenceNode: { enumerable: true }, + whatToShow: { enumerable: true }, + filter: { enumerable: true }, + [Symbol.toStringTag]: { value: "NodeIterator", configurable: true } + }); + ctorRegistry[interfaceName] = NodeIterator; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NodeIterator + }); +}; + +const Impl = require("../traversal/NodeIterator-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/NodeList.js b/node_modules/jsdom/lib/jsdom/living/generated/NodeList.js new file mode 100644 index 00000000..ad0aa45f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/NodeList.js @@ -0,0 +1,328 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "NodeList"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'NodeList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["NodeList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class NodeList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of NodeList."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'NodeList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'NodeList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of NodeList."); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(NodeList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "NodeList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true }, + keys: { value: globalObject.Array.prototype.keys, configurable: true, enumerable: true, writable: true }, + values: { value: globalObject.Array.prototype.values, configurable: true, enumerable: true, writable: true }, + entries: { value: globalObject.Array.prototype.entries, configurable: true, enumerable: true, writable: true }, + forEach: { value: globalObject.Array.prototype.forEach, configurable: true, enumerable: true, writable: true } + }); + ctorRegistry[interfaceName] = NodeList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NodeList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/NodeList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/OnBeforeUnloadEventHandlerNonNull.js b/node_modules/jsdom/lib/jsdom/living/generated/OnBeforeUnloadEventHandlerNonNull.js new file mode 100644 index 00000000..571d1109 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/OnBeforeUnloadEventHandlerNonNull.js @@ -0,0 +1,42 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + function invokeTheCallbackFunction(event) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + if (typeof value === "function") { + event = utils.tryWrapperForImpl(event); + + callResult = Reflect.apply(value, thisArg, [event]); + } + + if (callResult === null || callResult === undefined) { + callResult = null; + } else { + callResult = conversions["DOMString"](callResult, { context: context, globals: globalObject }); + } + return callResult; + } + + invokeTheCallbackFunction.construct = event => { + event = utils.tryWrapperForImpl(event); + + let callResult = Reflect.construct(value, [event]); + + if (callResult === null || callResult === undefined) { + callResult = null; + } else { + callResult = conversions["DOMString"](callResult, { context: context, globals: globalObject }); + } + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/OnErrorEventHandlerNonNull.js b/node_modules/jsdom/lib/jsdom/living/generated/OnErrorEventHandlerNonNull.js new file mode 100644 index 00000000..11e64081 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/OnErrorEventHandlerNonNull.js @@ -0,0 +1,56 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + function invokeTheCallbackFunction(...args) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + if (typeof value === "function") { + for (let i = 0; i < Math.min(args.length, 5); i++) { + args[i] = utils.tryWrapperForImpl(args[i]); + } + + if (args.length < 1) { + for (let i = args.length; i < 1; i++) { + args[i] = undefined; + } + } else if (args.length > 5) { + args.length = 5; + } + + callResult = Reflect.apply(value, thisArg, args); + } + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + } + + invokeTheCallbackFunction.construct = (...args) => { + for (let i = 0; i < Math.min(args.length, 5); i++) { + args[i] = utils.tryWrapperForImpl(args[i]); + } + + if (args.length < 1) { + for (let i = args.length; i < 1; i++) { + args[i] = undefined; + } + } else if (args.length > 5) { + args.length = 5; + } + + let callResult = Reflect.construct(value, args); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEvent.js new file mode 100644 index 00000000..18a6f149 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEvent.js @@ -0,0 +1,144 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PageTransitionEventInit = require("./PageTransitionEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "PageTransitionEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'PageTransitionEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PageTransitionEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PageTransitionEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'PageTransitionEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'PageTransitionEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = PageTransitionEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'PageTransitionEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get persisted() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get persisted' called on an object that is not a valid instance of PageTransitionEvent." + ); + } + + return esValue[implSymbol]["persisted"]; + } + } + Object.defineProperties(PageTransitionEvent.prototype, { + persisted: { enumerable: true }, + [Symbol.toStringTag]: { value: "PageTransitionEvent", configurable: true } + }); + ctorRegistry[interfaceName] = PageTransitionEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PageTransitionEvent + }); +}; + +const Impl = require("../events/PageTransitionEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEventInit.js new file mode 100644 index 00000000..008ee187 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEventInit.js @@ -0,0 +1,35 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "persisted"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'persisted' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Performance.js b/node_modules/jsdom/lib/jsdom/living/generated/Performance.js new file mode 100644 index 00000000..fee01800 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Performance.js @@ -0,0 +1,142 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "Performance"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Performance'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Performance"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Performance extends globalObject.EventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + now() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'now' called on an object that is not a valid instance of Performance."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].now()); + } + + toJSON() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toJSON' called on an object that is not a valid instance of Performance."); + } + + return esValue[implSymbol].toJSON(); + } + + get timeOrigin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get timeOrigin' called on an object that is not a valid instance of Performance." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["timeOrigin"]); + } + } + Object.defineProperties(Performance.prototype, { + now: { enumerable: true }, + toJSON: { enumerable: true }, + timeOrigin: { enumerable: true }, + [Symbol.toStringTag]: { value: "Performance", configurable: true } + }); + ctorRegistry[interfaceName] = Performance; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Performance + }); +}; + +const Impl = require("../hr-time/Performance-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Plugin.js b/node_modules/jsdom/lib/jsdom/living/generated/Plugin.js new file mode 100644 index 00000000..d5b38bb8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Plugin.js @@ -0,0 +1,385 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Plugin"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Plugin'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Plugin"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Plugin { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of Plugin."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'Plugin': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'Plugin': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].item(...args); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'namedItem' called on an object that is not a valid instance of Plugin."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'Plugin': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'Plugin': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].namedItem(...args); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of Plugin."); + } + + return esValue[implSymbol]["name"]; + } + + get description() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get description' called on an object that is not a valid instance of Plugin." + ); + } + + return esValue[implSymbol]["description"]; + } + + get filename() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get filename' called on an object that is not a valid instance of Plugin."); + } + + return esValue[implSymbol]["filename"]; + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of Plugin."); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(Plugin.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + name: { enumerable: true }, + description: { enumerable: true }, + filename: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "Plugin", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = Plugin; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Plugin + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !target[implSymbol][utils.supportsPropertyIndex](index); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../navigator/Plugin-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PluginArray.js b/node_modules/jsdom/lib/jsdom/living/generated/PluginArray.js new file mode 100644 index 00000000..df6cbcd7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PluginArray.js @@ -0,0 +1,362 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "PluginArray"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'PluginArray'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PluginArray"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PluginArray { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + refresh() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'refresh' called on an object that is not a valid instance of PluginArray."); + } + + return esValue[implSymbol].refresh(); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of PluginArray."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'PluginArray': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'PluginArray': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].item(...args); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'namedItem' called on an object that is not a valid instance of PluginArray." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'PluginArray': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'PluginArray': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].namedItem(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of PluginArray." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(PluginArray.prototype, { + refresh: { enumerable: true }, + item: { enumerable: true }, + namedItem: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "PluginArray", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = PluginArray; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PluginArray + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../navigator/PluginArray-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PopStateEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEvent.js new file mode 100644 index 00000000..c46b2998 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEvent.js @@ -0,0 +1,144 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PopStateEventInit = require("./PopStateEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "PopStateEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'PopStateEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PopStateEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PopStateEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'PopStateEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'PopStateEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = PopStateEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'PopStateEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get state() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get state' called on an object that is not a valid instance of PopStateEvent." + ); + } + + return esValue[implSymbol]["state"]; + } + } + Object.defineProperties(PopStateEvent.prototype, { + state: { enumerable: true }, + [Symbol.toStringTag]: { value: "PopStateEvent", configurable: true } + }); + ctorRegistry[interfaceName] = PopStateEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PopStateEvent + }); +}; + +const Impl = require("../events/PopStateEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PopStateEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEventInit.js new file mode 100644 index 00000000..79ecec85 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEventInit.js @@ -0,0 +1,32 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "state"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["any"](value, { context: context + " has member 'state' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = null; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ProcessingInstruction.js b/node_modules/jsdom/lib/jsdom/living/generated/ProcessingInstruction.js new file mode 100644 index 00000000..b936d91a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ProcessingInstruction.js @@ -0,0 +1,122 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const CharacterData = require("./CharacterData.js"); + +const interfaceName = "ProcessingInstruction"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'ProcessingInstruction'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ProcessingInstruction"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + CharacterData._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ProcessingInstruction extends globalObject.CharacterData { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of ProcessingInstruction." + ); + } + + return esValue[implSymbol]["target"]; + } + } + Object.defineProperties(ProcessingInstruction.prototype, { + target: { enumerable: true }, + [Symbol.toStringTag]: { value: "ProcessingInstruction", configurable: true } + }); + ctorRegistry[interfaceName] = ProcessingInstruction; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ProcessingInstruction + }); +}; + +const Impl = require("../nodes/ProcessingInstruction-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js new file mode 100644 index 00000000..58fb0a3e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js @@ -0,0 +1,170 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ProgressEventInit = require("./ProgressEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "ProgressEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'ProgressEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ProgressEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ProgressEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'ProgressEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'ProgressEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = ProgressEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'ProgressEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get lengthComputable() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lengthComputable' called on an object that is not a valid instance of ProgressEvent." + ); + } + + return esValue[implSymbol]["lengthComputable"]; + } + + get loaded() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get loaded' called on an object that is not a valid instance of ProgressEvent." + ); + } + + return esValue[implSymbol]["loaded"]; + } + + get total() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get total' called on an object that is not a valid instance of ProgressEvent." + ); + } + + return esValue[implSymbol]["total"]; + } + } + Object.defineProperties(ProgressEvent.prototype, { + lengthComputable: { enumerable: true }, + loaded: { enumerable: true }, + total: { enumerable: true }, + [Symbol.toStringTag]: { value: "ProgressEvent", configurable: true } + }); + ctorRegistry[interfaceName] = ProgressEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ProgressEvent + }); +}; + +const Impl = require("../events/ProgressEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js new file mode 100644 index 00000000..2738568c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js @@ -0,0 +1,65 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "lengthComputable"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'lengthComputable' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "loaded"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long long"](value, { + context: context + " has member 'loaded' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "total"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long long"](value, { + context: context + " has member 'total' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/RadioNodeList.js b/node_modules/jsdom/lib/jsdom/living/generated/RadioNodeList.js new file mode 100644 index 00000000..f7f82090 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/RadioNodeList.js @@ -0,0 +1,322 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const NodeList = require("./NodeList.js"); + +const interfaceName = "RadioNodeList"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'RadioNodeList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["RadioNodeList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + NodeList._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class RadioNodeList extends globalObject.NodeList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of RadioNodeList." + ); + } + + return esValue[implSymbol]["value"]; + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of RadioNodeList." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'RadioNodeList': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["value"] = V; + } + } + Object.defineProperties(RadioNodeList.prototype, { + value: { enumerable: true }, + [Symbol.toStringTag]: { value: "RadioNodeList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = RadioNodeList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: RadioNodeList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/RadioNodeList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Range.js b/node_modules/jsdom/lib/jsdom/living/generated/Range.js new file mode 100644 index 00000000..3d774be4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Range.js @@ -0,0 +1,641 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const AbstractRange = require("./AbstractRange.js"); + +const interfaceName = "Range"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Range'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Range"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + AbstractRange._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Range extends globalObject.AbstractRange { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + setStart(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setStart' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setStart' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setStart' on 'Range': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setStart' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setStart(...args); + } + + setEnd(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setEnd' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setEnd' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { context: "Failed to execute 'setEnd' on 'Range': parameter 1" }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setEnd' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setEnd(...args); + } + + setStartBefore(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setStartBefore' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setStartBefore' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setStartBefore' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setStartBefore(...args); + } + + setStartAfter(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setStartAfter' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setStartAfter' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setStartAfter' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setStartAfter(...args); + } + + setEndBefore(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setEndBefore' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setEndBefore' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setEndBefore' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setEndBefore(...args); + } + + setEndAfter(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setEndAfter' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setEndAfter' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setEndAfter' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setEndAfter(...args); + } + + collapse() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'collapse' called on an object that is not a valid instance of Range."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'collapse' on 'Range': parameter 1", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + return esValue[implSymbol].collapse(...args); + } + + selectNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'selectNode' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'selectNode' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'selectNode' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].selectNode(...args); + } + + selectNodeContents(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'selectNodeContents' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'selectNodeContents' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'selectNodeContents' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].selectNodeContents(...args); + } + + compareBoundaryPoints(how, sourceRange) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'compareBoundaryPoints' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'compareBoundaryPoints' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned short"](curArg, { + context: "Failed to execute 'compareBoundaryPoints' on 'Range': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'compareBoundaryPoints' on 'Range': parameter 2" + }); + args.push(curArg); + } + return esValue[implSymbol].compareBoundaryPoints(...args); + } + + deleteContents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'deleteContents' called on an object that is not a valid instance of Range."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteContents(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + extractContents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'extractContents' called on an object that is not a valid instance of Range." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].extractContents()); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + cloneContents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'cloneContents' called on an object that is not a valid instance of Range."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].cloneContents()); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + insertNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'insertNode' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'insertNode' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'insertNode' on 'Range': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].insertNode(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + surroundContents(newParent) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'surroundContents' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'surroundContents' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'surroundContents' on 'Range': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].surroundContents(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + cloneRange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'cloneRange' called on an object that is not a valid instance of Range."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].cloneRange()); + } + + detach() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'detach' called on an object that is not a valid instance of Range."); + } + + return esValue[implSymbol].detach(); + } + + isPointInRange(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'isPointInRange' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'isPointInRange' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'isPointInRange' on 'Range': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'isPointInRange' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].isPointInRange(...args); + } + + comparePoint(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'comparePoint' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'comparePoint' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'comparePoint' on 'Range': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'comparePoint' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].comparePoint(...args); + } + + intersectsNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'intersectsNode' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'intersectsNode' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'intersectsNode' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].intersectsNode(...args); + } + + toString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of Range."); + } + + return esValue[implSymbol].toString(); + } + + createContextualFragment(fragment) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createContextualFragment' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createContextualFragment' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createContextualFragment' on 'Range': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].createContextualFragment(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get commonAncestorContainer() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get commonAncestorContainer' called on an object that is not a valid instance of Range." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["commonAncestorContainer"]); + } + } + Object.defineProperties(Range.prototype, { + setStart: { enumerable: true }, + setEnd: { enumerable: true }, + setStartBefore: { enumerable: true }, + setStartAfter: { enumerable: true }, + setEndBefore: { enumerable: true }, + setEndAfter: { enumerable: true }, + collapse: { enumerable: true }, + selectNode: { enumerable: true }, + selectNodeContents: { enumerable: true }, + compareBoundaryPoints: { enumerable: true }, + deleteContents: { enumerable: true }, + extractContents: { enumerable: true }, + cloneContents: { enumerable: true }, + insertNode: { enumerable: true }, + surroundContents: { enumerable: true }, + cloneRange: { enumerable: true }, + detach: { enumerable: true }, + isPointInRange: { enumerable: true }, + comparePoint: { enumerable: true }, + intersectsNode: { enumerable: true }, + toString: { enumerable: true }, + createContextualFragment: { enumerable: true }, + commonAncestorContainer: { enumerable: true }, + [Symbol.toStringTag]: { value: "Range", configurable: true }, + START_TO_START: { value: 0, enumerable: true }, + START_TO_END: { value: 1, enumerable: true }, + END_TO_END: { value: 2, enumerable: true }, + END_TO_START: { value: 3, enumerable: true } + }); + Object.defineProperties(Range, { + START_TO_START: { value: 0, enumerable: true }, + START_TO_END: { value: 1, enumerable: true }, + END_TO_END: { value: 2, enumerable: true }, + END_TO_START: { value: 3, enumerable: true } + }); + ctorRegistry[interfaceName] = Range; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Range + }); +}; + +const Impl = require("../range/Range-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedString.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedString.js new file mode 100644 index 00000000..75c6ee99 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedString.js @@ -0,0 +1,149 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGAnimatedString"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGAnimatedString'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGAnimatedString"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGAnimatedString { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get baseVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get baseVal' called on an object that is not a valid instance of SVGAnimatedString." + ); + } + + return esValue[implSymbol]["baseVal"]; + } + + set baseVal(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set baseVal' called on an object that is not a valid instance of SVGAnimatedString." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'baseVal' property on 'SVGAnimatedString': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["baseVal"] = V; + } + + get animVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get animVal' called on an object that is not a valid instance of SVGAnimatedString." + ); + } + + return esValue[implSymbol]["animVal"]; + } + } + Object.defineProperties(SVGAnimatedString.prototype, { + baseVal: { enumerable: true }, + animVal: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGAnimatedString", configurable: true } + }); + ctorRegistry[interfaceName] = SVGAnimatedString; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGAnimatedString + }); +}; + +const Impl = require("../svg/SVGAnimatedString-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGBoundingBoxOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGBoundingBoxOptions.js new file mode 100644 index 00000000..7d1b2c58 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGBoundingBoxOptions.js @@ -0,0 +1,64 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "clipped"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'clipped' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "fill"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'fill' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = true; + } + } + + { + const key = "markers"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'markers' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "stroke"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'stroke' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGElement.js new file mode 100644 index 00000000..a08e5917 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGElement.js @@ -0,0 +1,2227 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnErrorEventHandlerNonNull = require("./OnErrorEventHandlerNonNull.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Element = require("./Element.js"); + +const interfaceName = "SVGElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Element._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGElement extends globalObject.Element { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + focus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'focus' called on an object that is not a valid instance of SVGElement."); + } + + return esValue[implSymbol].focus(); + } + + blur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'blur' called on an object that is not a valid instance of SVGElement."); + } + + return esValue[implSymbol].blur(); + } + + get className() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get className' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.getSameObject(this, "className", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["className"]); + }); + } + + get ownerSVGElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ownerSVGElement' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ownerSVGElement"]); + } + + get viewportElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get viewportElement' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["viewportElement"]); + } + + get style() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get style' called on an object that is not a valid instance of SVGElement."); + } + + return utils.getSameObject(this, "style", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["style"]); + }); + } + + set style(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set style' called on an object that is not a valid instance of SVGElement."); + } + + const Q = esValue["style"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'style' is not an object"); + } + Reflect.set(Q, "cssText", V); + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onauxclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onauxclick' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onauxclick"]); + } + + set onauxclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onauxclick' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onauxclick' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onauxclick"] = V; + } + + get onblur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onblur' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onblur"]); + } + + set onblur(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onblur' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onblur' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onblur"] = V; + } + + get oncancel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncancel' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncancel"]); + } + + set oncancel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncancel' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncancel' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncancel"] = V; + } + + get oncanplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplay' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplay"]); + } + + set oncanplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplay' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplay' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncanplay"] = V; + } + + get oncanplaythrough() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplaythrough' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplaythrough"]); + } + + set oncanplaythrough(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplaythrough' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplaythrough' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncanplaythrough"] = V; + } + + get onchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onchange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onchange"]); + } + + set onchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onchange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onchange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onchange"] = V; + } + + get onclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclick' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclick"]); + } + + set onclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclick' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclick' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onclick"] = V; + } + + get onclose() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclose' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclose"]); + } + + set onclose(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclose' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclose' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onclose"] = V; + } + + get oncontextmenu() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncontextmenu' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncontextmenu"]); + } + + set oncontextmenu(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncontextmenu' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncontextmenu' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncontextmenu"] = V; + } + + get oncuechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncuechange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncuechange"]); + } + + set oncuechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncuechange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncuechange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncuechange"] = V; + } + + get ondblclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondblclick' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondblclick"]); + } + + set ondblclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondblclick' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondblclick' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondblclick"] = V; + } + + get ondrag() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondrag' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrag"]); + } + + set ondrag(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondrag' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrag' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondrag"] = V; + } + + get ondragend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragend"]); + } + + set ondragend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragend"] = V; + } + + get ondragenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragenter' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragenter"]); + } + + set ondragenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragenter' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragenter' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragenter"] = V; + } + + get ondragleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragleave' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragleave"]); + } + + set ondragleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragleave' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragleave' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragleave"] = V; + } + + get ondragover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragover' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragover"]); + } + + set ondragover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragover' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragover' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragover"] = V; + } + + get ondragstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragstart' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragstart"]); + } + + set ondragstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragstart' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragstart' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragstart"] = V; + } + + get ondrop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondrop' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrop"]); + } + + set ondrop(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondrop' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrop' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondrop"] = V; + } + + get ondurationchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondurationchange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondurationchange"]); + } + + set ondurationchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondurationchange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondurationchange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondurationchange"] = V; + } + + get onemptied() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onemptied' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onemptied"]); + } + + set onemptied(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onemptied' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onemptied' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onemptied"] = V; + } + + get onended() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onended' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onended"]); + } + + set onended(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onended' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onended' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onended"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnErrorEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onfocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onfocus' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onfocus"]); + } + + set onfocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onfocus' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onfocus' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onfocus"] = V; + } + + get oninput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninput' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninput"]); + } + + set oninput(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninput' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninput' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oninput"] = V; + } + + get oninvalid() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninvalid' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninvalid"]); + } + + set oninvalid(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninvalid' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninvalid' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oninvalid"] = V; + } + + get onkeydown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeydown' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeydown"]); + } + + set onkeydown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeydown' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeydown' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onkeydown"] = V; + } + + get onkeypress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeypress' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeypress"]); + } + + set onkeypress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeypress' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeypress' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onkeypress"] = V; + } + + get onkeyup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeyup' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeyup"]); + } + + set onkeyup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeyup' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeyup' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onkeyup"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onload' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onload' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get onloadeddata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadeddata' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadeddata"]); + } + + set onloadeddata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadeddata' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadeddata' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadeddata"] = V; + } + + get onloadedmetadata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadedmetadata' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadedmetadata"]); + } + + set onloadedmetadata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadedmetadata' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadedmetadata' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadedmetadata"] = V; + } + + get onloadend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]); + } + + set onloadend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadend"] = V; + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onmousedown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousedown' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousedown"]); + } + + set onmousedown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousedown' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousedown' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmousedown"] = V; + } + + get onmouseenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseenter"]); + } + + set onmouseenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseenter' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseenter"] = V; + } + + get onmouseleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseleave"]); + } + + set onmouseleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseleave' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseleave"] = V; + } + + get onmousemove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousemove' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousemove"]); + } + + set onmousemove(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousemove' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousemove' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmousemove"] = V; + } + + get onmouseout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseout' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseout"]); + } + + set onmouseout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseout' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseout' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseout"] = V; + } + + get onmouseover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseover' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseover"]); + } + + set onmouseover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseover' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseover' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseover"] = V; + } + + get onmouseup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseup' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseup"]); + } + + set onmouseup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseup' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseup' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseup"] = V; + } + + get onwheel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwheel' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwheel"]); + } + + set onwheel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwheel' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwheel' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwheel"] = V; + } + + get onpause() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpause' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpause"]); + } + + set onpause(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpause' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpause' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpause"] = V; + } + + get onplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplay' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplay"]); + } + + set onplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplay' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplay' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onplay"] = V; + } + + get onplaying() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplaying' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplaying"]); + } + + set onplaying(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplaying' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplaying' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onplaying"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onratechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onratechange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onratechange"]); + } + + set onratechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onratechange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onratechange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onratechange"] = V; + } + + get onreset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onreset' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreset"]); + } + + set onreset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onreset' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreset' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onreset"] = V; + } + + get onresize() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onresize' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onresize"]); + } + + set onresize(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onresize' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onresize' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onresize"] = V; + } + + get onscroll() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onscroll' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onscroll"]); + } + + set onscroll(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onscroll' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onscroll' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onscroll"] = V; + } + + get onsecuritypolicyviolation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsecuritypolicyviolation' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsecuritypolicyviolation"]); + } + + set onsecuritypolicyviolation(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsecuritypolicyviolation' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsecuritypolicyviolation' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onsecuritypolicyviolation"] = V; + } + + get onseeked() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeked' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeked"]); + } + + set onseeked(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeked' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeked' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onseeked"] = V; + } + + get onseeking() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeking' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeking"]); + } + + set onseeking(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeking' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeking' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onseeking"] = V; + } + + get onselect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onselect' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onselect"]); + } + + set onselect(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onselect' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onselect' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onselect"] = V; + } + + get onstalled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstalled' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstalled"]); + } + + set onstalled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstalled' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstalled' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onstalled"] = V; + } + + get onsubmit() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsubmit' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsubmit"]); + } + + set onsubmit(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsubmit' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsubmit' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onsubmit"] = V; + } + + get onsuspend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsuspend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsuspend"]); + } + + set onsuspend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsuspend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsuspend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onsuspend"] = V; + } + + get ontimeupdate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontimeupdate' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontimeupdate"]); + } + + set ontimeupdate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontimeupdate' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontimeupdate' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontimeupdate"] = V; + } + + get ontoggle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontoggle' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontoggle"]); + } + + set ontoggle(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontoggle' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontoggle' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontoggle"] = V; + } + + get onvolumechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onvolumechange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onvolumechange"]); + } + + set onvolumechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onvolumechange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onvolumechange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onvolumechange"] = V; + } + + get onwaiting() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwaiting' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwaiting"]); + } + + set onwaiting(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwaiting' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwaiting' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwaiting"] = V; + } + + get dataset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dataset' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.getSameObject(this, "dataset", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["dataset"]); + }); + } + + get nonce() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get nonce' called on an object that is not a valid instance of SVGElement."); + } + + const value = esValue[implSymbol].getAttributeNS(null, "nonce"); + return value === null ? "" : value; + } + + set nonce(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set nonce' called on an object that is not a valid instance of SVGElement."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'nonce' property on 'SVGElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol].setAttributeNS(null, "nonce", V); + } + + get tabIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tabIndex' called on an object that is not a valid instance of SVGElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["tabIndex"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set tabIndex(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set tabIndex' called on an object that is not a valid instance of SVGElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'tabIndex' property on 'SVGElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["tabIndex"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(SVGElement.prototype, { + focus: { enumerable: true }, + blur: { enumerable: true }, + className: { enumerable: true }, + ownerSVGElement: { enumerable: true }, + viewportElement: { enumerable: true }, + style: { enumerable: true }, + onabort: { enumerable: true }, + onauxclick: { enumerable: true }, + onblur: { enumerable: true }, + oncancel: { enumerable: true }, + oncanplay: { enumerable: true }, + oncanplaythrough: { enumerable: true }, + onchange: { enumerable: true }, + onclick: { enumerable: true }, + onclose: { enumerable: true }, + oncontextmenu: { enumerable: true }, + oncuechange: { enumerable: true }, + ondblclick: { enumerable: true }, + ondrag: { enumerable: true }, + ondragend: { enumerable: true }, + ondragenter: { enumerable: true }, + ondragleave: { enumerable: true }, + ondragover: { enumerable: true }, + ondragstart: { enumerable: true }, + ondrop: { enumerable: true }, + ondurationchange: { enumerable: true }, + onemptied: { enumerable: true }, + onended: { enumerable: true }, + onerror: { enumerable: true }, + onfocus: { enumerable: true }, + oninput: { enumerable: true }, + oninvalid: { enumerable: true }, + onkeydown: { enumerable: true }, + onkeypress: { enumerable: true }, + onkeyup: { enumerable: true }, + onload: { enumerable: true }, + onloadeddata: { enumerable: true }, + onloadedmetadata: { enumerable: true }, + onloadend: { enumerable: true }, + onloadstart: { enumerable: true }, + onmousedown: { enumerable: true }, + onmouseenter: { enumerable: true }, + onmouseleave: { enumerable: true }, + onmousemove: { enumerable: true }, + onmouseout: { enumerable: true }, + onmouseover: { enumerable: true }, + onmouseup: { enumerable: true }, + onwheel: { enumerable: true }, + onpause: { enumerable: true }, + onplay: { enumerable: true }, + onplaying: { enumerable: true }, + onprogress: { enumerable: true }, + onratechange: { enumerable: true }, + onreset: { enumerable: true }, + onresize: { enumerable: true }, + onscroll: { enumerable: true }, + onsecuritypolicyviolation: { enumerable: true }, + onseeked: { enumerable: true }, + onseeking: { enumerable: true }, + onselect: { enumerable: true }, + onstalled: { enumerable: true }, + onsubmit: { enumerable: true }, + onsuspend: { enumerable: true }, + ontimeupdate: { enumerable: true }, + ontoggle: { enumerable: true }, + onvolumechange: { enumerable: true }, + onwaiting: { enumerable: true }, + dataset: { enumerable: true }, + nonce: { enumerable: true }, + tabIndex: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGElement + }); +}; + +const Impl = require("../nodes/SVGElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGGraphicsElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGGraphicsElement.js new file mode 100644 index 00000000..b4495b3f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGGraphicsElement.js @@ -0,0 +1,139 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGElement = require("./SVGElement.js"); + +const interfaceName = "SVGGraphicsElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGGraphicsElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGGraphicsElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGGraphicsElement extends globalObject.SVGElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get requiredExtensions() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get requiredExtensions' called on an object that is not a valid instance of SVGGraphicsElement." + ); + } + + return utils.getSameObject(this, "requiredExtensions", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["requiredExtensions"]); + }); + } + + get systemLanguage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get systemLanguage' called on an object that is not a valid instance of SVGGraphicsElement." + ); + } + + return utils.getSameObject(this, "systemLanguage", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["systemLanguage"]); + }); + } + } + Object.defineProperties(SVGGraphicsElement.prototype, { + requiredExtensions: { enumerable: true }, + systemLanguage: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGGraphicsElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGGraphicsElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGGraphicsElement + }); +}; + +const Impl = require("../nodes/SVGGraphicsElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGNumber.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGNumber.js new file mode 100644 index 00000000..e17fe8b0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGNumber.js @@ -0,0 +1,132 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGNumber"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGNumber'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGNumber"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGNumber { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get value' called on an object that is not a valid instance of SVGNumber."); + } + + return esValue[implSymbol]["value"]; + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set value' called on an object that is not a valid instance of SVGNumber."); + } + + V = conversions["float"](V, { + context: "Failed to set the 'value' property on 'SVGNumber': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["value"] = V; + } + } + Object.defineProperties(SVGNumber.prototype, { + value: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGNumber", configurable: true } + }); + ctorRegistry[interfaceName] = SVGNumber; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGNumber + }); +}; + +const Impl = require("../svg/SVGNumber-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGSVGElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGSVGElement.js new file mode 100644 index 00000000..9fa7f5e3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGSVGElement.js @@ -0,0 +1,737 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGGraphicsElement = require("./SVGGraphicsElement.js"); + +const interfaceName = "SVGSVGElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGSVGElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGSVGElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGGraphicsElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGSVGElement extends globalObject.SVGGraphicsElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + createSVGNumber() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createSVGNumber' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createSVGNumber()); + } + + getElementById(elementId) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getElementById' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementById' on 'SVGSVGElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementById' on 'SVGSVGElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args)); + } + + suspendRedraw(maxWaitMilliseconds) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'suspendRedraw' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'suspendRedraw' on 'SVGSVGElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'suspendRedraw' on 'SVGSVGElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].suspendRedraw(...args); + } + + unsuspendRedraw(suspendHandleID) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'unsuspendRedraw' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'unsuspendRedraw' on 'SVGSVGElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'unsuspendRedraw' on 'SVGSVGElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].unsuspendRedraw(...args); + } + + unsuspendRedrawAll() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'unsuspendRedrawAll' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return esValue[implSymbol].unsuspendRedrawAll(); + } + + forceRedraw() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'forceRedraw' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return esValue[implSymbol].forceRedraw(); + } + + get onafterprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onafterprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]); + } + + set onafterprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onafterprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onafterprint' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onafterprint"] = V; + } + + get onbeforeprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]); + } + + set onbeforeprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeprint' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeprint"] = V; + } + + get onbeforeunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeunload"]); + } + + set onbeforeunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeunload' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeunload"] = V; + } + + get onhashchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onhashchange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]); + } + + set onhashchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onhashchange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onhashchange' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onhashchange"] = V; + } + + get onlanguagechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onlanguagechange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onlanguagechange"]); + } + + set onlanguagechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onlanguagechange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onlanguagechange' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onlanguagechange"] = V; + } + + get onmessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]); + } + + set onmessage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessage' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onmessage"] = V; + } + + get onmessageerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessageerror' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessageerror"]); + } + + set onmessageerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessageerror' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessageerror' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onmessageerror"] = V; + } + + get onoffline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onoffline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]); + } + + set onoffline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onoffline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onoffline' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onoffline"] = V; + } + + get ononline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ononline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]); + } + + set ononline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ononline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ononline' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["ononline"] = V; + } + + get onpagehide() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpagehide' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]); + } + + set onpagehide(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpagehide' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpagehide' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onpagehide"] = V; + } + + get onpageshow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpageshow' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]); + } + + set onpageshow(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpageshow' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpageshow' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onpageshow"] = V; + } + + get onpopstate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpopstate' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]); + } + + set onpopstate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpopstate' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpopstate' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onpopstate"] = V; + } + + get onrejectionhandled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onrejectionhandled' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onrejectionhandled"]); + } + + set onrejectionhandled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onrejectionhandled' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onrejectionhandled' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onrejectionhandled"] = V; + } + + get onstorage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstorage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]); + } + + set onstorage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstorage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstorage' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onstorage"] = V; + } + + get onunhandledrejection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunhandledrejection' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunhandledrejection"]); + } + + set onunhandledrejection(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunhandledrejection' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunhandledrejection' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onunhandledrejection"] = V; + } + + get onunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]); + } + + set onunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunload' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onunload"] = V; + } + } + Object.defineProperties(SVGSVGElement.prototype, { + createSVGNumber: { enumerable: true }, + getElementById: { enumerable: true }, + suspendRedraw: { enumerable: true }, + unsuspendRedraw: { enumerable: true }, + unsuspendRedrawAll: { enumerable: true }, + forceRedraw: { enumerable: true }, + onafterprint: { enumerable: true }, + onbeforeprint: { enumerable: true }, + onbeforeunload: { enumerable: true }, + onhashchange: { enumerable: true }, + onlanguagechange: { enumerable: true }, + onmessage: { enumerable: true }, + onmessageerror: { enumerable: true }, + onoffline: { enumerable: true }, + ononline: { enumerable: true }, + onpagehide: { enumerable: true }, + onpageshow: { enumerable: true }, + onpopstate: { enumerable: true }, + onrejectionhandled: { enumerable: true }, + onstorage: { enumerable: true }, + onunhandledrejection: { enumerable: true }, + onunload: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGSVGElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGSVGElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGSVGElement + }); +}; + +const Impl = require("../nodes/SVGSVGElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGStringList.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGStringList.js new file mode 100644 index 00000000..51f31bc4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGStringList.js @@ -0,0 +1,537 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGStringList"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGStringList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGStringList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGStringList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + clear() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'clear' called on an object that is not a valid instance of SVGStringList."); + } + + return esValue[implSymbol].clear(); + } + + initialize(newItem) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initialize' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initialize' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initialize' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].initialize(...args); + } + + getItem(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'getItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getItem(...args); + } + + insertItemBefore(newItem, index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertItemBefore' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertItemBefore' on 'SVGStringList': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertItemBefore' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'insertItemBefore' on 'SVGStringList': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].insertItemBefore(...args); + } + + replaceItem(newItem, index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'replaceItem' on 'SVGStringList': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'replaceItem' on 'SVGStringList': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].replaceItem(...args); + } + + removeItem(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'removeItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].removeItem(...args); + } + + appendItem(newItem) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'appendItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'appendItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'appendItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].appendItem(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of SVGStringList." + ); + } + + return esValue[implSymbol]["length"]; + } + + get numberOfItems() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get numberOfItems' called on an object that is not a valid instance of SVGStringList." + ); + } + + return esValue[implSymbol]["numberOfItems"]; + } + } + Object.defineProperties(SVGStringList.prototype, { + clear: { enumerable: true }, + initialize: { enumerable: true }, + getItem: { enumerable: true }, + insertItemBefore: { enumerable: true }, + replaceItem: { enumerable: true }, + removeItem: { enumerable: true }, + appendItem: { enumerable: true }, + length: { enumerable: true }, + numberOfItems: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGStringList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = SVGStringList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGStringList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].getItem(index); + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + let indexedValue = V; + + indexedValue = conversions["DOMString"](indexedValue, { + context: "Failed to set the " + index + " property on 'SVGStringList': The provided value", + globals: globalObject + }); + + const creating = !target[implSymbol][utils.supportsPropertyIndex](index); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + + return true; + } + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].getItem(index); + ownDesc = { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + if (desc.get || desc.set) { + return false; + } + + const index = P >>> 0; + let indexedValue = desc.value; + + indexedValue = conversions["DOMString"](indexedValue, { + context: "Failed to set the " + index + " property on 'SVGStringList': The provided value", + globals: globalObject + }); + + const creating = !target[implSymbol][utils.supportsPropertyIndex](index); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + + return true; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !target[implSymbol][utils.supportsPropertyIndex](index); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../svg/SVGStringList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGTitleElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGTitleElement.js new file mode 100644 index 00000000..9bb0a277 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGTitleElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGElement = require("./SVGElement.js"); + +const interfaceName = "SVGTitleElement"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'SVGTitleElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGTitleElement"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGElement._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGTitleElement extends globalObject.SVGElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGTitleElement.prototype, { + [Symbol.toStringTag]: { value: "SVGTitleElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGTitleElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGTitleElement + }); +}; + +const Impl = require("../nodes/SVGTitleElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Screen.js b/node_modules/jsdom/lib/jsdom/living/generated/Screen.js new file mode 100644 index 00000000..012cf10d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Screen.js @@ -0,0 +1,180 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Screen"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Screen'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Screen"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Screen { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get availWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get availWidth' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["availWidth"]; + } + + get availHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get availHeight' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["availHeight"]; + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get width' called on an object that is not a valid instance of Screen."); + } + + return esValue[implSymbol]["width"]; + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get height' called on an object that is not a valid instance of Screen."); + } + + return esValue[implSymbol]["height"]; + } + + get colorDepth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get colorDepth' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["colorDepth"]; + } + + get pixelDepth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pixelDepth' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["pixelDepth"]; + } + } + Object.defineProperties(Screen.prototype, { + availWidth: { enumerable: true }, + availHeight: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + colorDepth: { enumerable: true }, + pixelDepth: { enumerable: true }, + [Symbol.toStringTag]: { value: "Screen", configurable: true } + }); + ctorRegistry[interfaceName] = Screen; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Screen + }); +}; + +const Impl = require("../window/Screen-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollBehavior.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollBehavior.js new file mode 100644 index 00000000..9668f63d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollBehavior.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["auto", "instant", "smooth"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for ScrollBehavior`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollIntoViewOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollIntoViewOptions.js new file mode 100644 index 00000000..00cb221f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollIntoViewOptions.js @@ -0,0 +1,45 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ScrollLogicalPosition = require("./ScrollLogicalPosition.js"); +const ScrollOptions = require("./ScrollOptions.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + ScrollOptions._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "block"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ScrollLogicalPosition.convert(globalObject, value, { context: context + " has member 'block' that" }); + + ret[key] = value; + } else { + ret[key] = "start"; + } + } + + { + const key = "inline"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ScrollLogicalPosition.convert(globalObject, value, { context: context + " has member 'inline' that" }); + + ret[key] = value; + } else { + ret[key] = "nearest"; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollLogicalPosition.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollLogicalPosition.js new file mode 100644 index 00000000..f7e9a10a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollLogicalPosition.js @@ -0,0 +1,14 @@ +"use strict"; + +const enumerationValues = new Set(["start", "center", "end", "nearest"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError( + `${context} '${string}' is not a valid enumeration value for ScrollLogicalPosition` + ); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollOptions.js new file mode 100644 index 00000000..1bfa5f37 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollOptions.js @@ -0,0 +1,30 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ScrollBehavior = require("./ScrollBehavior.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "behavior"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ScrollBehavior.convert(globalObject, value, { context: context + " has member 'behavior' that" }); + + ret[key] = value; + } else { + ret[key] = "auto"; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollRestoration.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollRestoration.js new file mode 100644 index 00000000..1b3c19bd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollRestoration.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["auto", "manual"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for ScrollRestoration`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Selection.js b/node_modules/jsdom/lib/jsdom/living/generated/Selection.js new file mode 100644 index 00000000..fe1a4414 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Selection.js @@ -0,0 +1,569 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Range = require("./Range.js"); +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Selection"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Selection'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Selection"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Selection { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + getRangeAt(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getRangeAt' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getRangeAt' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'getRangeAt' on 'Selection': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getRangeAt(...args)); + } + + addRange(range) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'addRange' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'addRange' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Range.convert(globalObject, curArg, { + context: "Failed to execute 'addRange' on 'Selection': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].addRange(...args); + } + + removeRange(range) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeRange' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeRange' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Range.convert(globalObject, curArg, { + context: "Failed to execute 'removeRange' on 'Selection': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].removeRange(...args); + } + + removeAllRanges() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeAllRanges' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol].removeAllRanges(); + } + + empty() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'empty' called on an object that is not a valid instance of Selection."); + } + + return esValue[implSymbol].empty(); + } + + collapse(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'collapse' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'collapse' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'collapse' on 'Selection': parameter 1" + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'collapse' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].collapse(...args); + } + + setPosition(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setPosition' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setPosition' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setPosition' on 'Selection': parameter 1" + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setPosition' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].setPosition(...args); + } + + collapseToStart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'collapseToStart' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol].collapseToStart(); + } + + collapseToEnd() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'collapseToEnd' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol].collapseToEnd(); + } + + extend(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'extend' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'extend' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'extend' on 'Selection': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'extend' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].extend(...args); + } + + setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setBaseAndExtent' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 4) { + throw new globalObject.TypeError( + `Failed to execute 'setBaseAndExtent' on 'Selection': 4 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 3" + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 4", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setBaseAndExtent(...args); + } + + selectAllChildren(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'selectAllChildren' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'selectAllChildren' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'selectAllChildren' on 'Selection': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].selectAllChildren(...args); + } + + deleteFromDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteFromDocument' called on an object that is not a valid instance of Selection." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteFromDocument(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + containsNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'containsNode' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'containsNode' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'containsNode' on 'Selection': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'containsNode' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + return esValue[implSymbol].containsNode(...args); + } + + toString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of Selection."); + } + + return esValue[implSymbol].toString(); + } + + get anchorNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get anchorNode' called on an object that is not a valid instance of Selection." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["anchorNode"]); + } + + get anchorOffset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get anchorOffset' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["anchorOffset"]; + } + + get focusNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get focusNode' called on an object that is not a valid instance of Selection." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["focusNode"]); + } + + get focusOffset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get focusOffset' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["focusOffset"]; + } + + get isCollapsed() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isCollapsed' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["isCollapsed"]; + } + + get rangeCount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rangeCount' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["rangeCount"]; + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Selection."); + } + + return esValue[implSymbol]["type"]; + } + } + Object.defineProperties(Selection.prototype, { + getRangeAt: { enumerable: true }, + addRange: { enumerable: true }, + removeRange: { enumerable: true }, + removeAllRanges: { enumerable: true }, + empty: { enumerable: true }, + collapse: { enumerable: true }, + setPosition: { enumerable: true }, + collapseToStart: { enumerable: true }, + collapseToEnd: { enumerable: true }, + extend: { enumerable: true }, + setBaseAndExtent: { enumerable: true }, + selectAllChildren: { enumerable: true }, + deleteFromDocument: { enumerable: true }, + containsNode: { enumerable: true }, + toString: { enumerable: true }, + anchorNode: { enumerable: true }, + anchorOffset: { enumerable: true }, + focusNode: { enumerable: true }, + focusOffset: { enumerable: true }, + isCollapsed: { enumerable: true }, + rangeCount: { enumerable: true }, + type: { enumerable: true }, + [Symbol.toStringTag]: { value: "Selection", configurable: true } + }); + ctorRegistry[interfaceName] = Selection; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Selection + }); +}; + +const Impl = require("../selection/Selection-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SelectionMode.js b/node_modules/jsdom/lib/jsdom/living/generated/SelectionMode.js new file mode 100644 index 00000000..dc807c74 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SelectionMode.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["select", "start", "end", "preserve"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for SelectionMode`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ShadowRoot.js b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRoot.js new file mode 100644 index 00000000..b72aef49 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRoot.js @@ -0,0 +1,187 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const DocumentFragment = require("./DocumentFragment.js"); + +const interfaceName = "ShadowRoot"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'ShadowRoot'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ShadowRoot"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + DocumentFragment._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ShadowRoot extends globalObject.DocumentFragment { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get mode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get mode' called on an object that is not a valid instance of ShadowRoot."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["mode"]); + } + + get host() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of ShadowRoot."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["host"]); + } + + get innerHTML() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get innerHTML' called on an object that is not a valid instance of ShadowRoot." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["innerHTML"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set innerHTML(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set innerHTML' called on an object that is not a valid instance of ShadowRoot." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'innerHTML' property on 'ShadowRoot': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["innerHTML"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get activeElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get activeElement' called on an object that is not a valid instance of ShadowRoot." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["activeElement"]); + } + } + Object.defineProperties(ShadowRoot.prototype, { + mode: { enumerable: true }, + host: { enumerable: true }, + innerHTML: { enumerable: true }, + activeElement: { enumerable: true }, + [Symbol.toStringTag]: { value: "ShadowRoot", configurable: true } + }); + ctorRegistry[interfaceName] = ShadowRoot; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ShadowRoot + }); +}; + +const Impl = require("../nodes/ShadowRoot-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootInit.js b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootInit.js new file mode 100644 index 00000000..66021476 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootInit.js @@ -0,0 +1,30 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ShadowRootMode = require("./ShadowRootMode.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "mode"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ShadowRootMode.convert(globalObject, value, { context: context + " has member 'mode' that" }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("mode is required in 'ShadowRootInit'"); + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootMode.js b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootMode.js new file mode 100644 index 00000000..37607134 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootMode.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["open", "closed"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for ShadowRootMode`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StaticRange.js b/node_modules/jsdom/lib/jsdom/living/generated/StaticRange.js new file mode 100644 index 00000000..f2ab1822 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StaticRange.js @@ -0,0 +1,123 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const StaticRangeInit = require("./StaticRangeInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const AbstractRange = require("./AbstractRange.js"); + +const interfaceName = "StaticRange"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'StaticRange'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["StaticRange"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + AbstractRange._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class StaticRange extends globalObject.AbstractRange { + constructor(init) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'StaticRange': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = StaticRangeInit.convert(globalObject, curArg, { + context: "Failed to construct 'StaticRange': parameter 1" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + } + Object.defineProperties(StaticRange.prototype, { + [Symbol.toStringTag]: { value: "StaticRange", configurable: true } + }); + ctorRegistry[interfaceName] = StaticRange; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StaticRange + }); +}; + +const Impl = require("../range/StaticRange-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StaticRangeInit.js b/node_modules/jsdom/lib/jsdom/living/generated/StaticRangeInit.js new file mode 100644 index 00000000..0be22119 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StaticRangeInit.js @@ -0,0 +1,72 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "endContainer"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = Node.convert(globalObject, value, { context: context + " has member 'endContainer' that" }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("endContainer is required in 'StaticRangeInit'"); + } + } + + { + const key = "endOffset"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'endOffset' that", + globals: globalObject + }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("endOffset is required in 'StaticRangeInit'"); + } + } + + { + const key = "startContainer"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = Node.convert(globalObject, value, { context: context + " has member 'startContainer' that" }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("startContainer is required in 'StaticRangeInit'"); + } + } + + { + const key = "startOffset"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'startOffset' that", + globals: globalObject + }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("startOffset is required in 'StaticRangeInit'"); + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Storage.js b/node_modules/jsdom/lib/jsdom/living/generated/Storage.js new file mode 100644 index 00000000..05c76eaf --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Storage.js @@ -0,0 +1,423 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Storage"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Storage'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Storage"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Storage { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + key(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'key' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'key' on 'Storage': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'key' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].key(...args); + } + + getItem(key) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getItem' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getItem' on 'Storage': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getItem' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getItem(...args); + } + + setItem(key, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setItem' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setItem' on 'Storage': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setItem' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setItem' on 'Storage': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setItem(...args); + } + + removeItem(key) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'removeItem' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeItem' on 'Storage': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeItem' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].removeItem(...args); + } + + clear() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'clear' called on an object that is not a valid instance of Storage."); + } + + return esValue[implSymbol].clear(); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of Storage."); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(Storage.prototype, { + key: { enumerable: true }, + getItem: { enumerable: true }, + setItem: { enumerable: true }, + removeItem: { enumerable: true }, + clear: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "Storage", configurable: true } + }); + ctorRegistry[interfaceName] = Storage; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Storage + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + const namedValue = target[implSymbol].getItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (typeof P === "string") { + let namedValue = V; + + namedValue = conversions["DOMString"](namedValue, { + context: "Failed to set the '" + P + "' property on 'Storage': The provided value", + globals: globalObject + }); + + target[implSymbol].setItem(P, namedValue); + + return true; + } + } + let ownDesc; + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + if (!utils.hasOwn(target, P)) { + if (desc.get || desc.set) { + return false; + } + + let namedValue = desc.value; + + namedValue = conversions["DOMString"](namedValue, { + context: "Failed to set the '" + P + "' property on 'Storage': The provided value", + globals: globalObject + }); + + target[implSymbol].setItem(P, namedValue); + + return true; + } + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (target[implSymbol].getItem(P) !== null && !(P in target)) { + target[implSymbol].removeItem(P); + return true; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../webstorage/Storage-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StorageEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/StorageEvent.js new file mode 100644 index 00000000..b3f66c19 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StorageEvent.js @@ -0,0 +1,318 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const StorageEventInit = require("./StorageEventInit.js"); +const Storage = require("./Storage.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "StorageEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'StorageEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["StorageEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class StorageEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'StorageEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'StorageEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = StorageEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'StorageEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initStorageEvent(type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initStorageEvent' called on an object that is not a valid instance of StorageEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initStorageEvent' on 'StorageEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 4", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 5", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[5]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 6", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[6]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 7", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + { + let curArg = arguments[7]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = Storage.convert(globalObject, curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 8" + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].initStorageEvent(...args); + } + + get key() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get key' called on an object that is not a valid instance of StorageEvent."); + } + + return esValue[implSymbol]["key"]; + } + + get oldValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oldValue' called on an object that is not a valid instance of StorageEvent." + ); + } + + return esValue[implSymbol]["oldValue"]; + } + + get newValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get newValue' called on an object that is not a valid instance of StorageEvent." + ); + } + + return esValue[implSymbol]["newValue"]; + } + + get url() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get url' called on an object that is not a valid instance of StorageEvent."); + } + + return esValue[implSymbol]["url"]; + } + + get storageArea() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get storageArea' called on an object that is not a valid instance of StorageEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["storageArea"]); + } + } + Object.defineProperties(StorageEvent.prototype, { + initStorageEvent: { enumerable: true }, + key: { enumerable: true }, + oldValue: { enumerable: true }, + newValue: { enumerable: true }, + url: { enumerable: true }, + storageArea: { enumerable: true }, + [Symbol.toStringTag]: { value: "StorageEvent", configurable: true } + }); + ctorRegistry[interfaceName] = StorageEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StorageEvent + }); +}; + +const Impl = require("../events/StorageEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StorageEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/StorageEventInit.js new file mode 100644 index 00000000..c51c7127 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StorageEventInit.js @@ -0,0 +1,99 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Storage = require("./Storage.js"); +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "key"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { context: context + " has member 'key' that", globals: globalObject }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "newValue"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { + context: context + " has member 'newValue' that", + globals: globalObject + }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "oldValue"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { + context: context + " has member 'oldValue' that", + globals: globalObject + }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "storageArea"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = Storage.convert(globalObject, value, { context: context + " has member 'storageArea' that" }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "url"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { context: context + " has member 'url' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StyleSheetList.js b/node_modules/jsdom/lib/jsdom/living/generated/StyleSheetList.js new file mode 100644 index 00000000..874afda1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StyleSheetList.js @@ -0,0 +1,326 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "StyleSheetList"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'StyleSheetList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["StyleSheetList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class StyleSheetList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of StyleSheetList."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'StyleSheetList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'StyleSheetList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of StyleSheetList." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(StyleSheetList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "StyleSheetList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = StyleSheetList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StyleSheetList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../cssom/StyleSheetList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SupportedType.js b/node_modules/jsdom/lib/jsdom/living/generated/SupportedType.js new file mode 100644 index 00000000..f64ae10d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SupportedType.js @@ -0,0 +1,18 @@ +"use strict"; + +const enumerationValues = new Set([ + "text/html", + "text/xml", + "application/xml", + "application/xhtml+xml", + "image/svg+xml" +]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for SupportedType`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Text.js b/node_modules/jsdom/lib/jsdom/living/generated/Text.js new file mode 100644 index 00000000..8f739be1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Text.js @@ -0,0 +1,170 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const CharacterData = require("./CharacterData.js"); + +const interfaceName = "Text"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'Text'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Text"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + CharacterData._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Text extends globalObject.CharacterData { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'Text': parameter 1", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + splitText(offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'splitText' called on an object that is not a valid instance of Text."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'splitText' on 'Text': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'splitText' on 'Text': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].splitText(...args)); + } + + get wholeText() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get wholeText' called on an object that is not a valid instance of Text."); + } + + return esValue[implSymbol]["wholeText"]; + } + + get assignedSlot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get assignedSlot' called on an object that is not a valid instance of Text." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["assignedSlot"]); + } + } + Object.defineProperties(Text.prototype, { + splitText: { enumerable: true }, + wholeText: { enumerable: true }, + assignedSlot: { enumerable: true }, + [Symbol.toStringTag]: { value: "Text", configurable: true } + }); + ctorRegistry[interfaceName] = Text; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Text + }); +}; + +const Impl = require("../nodes/Text-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TextTrackKind.js b/node_modules/jsdom/lib/jsdom/living/generated/TextTrackKind.js new file mode 100644 index 00000000..5ad709a7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TextTrackKind.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["subtitles", "captions", "descriptions", "chapters", "metadata"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for TextTrackKind`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js new file mode 100644 index 00000000..f6606c91 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js @@ -0,0 +1,222 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const TouchEventInit = require("./TouchEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "TouchEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'TouchEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["TouchEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class TouchEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'TouchEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'TouchEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = TouchEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'TouchEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get touches() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get touches' called on an object that is not a valid instance of TouchEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["touches"]); + } + + get targetTouches() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get targetTouches' called on an object that is not a valid instance of TouchEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["targetTouches"]); + } + + get changedTouches() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get changedTouches' called on an object that is not a valid instance of TouchEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["changedTouches"]); + } + + get altKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get altKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["altKey"]; + } + + get metaKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get metaKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["metaKey"]; + } + + get ctrlKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ctrlKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["ctrlKey"]; + } + + get shiftKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shiftKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["shiftKey"]; + } + } + Object.defineProperties(TouchEvent.prototype, { + touches: { enumerable: true }, + targetTouches: { enumerable: true }, + changedTouches: { enumerable: true }, + altKey: { enumerable: true }, + metaKey: { enumerable: true }, + ctrlKey: { enumerable: true }, + shiftKey: { enumerable: true }, + [Symbol.toStringTag]: { value: "TouchEvent", configurable: true } + }); + ctorRegistry[interfaceName] = TouchEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: TouchEvent + }); +}; + +const Impl = require("../events/TouchEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TouchEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/TouchEventInit.js new file mode 100644 index 00000000..7a472776 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TouchEventInit.js @@ -0,0 +1,89 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventModifierInit = require("./EventModifierInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventModifierInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "changedTouches"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'changedTouches' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "targetTouches"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'targetTouches' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "touches"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'touches' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TreeWalker.js b/node_modules/jsdom/lib/jsdom/living/generated/TreeWalker.js new file mode 100644 index 00000000..b525271b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TreeWalker.js @@ -0,0 +1,255 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "TreeWalker"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'TreeWalker'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["TreeWalker"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class TreeWalker { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + parentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'parentNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].parentNode()); + } + + firstChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'firstChild' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].firstChild()); + } + + lastChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'lastChild' called on an object that is not a valid instance of TreeWalker."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].lastChild()); + } + + previousSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'previousSibling' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].previousSibling()); + } + + nextSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'nextSibling' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].nextSibling()); + } + + previousNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'previousNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].previousNode()); + } + + nextNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'nextNode' called on an object that is not a valid instance of TreeWalker."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].nextNode()); + } + + get root() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get root' called on an object that is not a valid instance of TreeWalker."); + } + + return utils.getSameObject(this, "root", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["root"]); + }); + } + + get whatToShow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get whatToShow' called on an object that is not a valid instance of TreeWalker." + ); + } + + return esValue[implSymbol]["whatToShow"]; + } + + get filter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get filter' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["filter"]); + } + + get currentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["currentNode"]); + } + + set currentNode(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set currentNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + V = Node.convert(globalObject, V, { + context: "Failed to set the 'currentNode' property on 'TreeWalker': The provided value" + }); + + esValue[implSymbol]["currentNode"] = V; + } + } + Object.defineProperties(TreeWalker.prototype, { + parentNode: { enumerable: true }, + firstChild: { enumerable: true }, + lastChild: { enumerable: true }, + previousSibling: { enumerable: true }, + nextSibling: { enumerable: true }, + previousNode: { enumerable: true }, + nextNode: { enumerable: true }, + root: { enumerable: true }, + whatToShow: { enumerable: true }, + filter: { enumerable: true }, + currentNode: { enumerable: true }, + [Symbol.toStringTag]: { value: "TreeWalker", configurable: true } + }); + ctorRegistry[interfaceName] = TreeWalker; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: TreeWalker + }); +}; + +const Impl = require("../traversal/TreeWalker-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js new file mode 100644 index 00000000..9929da30 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js @@ -0,0 +1,235 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const UIEventInit = require("./UIEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "UIEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'UIEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["UIEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class UIEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'UIEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'UIEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = UIEventInit.convert(globalObject, curArg, { context: "Failed to construct 'UIEvent': parameter 2" }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initUIEvent(typeArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'initUIEvent' called on an object that is not a valid instance of UIEvent."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initUIEvent' on 'UIEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 5", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].initUIEvent(...args); + } + + get view() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get view' called on an object that is not a valid instance of UIEvent."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["view"]); + } + + get detail() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get detail' called on an object that is not a valid instance of UIEvent."); + } + + return esValue[implSymbol]["detail"]; + } + + get which() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get which' called on an object that is not a valid instance of UIEvent."); + } + + return esValue[implSymbol]["which"]; + } + } + Object.defineProperties(UIEvent.prototype, { + initUIEvent: { enumerable: true }, + view: { enumerable: true }, + detail: { enumerable: true }, + which: { enumerable: true }, + [Symbol.toStringTag]: { value: "UIEvent", configurable: true } + }); + ctorRegistry[interfaceName] = UIEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: UIEvent + }); +}; + +const Impl = require("../events/UIEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js new file mode 100644 index 00000000..3051b230 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js @@ -0,0 +1,62 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "detail"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'detail' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "view"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = utils.tryImplForWrapper(value); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "which"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'which' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ValidityState.js b/node_modules/jsdom/lib/jsdom/living/generated/ValidityState.js new file mode 100644 index 00000000..5c2e4384 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ValidityState.js @@ -0,0 +1,249 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "ValidityState"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'ValidityState'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ValidityState"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ValidityState { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get valueMissing() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valueMissing' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["valueMissing"]; + } + + get typeMismatch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get typeMismatch' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["typeMismatch"]; + } + + get patternMismatch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get patternMismatch' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["patternMismatch"]; + } + + get tooLong() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tooLong' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["tooLong"]; + } + + get tooShort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tooShort' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["tooShort"]; + } + + get rangeUnderflow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rangeUnderflow' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["rangeUnderflow"]; + } + + get rangeOverflow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rangeOverflow' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["rangeOverflow"]; + } + + get stepMismatch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get stepMismatch' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["stepMismatch"]; + } + + get badInput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get badInput' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["badInput"]; + } + + get customError() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get customError' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["customError"]; + } + + get valid() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valid' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["valid"]; + } + } + Object.defineProperties(ValidityState.prototype, { + valueMissing: { enumerable: true }, + typeMismatch: { enumerable: true }, + patternMismatch: { enumerable: true }, + tooLong: { enumerable: true }, + tooShort: { enumerable: true }, + rangeUnderflow: { enumerable: true }, + rangeOverflow: { enumerable: true }, + stepMismatch: { enumerable: true }, + badInput: { enumerable: true }, + customError: { enumerable: true }, + valid: { enumerable: true }, + [Symbol.toStringTag]: { value: "ValidityState", configurable: true } + }); + ctorRegistry[interfaceName] = ValidityState; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ValidityState + }); +}; + +const Impl = require("../constraint-validation/ValidityState-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/VisibilityState.js b/node_modules/jsdom/lib/jsdom/living/generated/VisibilityState.js new file mode 100644 index 00000000..798eb094 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/VisibilityState.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["hidden", "visible", "prerender"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for VisibilityState`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/VoidFunction.js b/node_modules/jsdom/lib/jsdom/living/generated/VoidFunction.js new file mode 100644 index 00000000..9a00672a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/VoidFunction.js @@ -0,0 +1,26 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (typeof value !== "function") { + throw new globalObject.TypeError(context + " is not a function"); + } + + function invokeTheCallbackFunction() { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + callResult = Reflect.apply(value, thisArg, []); + } + + invokeTheCallbackFunction.construct = () => { + let callResult = Reflect.construct(value, []); + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/WebSocket.js b/node_modules/jsdom/lib/jsdom/living/generated/WebSocket.js new file mode 100644 index 00000000..eac6d157 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/WebSocket.js @@ -0,0 +1,476 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Blob = require("./Blob.js"); +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const BinaryType = require("./BinaryType.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "WebSocket"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'WebSocket'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["WebSocket"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class WebSocket extends globalObject.EventTarget { + constructor(url) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'WebSocket': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to construct 'WebSocket': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + if (utils.isObject(curArg)) { + if (curArg[Symbol.iterator] !== undefined) { + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError( + "Failed to construct 'WebSocket': parameter 2" + " sequence" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions["DOMString"](nextItem, { + context: "Failed to construct 'WebSocket': parameter 2" + " sequence" + "'s element", + globals: globalObject + }); + + V.push(nextItem); + } + curArg = V; + } + } else { + } + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'WebSocket': parameter 2", + globals: globalObject + }); + } + } else { + curArg = []; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + close() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'close' called on an object that is not a valid instance of WebSocket."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["unsigned short"](curArg, { + context: "Failed to execute 'close' on 'WebSocket': parameter 1", + globals: globalObject, + clamp: true + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'close' on 'WebSocket': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].close(...args); + } + + send(data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'send' called on an object that is not a valid instance of WebSocket."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'send' on 'WebSocket': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (Blob.is(curArg)) { + { + let curArg = arguments[0]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1" + }); + args.push(curArg); + } + } else if (utils.isArrayBuffer(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions["ArrayBuffer"](curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + } else if (ArrayBuffer.isView(curArg)) { + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + } else { + throw new globalObject.TypeError( + "Failed to execute 'send' on 'WebSocket': parameter 1" + " is not of any supported type." + ); + } + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + } + } + return esValue[implSymbol].send(...args); + } + + get url() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get url' called on an object that is not a valid instance of WebSocket."); + } + + return esValue[implSymbol]["url"]; + } + + get readyState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readyState' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["readyState"]; + } + + get bufferedAmount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bufferedAmount' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["bufferedAmount"]; + } + + get onopen() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onopen' called on an object that is not a valid instance of WebSocket."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onopen"]); + } + + set onopen(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onopen' called on an object that is not a valid instance of WebSocket."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onopen' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onopen"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of WebSocket." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onclose() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclose' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclose"]); + } + + set onclose(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclose' called on an object that is not a valid instance of WebSocket." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclose' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onclose"] = V; + } + + get extensions() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get extensions' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["extensions"]; + } + + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get protocol' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["protocol"]; + } + + get onmessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessage' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]); + } + + set onmessage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessage' called on an object that is not a valid instance of WebSocket." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessage' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onmessage"] = V; + } + + get binaryType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get binaryType' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["binaryType"]); + } + + set binaryType(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set binaryType' called on an object that is not a valid instance of WebSocket." + ); + } + + V = `${V}`; + if (!BinaryType.enumerationValues.has(V)) { + return; + } + + esValue[implSymbol]["binaryType"] = V; + } + } + Object.defineProperties(WebSocket.prototype, { + close: { enumerable: true }, + send: { enumerable: true }, + url: { enumerable: true }, + readyState: { enumerable: true }, + bufferedAmount: { enumerable: true }, + onopen: { enumerable: true }, + onerror: { enumerable: true }, + onclose: { enumerable: true }, + extensions: { enumerable: true }, + protocol: { enumerable: true }, + onmessage: { enumerable: true }, + binaryType: { enumerable: true }, + [Symbol.toStringTag]: { value: "WebSocket", configurable: true }, + CONNECTING: { value: 0, enumerable: true }, + OPEN: { value: 1, enumerable: true }, + CLOSING: { value: 2, enumerable: true }, + CLOSED: { value: 3, enumerable: true } + }); + Object.defineProperties(WebSocket, { + CONNECTING: { value: 0, enumerable: true }, + OPEN: { value: 1, enumerable: true }, + CLOSING: { value: 2, enumerable: true }, + CLOSED: { value: 3, enumerable: true } + }); + ctorRegistry[interfaceName] = WebSocket; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: WebSocket + }); +}; + +const Impl = require("../websockets/WebSocket-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/WheelEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/WheelEvent.js new file mode 100644 index 00000000..f0c858ee --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/WheelEvent.js @@ -0,0 +1,191 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const WheelEventInit = require("./WheelEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const MouseEvent = require("./MouseEvent.js"); + +const interfaceName = "WheelEvent"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'WheelEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["WheelEvent"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + MouseEvent._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class WheelEvent extends globalObject.MouseEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'WheelEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'WheelEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = WheelEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'WheelEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get deltaX() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaX' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaX"]; + } + + get deltaY() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaY' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaY"]; + } + + get deltaZ() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaZ' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaZ"]; + } + + get deltaMode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaMode' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaMode"]; + } + } + Object.defineProperties(WheelEvent.prototype, { + deltaX: { enumerable: true }, + deltaY: { enumerable: true }, + deltaZ: { enumerable: true }, + deltaMode: { enumerable: true }, + [Symbol.toStringTag]: { value: "WheelEvent", configurable: true }, + DOM_DELTA_PIXEL: { value: 0x00, enumerable: true }, + DOM_DELTA_LINE: { value: 0x01, enumerable: true }, + DOM_DELTA_PAGE: { value: 0x02, enumerable: true } + }); + Object.defineProperties(WheelEvent, { + DOM_DELTA_PIXEL: { value: 0x00, enumerable: true }, + DOM_DELTA_LINE: { value: 0x01, enumerable: true }, + DOM_DELTA_PAGE: { value: 0x02, enumerable: true } + }); + ctorRegistry[interfaceName] = WheelEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: WheelEvent + }); +}; + +const Impl = require("../events/WheelEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/WheelEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/WheelEventInit.js new file mode 100644 index 00000000..757f81c3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/WheelEventInit.js @@ -0,0 +1,71 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const MouseEventInit = require("./MouseEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + MouseEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "deltaMode"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'deltaMode' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "deltaX"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'deltaX' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } + + { + const key = "deltaY"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'deltaY' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } + + { + const key = "deltaZ"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'deltaZ' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLDocument.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLDocument.js new file mode 100644 index 00000000..f43fadbf --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLDocument.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Document = require("./Document.js"); + +const interfaceName = "XMLDocument"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'XMLDocument'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLDocument"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Document._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLDocument extends globalObject.Document { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(XMLDocument.prototype, { + [Symbol.toStringTag]: { value: "XMLDocument", configurable: true } + }); + ctorRegistry[interfaceName] = XMLDocument; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLDocument + }); +}; + +const Impl = require("../nodes/XMLDocument-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js new file mode 100644 index 00000000..9e99ad15 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js @@ -0,0 +1,655 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Document = require("./Document.js"); +const Blob = require("./Blob.js"); +const FormData = require("./FormData.js"); +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const XMLHttpRequestResponseType = require("./XMLHttpRequestResponseType.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const XMLHttpRequestEventTarget = require("./XMLHttpRequestEventTarget.js"); + +const interfaceName = "XMLHttpRequest"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'XMLHttpRequest'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLHttpRequest"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + XMLHttpRequestEventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLHttpRequest extends globalObject.XMLHttpRequestEventTarget { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + open(method, url) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'open' called on an object that is not a valid instance of XMLHttpRequest."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + switch (arguments.length) { + case 2: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + break; + case 3: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + break; + case 4: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 4", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 4", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 5", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + } + return esValue[implSymbol].open(...args); + } + + setRequestHeader(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setRequestHeader' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setRequestHeader(...args); + } + + send() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'send' called on an object that is not a valid instance of XMLHttpRequest."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (Document.is(curArg) || Blob.is(curArg) || FormData.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'send' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + } + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].send(...args); + } + + abort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'abort' called on an object that is not a valid instance of XMLHttpRequest."); + } + + return esValue[implSymbol].abort(); + } + + getResponseHeader(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getResponseHeader' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getResponseHeader' on 'XMLHttpRequest': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'getResponseHeader' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getResponseHeader(...args); + } + + getAllResponseHeaders() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getAllResponseHeaders' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol].getAllResponseHeaders(); + } + + overrideMimeType(mime) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'overrideMimeType' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'overrideMimeType' on 'XMLHttpRequest': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'overrideMimeType' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].overrideMimeType(...args); + } + + get onreadystatechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onreadystatechange' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreadystatechange"]); + } + + set onreadystatechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onreadystatechange' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreadystatechange' property on 'XMLHttpRequest': The provided value" + }); + } + esValue[implSymbol]["onreadystatechange"] = V; + } + + get readyState() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get readyState' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["readyState"]; + } + + get timeout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get timeout' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["timeout"]; + } + + set timeout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set timeout' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'timeout' property on 'XMLHttpRequest': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["timeout"] = V; + } + + get withCredentials() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get withCredentials' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["withCredentials"]; + } + + set withCredentials(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set withCredentials' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'withCredentials' property on 'XMLHttpRequest': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["withCredentials"] = V; + } + + get upload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get upload' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.getSameObject(this, "upload", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["upload"]); + }); + } + + get responseURL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseURL' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["responseURL"]; + } + + get status() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get status' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["status"]; + } + + get statusText() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get statusText' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["statusText"]; + } + + get responseType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseType' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["responseType"]); + } + + set responseType(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set responseType' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + V = `${V}`; + if (!XMLHttpRequestResponseType.enumerationValues.has(V)) { + return; + } + + esValue[implSymbol]["responseType"] = V; + } + + get response() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get response' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["response"]; + } + + get responseText() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseText' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["responseText"]; + } + + get responseXML() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseXML' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["responseXML"]); + } + } + Object.defineProperties(XMLHttpRequest.prototype, { + open: { enumerable: true }, + setRequestHeader: { enumerable: true }, + send: { enumerable: true }, + abort: { enumerable: true }, + getResponseHeader: { enumerable: true }, + getAllResponseHeaders: { enumerable: true }, + overrideMimeType: { enumerable: true }, + onreadystatechange: { enumerable: true }, + readyState: { enumerable: true }, + timeout: { enumerable: true }, + withCredentials: { enumerable: true }, + upload: { enumerable: true }, + responseURL: { enumerable: true }, + status: { enumerable: true }, + statusText: { enumerable: true }, + responseType: { enumerable: true }, + response: { enumerable: true }, + responseText: { enumerable: true }, + responseXML: { enumerable: true }, + [Symbol.toStringTag]: { value: "XMLHttpRequest", configurable: true }, + UNSENT: { value: 0, enumerable: true }, + OPENED: { value: 1, enumerable: true }, + HEADERS_RECEIVED: { value: 2, enumerable: true }, + LOADING: { value: 3, enumerable: true }, + DONE: { value: 4, enumerable: true } + }); + Object.defineProperties(XMLHttpRequest, { + UNSENT: { value: 0, enumerable: true }, + OPENED: { value: 1, enumerable: true }, + HEADERS_RECEIVED: { value: 2, enumerable: true }, + LOADING: { value: 3, enumerable: true }, + DONE: { value: 4, enumerable: true } + }); + ctorRegistry[interfaceName] = XMLHttpRequest; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLHttpRequest + }); +}; + +const Impl = require("../xhr/XMLHttpRequest-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestEventTarget.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestEventTarget.js new file mode 100644 index 00000000..8d7fb6a8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestEventTarget.js @@ -0,0 +1,334 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "XMLHttpRequestEventTarget"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'XMLHttpRequestEventTarget'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLHttpRequestEventTarget"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLHttpRequestEventTarget extends globalObject.EventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onload' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onload' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get ontimeout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontimeout' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontimeout"]); + } + + set ontimeout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontimeout' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontimeout' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["ontimeout"] = V; + } + + get onloadend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadend' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]); + } + + set onloadend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadend' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadend' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onloadend"] = V; + } + } + Object.defineProperties(XMLHttpRequestEventTarget.prototype, { + onloadstart: { enumerable: true }, + onprogress: { enumerable: true }, + onabort: { enumerable: true }, + onerror: { enumerable: true }, + onload: { enumerable: true }, + ontimeout: { enumerable: true }, + onloadend: { enumerable: true }, + [Symbol.toStringTag]: { value: "XMLHttpRequestEventTarget", configurable: true } + }); + ctorRegistry[interfaceName] = XMLHttpRequestEventTarget; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLHttpRequestEventTarget + }); +}; + +const Impl = require("../xhr/XMLHttpRequestEventTarget-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestResponseType.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestResponseType.js new file mode 100644 index 00000000..96a958fa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestResponseType.js @@ -0,0 +1,14 @@ +"use strict"; + +const enumerationValues = new Set(["", "arraybuffer", "blob", "document", "json", "text"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError( + `${context} '${string}' is not a valid enumeration value for XMLHttpRequestResponseType` + ); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestUpload.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestUpload.js new file mode 100644 index 00000000..0ed7caf1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestUpload.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const XMLHttpRequestEventTarget = require("./XMLHttpRequestEventTarget.js"); + +const interfaceName = "XMLHttpRequestUpload"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'XMLHttpRequestUpload'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLHttpRequestUpload"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => { + XMLHttpRequestEventTarget._internalSetup(wrapper, globalObject); +}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLHttpRequestUpload extends globalObject.XMLHttpRequestEventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(XMLHttpRequestUpload.prototype, { + [Symbol.toStringTag]: { value: "XMLHttpRequestUpload", configurable: true } + }); + ctorRegistry[interfaceName] = XMLHttpRequestUpload; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLHttpRequestUpload + }); +}; + +const Impl = require("../xhr/XMLHttpRequestUpload-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLSerializer.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLSerializer.js new file mode 100644 index 00000000..2675c5e2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLSerializer.js @@ -0,0 +1,132 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "XMLSerializer"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new globalObject.TypeError(`${context} is not of type 'XMLSerializer'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLSerializer"].prototype; + } + + return Object.create(proto); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLSerializer { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + serializeToString(root) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'serializeToString' called on an object that is not a valid instance of XMLSerializer." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'serializeToString' on 'XMLSerializer': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'serializeToString' on 'XMLSerializer': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].serializeToString(...args); + } + } + Object.defineProperties(XMLSerializer.prototype, { + serializeToString: { enumerable: true }, + [Symbol.toStringTag]: { value: "XMLSerializer", configurable: true } + }); + ctorRegistry[interfaceName] = XMLSerializer; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLSerializer + }); +}; + +const Impl = require("../domparsing/XMLSerializer-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/utils.js b/node_modules/jsdom/lib/jsdom/living/generated/utils.js new file mode 100644 index 00000000..3af17706 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/utils.js @@ -0,0 +1,190 @@ +"use strict"; + +// Returns "Type(value) is Object" in ES terminology. +function isObject(value) { + return (typeof value === "object" && value !== null) || typeof value === "function"; +} + +const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty); + +// Like `Object.assign`, but using `[[GetOwnProperty]]` and `[[DefineOwnProperty]]` +// instead of `[[Get]]` and `[[Set]]` and only allowing objects +function define(target, source) { + for (const key of Reflect.ownKeys(source)) { + const descriptor = Reflect.getOwnPropertyDescriptor(source, key); + if (descriptor && !Reflect.defineProperty(target, key, descriptor)) { + throw new TypeError(`Cannot redefine property: ${String(key)}`); + } + } +} + +function newObjectInRealm(globalObject, object) { + const ctorRegistry = initCtorRegistry(globalObject); + return Object.defineProperties( + Object.create(ctorRegistry["%Object.prototype%"]), + Object.getOwnPropertyDescriptors(object) + ); +} + +const wrapperSymbol = Symbol("wrapper"); +const implSymbol = Symbol("impl"); +const sameObjectCaches = Symbol("SameObject caches"); +const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry"); + +const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype); + +function initCtorRegistry(globalObject) { + if (hasOwn(globalObject, ctorRegistrySymbol)) { + return globalObject[ctorRegistrySymbol]; + } + + const ctorRegistry = Object.create(null); + + // In addition to registering all the WebIDL2JS-generated types in the constructor registry, + // we also register a few intrinsics that we make use of in generated code, since they are not + // easy to grab from the globalObject variable. + ctorRegistry["%Object.prototype%"] = globalObject.Object.prototype; + ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf( + Object.getPrototypeOf(new globalObject.Array()[Symbol.iterator]()) + ); + + try { + ctorRegistry["%AsyncIteratorPrototype%"] = Object.getPrototypeOf( + Object.getPrototypeOf( + globalObject.eval("(async function* () {})").prototype + ) + ); + } catch { + ctorRegistry["%AsyncIteratorPrototype%"] = AsyncIteratorPrototype; + } + + globalObject[ctorRegistrySymbol] = ctorRegistry; + return ctorRegistry; +} + +function getSameObject(wrapper, prop, creator) { + if (!wrapper[sameObjectCaches]) { + wrapper[sameObjectCaches] = Object.create(null); + } + + if (prop in wrapper[sameObjectCaches]) { + return wrapper[sameObjectCaches][prop]; + } + + wrapper[sameObjectCaches][prop] = creator(); + return wrapper[sameObjectCaches][prop]; +} + +function wrapperForImpl(impl) { + return impl ? impl[wrapperSymbol] : null; +} + +function implForWrapper(wrapper) { + return wrapper ? wrapper[implSymbol] : null; +} + +function tryWrapperForImpl(impl) { + const wrapper = wrapperForImpl(impl); + return wrapper ? wrapper : impl; +} + +function tryImplForWrapper(wrapper) { + const impl = implForWrapper(wrapper); + return impl ? impl : wrapper; +} + +const iterInternalSymbol = Symbol("internal"); + +function isArrayIndexPropName(P) { + if (typeof P !== "string") { + return false; + } + const i = P >>> 0; + if (i === 2 ** 32 - 1) { + return false; + } + const s = `${i}`; + if (P !== s) { + return false; + } + return true; +} + +const byteLengthGetter = + Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get; +function isArrayBuffer(value) { + try { + byteLengthGetter.call(value); + return true; + } catch (e) { + return false; + } +} + +function iteratorResult([key, value], kind) { + let result; + switch (kind) { + case "key": + result = key; + break; + case "value": + result = value; + break; + case "key+value": + result = [key, value]; + break; + } + return { value: result, done: false }; +} + +const supportsPropertyIndex = Symbol("supports property index"); +const supportedPropertyIndices = Symbol("supported property indices"); +const supportsPropertyName = Symbol("supports property name"); +const supportedPropertyNames = Symbol("supported property names"); +const indexedGet = Symbol("indexed property get"); +const indexedSetNew = Symbol("indexed property set new"); +const indexedSetExisting = Symbol("indexed property set existing"); +const namedGet = Symbol("named property get"); +const namedSetNew = Symbol("named property set new"); +const namedSetExisting = Symbol("named property set existing"); +const namedDelete = Symbol("named property delete"); + +const asyncIteratorNext = Symbol("async iterator get the next iteration result"); +const asyncIteratorReturn = Symbol("async iterator return steps"); +const asyncIteratorInit = Symbol("async iterator initialization steps"); +const asyncIteratorEOI = Symbol("async iterator end of iteration"); + +module.exports = exports = { + isObject, + hasOwn, + define, + newObjectInRealm, + wrapperSymbol, + implSymbol, + getSameObject, + ctorRegistrySymbol, + initCtorRegistry, + wrapperForImpl, + implForWrapper, + tryWrapperForImpl, + tryImplForWrapper, + iterInternalSymbol, + isArrayBuffer, + isArrayIndexPropName, + supportsPropertyIndex, + supportedPropertyIndices, + supportsPropertyName, + supportedPropertyNames, + indexedGet, + indexedSetNew, + indexedSetExisting, + namedGet, + namedSetNew, + namedSetExisting, + namedDelete, + asyncIteratorNext, + asyncIteratorReturn, + asyncIteratorInit, + asyncIteratorEOI, + iteratorResult +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/agent-factory.js b/node_modules/jsdom/lib/jsdom/living/helpers/agent-factory.js new file mode 100644 index 00000000..4af6a244 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/agent-factory.js @@ -0,0 +1,15 @@ +"use strict"; +const http = require("http"); +const https = require("https"); +const { parse: parseURLToNodeOptions } = require("url"); +const HttpProxyAgent = require("http-proxy-agent"); +const HttpsProxyAgent = require("https-proxy-agent"); + +module.exports = function agentFactory(proxy, rejectUnauthorized) { + const agentOpts = { keepAlive: true, rejectUnauthorized }; + if (proxy) { + const proxyOpts = { ...parseURLToNodeOptions(proxy), ...agentOpts }; + return { https: new HttpsProxyAgent(proxyOpts), http: new HttpProxyAgent(proxyOpts) }; + } + return { http: new http.Agent(agentOpts), https: new https.Agent(agentOpts) }; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/binary-data.js b/node_modules/jsdom/lib/jsdom/living/helpers/binary-data.js new file mode 100644 index 00000000..dc5909c8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/binary-data.js @@ -0,0 +1,9 @@ +"use strict"; + +// See https://github.com/jsdom/jsdom/pull/2743#issuecomment-562991955 for background. +exports.copyToArrayBufferInNewRealm = (nodejsBuffer, newRealm) => { + const newAB = new newRealm.ArrayBuffer(nodejsBuffer.byteLength); + const view = new Uint8Array(newAB); + view.set(nodejsBuffer); + return newAB; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/create-element.js b/node_modules/jsdom/lib/jsdom/living/helpers/create-element.js new file mode 100644 index 00000000..0a330ec3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/create-element.js @@ -0,0 +1,320 @@ +"use strict"; + +const DOMException = require("domexception/webidl2js-wrapper"); + +const interfaces = require("../interfaces"); + +const { implForWrapper } = require("../generated/utils"); + +const { HTML_NS, SVG_NS } = require("./namespaces"); +const { domSymbolTree } = require("./internal-constants"); +const { validateAndExtract } = require("./validate-names"); +const reportException = require("./runtime-script-errors"); +const { + isValidCustomElementName, upgradeElement, lookupCEDefinition, enqueueCEUpgradeReaction +} = require("./custom-elements"); + +const INTERFACE_TAG_MAPPING = { + // https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom%3Aelement-interface + // https://html.spec.whatwg.org/multipage/indices.html#elements-3 + [HTML_NS]: { + HTMLElement: [ + "abbr", "address", "article", "aside", "b", "bdi", "bdo", "cite", "code", "dd", "dfn", "dt", "em", "figcaption", + "figure", "footer", "header", "hgroup", "i", "kbd", "main", "mark", "nav", "noscript", "rp", "rt", "ruby", "s", + "samp", "section", "small", "strong", "sub", "summary", "sup", "u", "var", "wbr" + ], + HTMLAnchorElement: ["a"], + HTMLAreaElement: ["area"], + HTMLAudioElement: ["audio"], + HTMLBaseElement: ["base"], + HTMLBodyElement: ["body"], + HTMLBRElement: ["br"], + HTMLButtonElement: ["button"], + HTMLCanvasElement: ["canvas"], + HTMLDataElement: ["data"], + HTMLDataListElement: ["datalist"], + HTMLDetailsElement: ["details"], + HTMLDialogElement: ["dialog"], + HTMLDirectoryElement: ["dir"], + HTMLDivElement: ["div"], + HTMLDListElement: ["dl"], + HTMLEmbedElement: ["embed"], + HTMLFieldSetElement: ["fieldset"], + HTMLFontElement: ["font"], + HTMLFormElement: ["form"], + HTMLFrameElement: ["frame"], + HTMLFrameSetElement: ["frameset"], + HTMLHeadingElement: ["h1", "h2", "h3", "h4", "h5", "h6"], + HTMLHeadElement: ["head"], + HTMLHRElement: ["hr"], + HTMLHtmlElement: ["html"], + HTMLIFrameElement: ["iframe"], + HTMLImageElement: ["img"], + HTMLInputElement: ["input"], + HTMLLabelElement: ["label"], + HTMLLegendElement: ["legend"], + HTMLLIElement: ["li"], + HTMLLinkElement: ["link"], + HTMLMapElement: ["map"], + HTMLMarqueeElement: ["marquee"], + HTMLMediaElement: [], + HTMLMenuElement: ["menu"], + HTMLMetaElement: ["meta"], + HTMLMeterElement: ["meter"], + HTMLModElement: ["del", "ins"], + HTMLObjectElement: ["object"], + HTMLOListElement: ["ol"], + HTMLOptGroupElement: ["optgroup"], + HTMLOptionElement: ["option"], + HTMLOutputElement: ["output"], + HTMLParagraphElement: ["p"], + HTMLParamElement: ["param"], + HTMLPictureElement: ["picture"], + HTMLPreElement: ["listing", "pre", "xmp"], + HTMLProgressElement: ["progress"], + HTMLQuoteElement: ["blockquote", "q"], + HTMLScriptElement: ["script"], + HTMLSelectElement: ["select"], + HTMLSlotElement: ["slot"], + HTMLSourceElement: ["source"], + HTMLSpanElement: ["span"], + HTMLStyleElement: ["style"], + HTMLTableCaptionElement: ["caption"], + HTMLTableCellElement: ["th", "td"], + HTMLTableColElement: ["col", "colgroup"], + HTMLTableElement: ["table"], + HTMLTimeElement: ["time"], + HTMLTitleElement: ["title"], + HTMLTableRowElement: ["tr"], + HTMLTableSectionElement: ["thead", "tbody", "tfoot"], + HTMLTemplateElement: ["template"], + HTMLTextAreaElement: ["textarea"], + HTMLTrackElement: ["track"], + HTMLUListElement: ["ul"], + HTMLUnknownElement: [], + HTMLVideoElement: ["video"] + }, + [SVG_NS]: { + SVGElement: [], + SVGGraphicsElement: [], + SVGSVGElement: ["svg"], + SVGTitleElement: ["title"] + } +}; + +const TAG_INTERFACE_LOOKUP = {}; + +for (const namespace of [HTML_NS, SVG_NS]) { + TAG_INTERFACE_LOOKUP[namespace] = {}; + + const interfaceNames = Object.keys(INTERFACE_TAG_MAPPING[namespace]); + for (const interfaceName of interfaceNames) { + const tagNames = INTERFACE_TAG_MAPPING[namespace][interfaceName]; + + for (const tagName of tagNames) { + TAG_INTERFACE_LOOKUP[namespace][tagName] = interfaceName; + } + } +} + +const UNKNOWN_HTML_ELEMENTS_NAMES = ["applet", "bgsound", "blink", "isindex", "keygen", "multicol", "nextid", "spacer"]; +const HTML_ELEMENTS_NAMES = [ + "acronym", "basefont", "big", "center", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", + "strike", "tt" +]; + +// https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom:element-interface +function getHTMLElementInterface(name) { + if (UNKNOWN_HTML_ELEMENTS_NAMES.includes(name)) { + return interfaces.getInterfaceWrapper("HTMLUnknownElement"); + } + + if (HTML_ELEMENTS_NAMES.includes(name)) { + return interfaces.getInterfaceWrapper("HTMLElement"); + } + + const specDefinedInterface = TAG_INTERFACE_LOOKUP[HTML_NS][name]; + if (specDefinedInterface !== undefined) { + return interfaces.getInterfaceWrapper(specDefinedInterface); + } + + if (isValidCustomElementName(name)) { + return interfaces.getInterfaceWrapper("HTMLElement"); + } + + return interfaces.getInterfaceWrapper("HTMLUnknownElement"); +} + +// https://svgwg.org/svg2-draft/types.html#ElementsInTheSVGDOM +function getSVGInterface(name) { + const specDefinedInterface = TAG_INTERFACE_LOOKUP[SVG_NS][name]; + if (specDefinedInterface !== undefined) { + return interfaces.getInterfaceWrapper(specDefinedInterface); + } + + return interfaces.getInterfaceWrapper("SVGElement"); +} + +// Returns the list of valid tag names that can bo associated with a element given its namespace and name. +function getValidTagNames(namespace, name) { + if (INTERFACE_TAG_MAPPING[namespace] && INTERFACE_TAG_MAPPING[namespace][name]) { + return INTERFACE_TAG_MAPPING[namespace][name]; + } + + return []; +} + +// https://dom.spec.whatwg.org/#concept-create-element +function createElement( + document, + localName, + namespace, + prefix = null, + isValue = null, + synchronousCE = false +) { + let result = null; + + const { _globalObject } = document; + const definition = lookupCEDefinition(document, namespace, localName, isValue); + + if (definition !== null && definition.name !== localName) { + const elementInterface = getHTMLElementInterface(localName); + + result = elementInterface.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace: HTML_NS, + prefix, + ceState: "undefined", + ceDefinition: null, + isValue + }); + + if (synchronousCE) { + upgradeElement(definition, result); + } else { + enqueueCEUpgradeReaction(result, definition); + } + } else if (definition !== null) { + if (synchronousCE) { + try { + const C = definition.constructor; + + const resultWrapper = C.construct(); + result = implForWrapper(resultWrapper); + + if (!result._ceState || !result._ceDefinition || result._namespaceURI !== HTML_NS) { + throw new TypeError("Internal error: Invalid custom element."); + } + + if (result._attributeList.length !== 0) { + throw DOMException.create(_globalObject, ["Unexpected attributes.", "NotSupportedError"]); + } + if (domSymbolTree.hasChildren(result)) { + throw DOMException.create(_globalObject, ["Unexpected child nodes.", "NotSupportedError"]); + } + if (domSymbolTree.parent(result)) { + throw DOMException.create(_globalObject, ["Unexpected element parent.", "NotSupportedError"]); + } + if (result._ownerDocument !== document) { + throw DOMException.create(_globalObject, ["Unexpected element owner document.", "NotSupportedError"]); + } + if (result._namespaceURI !== namespace) { + throw DOMException.create(_globalObject, ["Unexpected element namespace URI.", "NotSupportedError"]); + } + if (result._localName !== localName) { + throw DOMException.create(_globalObject, ["Unexpected element local name.", "NotSupportedError"]); + } + + result._prefix = prefix; + result._isValue = isValue; + } catch (error) { + reportException(document._defaultView, error); + + const interfaceWrapper = interfaces.getInterfaceWrapper("HTMLUnknownElement"); + result = interfaceWrapper.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace: HTML_NS, + prefix, + ceState: "failed", + ceDefinition: null, + isValue: null + }); + } + } else { + const interfaceWrapper = interfaces.getInterfaceWrapper("HTMLElement"); + result = interfaceWrapper.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace: HTML_NS, + prefix, + ceState: "undefined", + ceDefinition: null, + isValue: null + }); + + enqueueCEUpgradeReaction(result, definition); + } + } else { + let elementInterface; + + switch (namespace) { + case HTML_NS: + elementInterface = getHTMLElementInterface(localName); + break; + + case SVG_NS: + elementInterface = getSVGInterface(localName); + break; + + default: + elementInterface = interfaces.getInterfaceWrapper("Element"); + break; + } + + result = elementInterface.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace, + prefix, + ceState: "uncustomized", + ceDefinition: null, + isValue + }); + + if (namespace === HTML_NS && (isValidCustomElementName(localName) || isValue !== null)) { + result._ceState = "undefined"; + } + } + + return result; +} + +// https://dom.spec.whatwg.org/#internal-createelementns-steps +function internalCreateElementNSSteps(document, namespace, qualifiedName, options) { + const extracted = validateAndExtract(document._globalObject, namespace, qualifiedName); + + let isValue = null; + if (options && options.is !== undefined) { + isValue = options.is; + } + + return createElement( + document, + extracted.localName, + extracted.namespace, + extracted.prefix, + isValue, + true + ); +} + +module.exports = { + createElement, + internalCreateElementNSSteps, + + getValidTagNames, + getHTMLElementInterface +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js b/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js new file mode 100644 index 00000000..e8a8d5ae --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js @@ -0,0 +1,188 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); +const ErrorEvent = require("../generated/ErrorEvent"); +const EventHandlerNonNull = require("../generated/EventHandlerNonNull.js"); +const OnBeforeUnloadEventHandlerNonNull = require("../generated/OnBeforeUnloadEventHandlerNonNull.js"); +const OnErrorEventHandlerNonNull = require("../generated/OnErrorEventHandlerNonNull.js"); +const reportException = require("./runtime-script-errors"); + +exports.appendHandler = (el, eventName) => { + // tryImplForWrapper() is currently required due to use in Window.js + idlUtils.tryImplForWrapper(el).addEventListener(eventName, event => { + // https://html.spec.whatwg.org/#the-event-handler-processing-algorithm + const callback = exports.getCurrentEventHandlerValue(el, eventName); + if (callback === null) { + return; + } + + const specialError = ErrorEvent.isImpl(event) && event.type === "error" && + event.currentTarget.constructor.name === "Window"; + + let returnValue = null; + // https://heycam.github.io/webidl/#es-invoking-callback-functions + if (typeof callback === "function") { + if (specialError) { + returnValue = callback.call( + event.currentTarget, + event.message, + event.filename, + event.lineno, + event.colno, + event.error + ); + } else { + returnValue = callback.call(event.currentTarget, event); + } + } + + // TODO: we don't implement BeforeUnloadEvent so we can't brand-check here + if (event.type === "beforeunload") { + if (returnValue !== null) { + event._canceledFlag = true; + if (event.returnValue === "") { + event.returnValue = returnValue; + } + } + } else if (specialError) { + if (returnValue === true) { + event._canceledFlag = true; + } + } else if (returnValue === false) { + event._canceledFlag = true; + } + }); +}; + +// "Simple" in this case means "no content attributes involved" +exports.setupForSimpleEventAccessors = (prototype, events) => { + prototype._getEventHandlerFor = function (event) { + return this._eventHandlers ? this._eventHandlers[event] : undefined; + }; + + prototype._setEventHandlerFor = function (event, handler) { + if (!this._registeredHandlers) { + this._registeredHandlers = new Set(); + this._eventHandlers = Object.create(null); + } + + if (!this._registeredHandlers.has(event) && handler !== null) { + this._registeredHandlers.add(event); + exports.appendHandler(this, event); + } + this._eventHandlers[event] = handler; + }; + + for (const event of events) { + exports.createEventAccessor(prototype, event); + } +}; + +// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler +exports.getCurrentEventHandlerValue = (target, event) => { + const value = target._getEventHandlerFor(event); + if (!value) { + return null; + } + + if (value.body !== undefined) { + let element, document, fn; + if (target.constructor.name === "Window") { + element = null; + document = idlUtils.implForWrapper(target.document); + } else { + element = target; + document = element.ownerDocument; + } + const { body } = value; + + const formOwner = element !== null && element.form ? element.form : null; + const window = target.constructor.name === "Window" && target._document ? target : document.defaultView; + + try { + // eslint-disable-next-line no-new-func + Function(body); // properly error out on syntax errors + // Note: this won't execute body; that would require `Function(body)()`. + } catch (e) { + if (window) { + reportException(window, e); + } + target._setEventHandlerFor(event, null); + return null; + } + + // Note: the with (window) { } is not necessary in Node, but is necessary in a browserified environment. + + const createFunction = document.defaultView.Function; + if (event === "error" && element === null) { + const sourceURL = document ? `\n//# sourceURL=${document.URL}` : ""; + + fn = createFunction(`\ +with (arguments[0]) { return function onerror(event, source, lineno, colno, error) { +${body} +}; }${sourceURL}`)(window); + + fn = OnErrorEventHandlerNonNull.convert(window, fn); + } else { + const calls = []; + if (element !== null) { + calls.push(idlUtils.wrapperForImpl(document)); + } + + if (formOwner !== null) { + calls.push(idlUtils.wrapperForImpl(formOwner)); + } + + if (element !== null) { + calls.push(idlUtils.wrapperForImpl(element)); + } + + let wrapperBody = `\ +with (arguments[0]) { return function on${event}(event) { +${body} +}; }`; + + // eslint-disable-next-line no-unused-vars + for (const call of calls) { + wrapperBody = `\ +with (arguments[0]) { return function () { +${wrapperBody} +}; }`; + } + + if (document) { + wrapperBody += `\n//# sourceURL=${document.URL}`; + } + + fn = createFunction(wrapperBody)(window); + for (const call of calls) { + fn = fn(call); + } + + if (event === "beforeunload") { + fn = OnBeforeUnloadEventHandlerNonNull.convert(window, fn); + } else { + fn = EventHandlerNonNull.convert(window, fn); + } + } + + target._setEventHandlerFor(event, fn); + } + + return target._getEventHandlerFor(event); +}; + +// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes +// TODO: Consider replacing this with `[ReflectEvent]` +exports.createEventAccessor = (obj, event) => { + Object.defineProperty(obj, "on" + event, { + configurable: true, + enumerable: true, + get() { + return exports.getCurrentEventHandlerValue(this, event); + }, + set(val) { + this._setEventHandlerFor(event, val); + } + }); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/custom-elements.js b/node_modules/jsdom/lib/jsdom/living/helpers/custom-elements.js new file mode 100644 index 00000000..1dbd7734 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/custom-elements.js @@ -0,0 +1,270 @@ +"use strict"; + +const DOMException = require("domexception/webidl2js-wrapper"); +const isPotentialCustomElementName = require("is-potential-custom-element-name"); + +const NODE_TYPE = require("../node-type"); +const { HTML_NS } = require("./namespaces"); +const { shadowIncludingRoot } = require("./shadow-dom"); +const reportException = require("./runtime-script-errors"); + +const { implForWrapper, wrapperForImpl } = require("../generated/utils"); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions-stack +class CEReactionsStack { + constructor() { + this._stack = []; + + // https://html.spec.whatwg.org/multipage/custom-elements.html#backup-element-queue + this.backupElementQueue = []; + + // https://html.spec.whatwg.org/multipage/custom-elements.html#processing-the-backup-element-queue + this.processingBackupElementQueue = false; + } + + push(elementQueue) { + this._stack.push(elementQueue); + } + + pop() { + return this._stack.pop(); + } + + get currentElementQueue() { + const { _stack } = this; + return _stack[_stack.length - 1]; + } + + isEmpty() { + return this._stack.length === 0; + } +} + +// In theory separate cross-origin Windows created by separate JSDOM instances could have separate stacks. But, we would +// need to implement the whole agent architecture. Which is kind of questionable given that we don't run our Windows in +// their own separate threads, which is what agents are meant to represent. +const customElementReactionsStack = new CEReactionsStack(); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#cereactions +function ceReactionsPreSteps() { + customElementReactionsStack.push([]); +} +function ceReactionsPostSteps() { + const queue = customElementReactionsStack.pop(); + invokeCEReactions(queue); +} + +const RESTRICTED_CUSTOM_ELEMENT_NAME = new Set([ + "annotation-xml", + "color-profile", + "font-face", + "font-face-src", + "font-face-uri", + "font-face-format", + "font-face-name", + "missing-glyph" +]); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name +function isValidCustomElementName(name) { + if (RESTRICTED_CUSTOM_ELEMENT_NAME.has(name)) { + return false; + } + + return isPotentialCustomElementName(name); +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#concept-upgrade-an-element +function upgradeElement(definition, element) { + if (element._ceState !== "undefined" || element._ceState === "uncustomized") { + return; + } + + element._ceDefinition = definition; + element._ceState = "failed"; + + for (const attribute of element._attributeList) { + const { _localName, _namespace, _value } = attribute; + enqueueCECallbackReaction(element, "attributeChangedCallback", [_localName, null, _value, _namespace]); + } + + if (shadowIncludingRoot(element).nodeType === NODE_TYPE.DOCUMENT_NODE) { + enqueueCECallbackReaction(element, "connectedCallback", []); + } + + definition.constructionStack.push(element); + + const { constructionStack, constructor: C } = definition; + + let constructionError; + try { + if (definition.disableShadow === true && element._shadowRoot !== null) { + throw DOMException.create(element._globalObject, [ + "Can't upgrade a custom element with a shadow root if shadow is disabled", + "NotSupportedError" + ]); + } + + const constructionResult = C.construct(); + const constructionResultImpl = implForWrapper(constructionResult); + + if (constructionResultImpl !== element) { + throw new TypeError("Invalid custom element constructor return value"); + } + } catch (error) { + constructionError = error; + } + + constructionStack.pop(); + + if (constructionError !== undefined) { + element._ceDefinition = null; + element._ceReactionQueue = []; + + throw constructionError; + } + + element._ceState = "custom"; +} + +// https://html.spec.whatwg.org/#concept-try-upgrade +function tryUpgradeElement(element) { + const { _ownerDocument, _namespaceURI, _localName, _isValue } = element; + const definition = lookupCEDefinition(_ownerDocument, _namespaceURI, _localName, _isValue); + + if (definition !== null) { + enqueueCEUpgradeReaction(element, definition); + } +} + +// https://html.spec.whatwg.org/#look-up-a-custom-element-definition +function lookupCEDefinition(document, namespace, localName, isValue) { + const definition = null; + + if (namespace !== HTML_NS) { + return definition; + } + + if (!document._defaultView) { + return definition; + } + + const registry = implForWrapper(document._globalObject.customElements); + + const definitionByName = registry._customElementDefinitions.find(def => { + return def.name === def.localName && def.localName === localName; + }); + if (definitionByName !== undefined) { + return definitionByName; + } + + const definitionByIs = registry._customElementDefinitions.find(def => { + return def.name === isValue && def.localName === localName; + }); + if (definitionByIs !== undefined) { + return definitionByIs; + } + + return definition; +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#invoke-custom-element-reactions +function invokeCEReactions(elementQueue) { + while (elementQueue.length > 0) { + const element = elementQueue.shift(); + + const reactions = element._ceReactionQueue; + + try { + while (reactions.length > 0) { + const reaction = reactions.shift(); + + switch (reaction.type) { + case "upgrade": + upgradeElement(reaction.definition, element); + break; + + case "callback": + reaction.callback.apply(wrapperForImpl(element), reaction.args); + break; + } + } + } catch (error) { + reportException(element._globalObject, error); + } + } +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-an-element-on-the-appropriate-element-queue +function enqueueElementOnAppropriateElementQueue(element) { + if (customElementReactionsStack.isEmpty()) { + customElementReactionsStack.backupElementQueue.push(element); + + if (customElementReactionsStack.processingBackupElementQueue) { + return; + } + + customElementReactionsStack.processingBackupElementQueue = true; + + Promise.resolve().then(() => { + const elementQueue = customElementReactionsStack.backupElementQueue; + invokeCEReactions(elementQueue); + + customElementReactionsStack.processingBackupElementQueue = false; + }); + } else { + customElementReactionsStack.currentElementQueue.push(element); + } +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-a-custom-element-callback-reaction +function enqueueCECallbackReaction(element, callbackName, args) { + const { _ceDefinition: { lifecycleCallbacks, observedAttributes } } = element; + + const callback = lifecycleCallbacks[callbackName]; + if (callback === null) { + return; + } + + if (callbackName === "attributeChangedCallback") { + const attributeName = args[0]; + if (!observedAttributes.includes(attributeName)) { + return; + } + } + + element._ceReactionQueue.push({ + type: "callback", + callback, + args + }); + + enqueueElementOnAppropriateElementQueue(element); +} + +// https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction +function enqueueCEUpgradeReaction(element, definition) { + element._ceReactionQueue.push({ + type: "upgrade", + definition + }); + + enqueueElementOnAppropriateElementQueue(element); +} + +module.exports = { + customElementReactionsStack, + + ceReactionsPreSteps, + ceReactionsPostSteps, + + isValidCustomElementName, + + upgradeElement, + tryUpgradeElement, + + lookupCEDefinition, + enqueueCEUpgradeReaction, + enqueueCECallbackReaction, + invokeCEReactions +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/dates-and-times.js b/node_modules/jsdom/lib/jsdom/living/helpers/dates-and-times.js new file mode 100644 index 00000000..15d920b4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/dates-and-times.js @@ -0,0 +1,270 @@ +"use strict"; + +function isLeapYear(year) { + return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#number-of-days-in-month-month-of-year-year +const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +function numberOfDaysInMonthOfYear(month, year) { + if (month === 2 && isLeapYear(year)) { + return 29; + } + return daysInMonth[month - 1]; +} + +const monthRe = /^([0-9]{4,})-([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-month-string +function parseMonthString(str) { + const matches = monthRe.exec(str); + if (!matches) { + return null; + } + const year = Number(matches[1]); + if (year <= 0) { + return null; + } + const month = Number(matches[2]); + if (month < 1 || month > 12) { + return null; + } + return { year, month }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-month-string +function isValidMonthString(str) { + return parseMonthString(str) !== null; +} +function serializeMonth({ year, month }) { + const yearStr = `${year}`.padStart(4, "0"); + const monthStr = `${month}`.padStart(2, "0"); + return `${yearStr}-${monthStr}`; +} + +const dateRe = /^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-date-string +function parseDateString(str) { + const matches = dateRe.exec(str); + if (!matches) { + return null; + } + const year = Number(matches[1]); + if (year <= 0) { + return null; + } + const month = Number(matches[2]); + if (month < 1 || month > 12) { + return null; + } + const day = Number(matches[3]); + if (day < 1 || day > numberOfDaysInMonthOfYear(month, year)) { + return null; + } + return { year, month, day }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string +function isValidDateString(str) { + return parseDateString(str) !== null; +} +function serializeDate(date) { + const dayStr = `${date.day}`.padStart(2, "0"); + return `${serializeMonth(date)}-${dayStr}`; +} + +const yearlessDateRe = /^(?:--)?([0-9]{2})-([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-yearless-date-string +function parseYearlessDateString(str) { + const matches = yearlessDateRe.exec(str); + if (!matches) { + return null; + } + const month = Number(matches[1]); + if (month < 1 || month > 12) { + return null; + } + const day = Number(matches[2]); + if (day < 1 || day > numberOfDaysInMonthOfYear(month, 4)) { + return null; + } + return { month, day }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-yearless-date-string +function isValidYearlessDateString(str) { + return parseYearlessDateString(str) !== null; +} +function serializeYearlessDate({ month, day }) { + const monthStr = `${month}`.padStart(2, "0"); + const dayStr = `${day}`.padStart(2, "0"); + return `${monthStr}-${dayStr}`; +} + +const timeRe = /^([0-9]{2}):([0-9]{2})(?::([0-9]{2}(?:\.([0-9]{1,3}))?))?$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-time-string +function parseTimeString(str) { + const matches = timeRe.exec(str); + if (!matches) { + return null; + } + const hour = Number(matches[1]); + if (hour < 0 || hour > 23) { + return null; + } + const minute = Number(matches[2]); + if (minute < 0 || minute > 59) { + return null; + } + const second = matches[3] !== undefined ? Math.trunc(Number(matches[3])) : 0; + if (second < 0 || second >= 60) { + return null; + } + const millisecond = matches[4] !== undefined ? Number(matches[4]) : 0; + return { hour, minute, second, millisecond }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-time-string +function isValidTimeString(str) { + return parseTimeString(str) !== null; +} + +function serializeTime({ hour, minute, second, millisecond }) { + const hourStr = `${hour}`.padStart(2, "0"); + const minuteStr = `${minute}`.padStart(2, "0"); + if (second === 0 && millisecond === 0) { + return `${hourStr}:${minuteStr}`; + } + const secondStr = `${second}`.padStart(2, "0"); + const millisecondStr = `${millisecond}`.padStart(3, "0"); + return `${hourStr}:${minuteStr}:${secondStr}.${millisecondStr}`; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-local-date-and-time-string +function parseLocalDateAndTimeString(str, normalized = false) { + let separatorIdx = str.indexOf("T"); + if (separatorIdx < 0 && !normalized) { + separatorIdx = str.indexOf(" "); + } + if (separatorIdx < 0) { + return null; + } + const date = parseDateString(str.slice(0, separatorIdx)); + if (date === null) { + return null; + } + const time = parseTimeString(str.slice(separatorIdx + 1)); + if (time === null) { + return null; + } + return { date, time }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string +function isValidLocalDateAndTimeString(str) { + return parseLocalDateAndTimeString(str) !== null; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-normalised-local-date-and-time-string +function isValidNormalizedLocalDateAndTimeString(str) { + return parseLocalDateAndTimeString(str, true) !== null; +} +function serializeNormalizedDateAndTime({ date, time }) { + return `${serializeDate(date)}T${serializeTime(time)}`; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#week-number-of-the-last-day +// https://stackoverflow.com/a/18538272/1937836 +function weekNumberOfLastDay(year) { + const jan1 = new Date(year, 0); + return jan1.getDay() === 4 || (isLeapYear(year) && jan1.getDay() === 3) ? 53 : 52; +} + +const weekRe = /^([0-9]{4,5})-W([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-week-string +function parseWeekString(str) { + const matches = weekRe.exec(str); + if (!matches) { + return null; + } + const year = Number(matches[1]); + if (year <= 0) { + return null; + } + const week = Number(matches[2]); + if (week < 1 || week > weekNumberOfLastDay(year)) { + return null; + } + return { year, week }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-week-string +function isValidWeekString(str) { + return parseWeekString(str) !== null; +} +function serializeWeek({ year, week }) { + const yearStr = `${year}`.padStart(4, "0"); + const weekStr = `${week}`.padStart(2, "0"); + return `${yearStr}-W${weekStr}`; +} + +// https://stackoverflow.com/a/6117889 +function parseDateAsWeek(originalDate) { + const dayInSeconds = 86400000; + // Copy date so don't modify original + const date = new Date(Date.UTC(originalDate.getUTCFullYear(), originalDate.getUTCMonth(), originalDate.getUTCDate())); + // Set to nearest Thursday: current date + 4 - current day number + // Make Sunday's day number 7 + date.setUTCDate(date.getUTCDate() + 4 - (date.getUTCDay() || 7)); + // Get first day of year + const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1)); + // Calculate full weeks to nearest Thursday + const week = Math.ceil((((date - yearStart) / dayInSeconds) + 1) / 7); + + return { year: date.getUTCFullYear(), week }; +} + +function isDate(obj) { + try { + Date.prototype.valueOf.call(obj); + return true; + } catch { + return false; + } +} + +module.exports = { + isDate, + numberOfDaysInMonthOfYear, + + parseMonthString, + isValidMonthString, + serializeMonth, + + parseDateString, + isValidDateString, + serializeDate, + + parseYearlessDateString, + isValidYearlessDateString, + serializeYearlessDate, + + parseTimeString, + isValidTimeString, + serializeTime, + + parseLocalDateAndTimeString, + isValidLocalDateAndTimeString, + isValidNormalizedLocalDateAndTimeString, + serializeNormalizedDateAndTime, + + parseDateAsWeek, + weekNumberOfLastDay, + parseWeekString, + isValidWeekString, + serializeWeek +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/details.js b/node_modules/jsdom/lib/jsdom/living/helpers/details.js new file mode 100644 index 00000000..25c5387d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/details.js @@ -0,0 +1,15 @@ +"use strict"; +const { firstChildWithLocalName } = require("./traversal"); +const { HTML_NS } = require("./namespaces"); + +// https://html.spec.whatwg.org/multipage/interactive-elements.html#summary-for-its-parent-details +exports.isSummaryForParentDetails = summaryElement => { + const parent = summaryElement.parentNode; + if (parent === null) { + return false; + } + if (parent._localName !== "details" || parent._namespaceURI !== HTML_NS) { + return false; + } + return firstChildWithLocalName(parent, "summary") === summaryElement; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/document-base-url.js b/node_modules/jsdom/lib/jsdom/living/helpers/document-base-url.js new file mode 100644 index 00000000..f69e0619 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/document-base-url.js @@ -0,0 +1,54 @@ +"use strict"; +const whatwgURL = require("whatwg-url"); +const { implForWrapper } = require("../generated/utils"); + +exports.documentBaseURL = document => { + // https://html.spec.whatwg.org/multipage/infrastructure.html#document-base-url + + const firstBase = document.querySelector("base[href]"); + const fallbackBaseURL = exports.fallbackBaseURL(document); + + if (firstBase === null) { + return fallbackBaseURL; + } + + return frozenBaseURL(firstBase, fallbackBaseURL); +}; + +exports.documentBaseURLSerialized = document => { + return whatwgURL.serializeURL(exports.documentBaseURL(document)); +}; + +exports.fallbackBaseURL = document => { + // https://html.spec.whatwg.org/multipage/infrastructure.html#fallback-base-url + + // Unimplemented: