Skip to content

Commit

Permalink
Update Node.js minimum and dependencies
Browse files Browse the repository at this point in the history
Note that we can't yet test in Node v20 (or v19) due to nodejs/node#47798.
  • Loading branch information
domenic committed May 1, 2023
1 parent 4d1ef41 commit ee7957a
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 154 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"no-invalid-this": "off",
"require-unicode-regexp": "off",
"prefer-template": "off",
"prefer-object-has-own": "off", // remove this once Node v16 is the minimum
"logical-assignment-operators": "off", // remove this once Node v16 is the minimum
"new-cap": ["error", { "capIsNewExceptions": ["ByteString", "USVString", "DOMString"] }],

// Custom rules
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Basic info:

- **Node.js version:** <!-- only v14 and above are supported -->
- **jsdom version:** <!-- only v21 and above are supported -->
- **Node.js version:** <!-- only v16 and above are supported -->
- **jsdom version:** <!-- only v22 and above are supported -->

### Minimal reproduction case

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/jsdom-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 16
- 18
architecture:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG [DOM](https://dom.spec.whatwg.org/) and [HTML](https://html.spec.whatwg.org/multipage/) Standards, for use with Node.js. In general, the goal of the project is to emulate enough of a subset of a web browser to be useful for testing and scraping real-world web applications.

The latest versions of jsdom require Node.js v14 or newer. (Versions of jsdom below v20 still work with previous Node.js versions, but are unsupported.)
The latest versions of jsdom require Node.js v16 or newer. (Versions of jsdom below v22 still work with previous Node.js versions, but are unsupported.)

## Basic usage

Expand Down
2 changes: 1 addition & 1 deletion benchmark/path-to-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function pathToSuites(benchmarks, paths) {
let suites = benchmarks;

for (const part of parts) {
suites = Object.prototype.hasOwnProperty.call(suites, part) && suites[part];
suites = Object.hasOwn(suites, part) && suites[part];
if (!suites) {
throw Error("Invalid suite: '" + path + "'");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdom/browser/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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 { define, mixin } = require("../utils");
const Element = require("../living/generated/Element");
const EventTarget = require("../living/generated/EventTarget");
const EventHandlerNonNull = require("../living/generated/EventHandlerNonNull");
Expand Down
1 change: 0 additions & 1 deletion lib/jsdom/living/hr-time/Performance-impl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const { performance } = require("../../utils");

class PerformanceImpl extends EventTargetImpl {
constructor(globalObject, args, privateData) {
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdom/living/nodes/HTMLInputElement-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class HTMLInputElementImpl extends HTMLElementImpl {

get files() {
if (this.type === "file") {
this[filesSymbol] = this[filesSymbol] || FileList.createImpl(this._globalObject);
this[filesSymbol] ||= FileList.createImpl(this._globalObject);
} else {
this[filesSymbol] = null;
}
Expand Down
4 changes: 0 additions & 4 deletions lib/jsdom/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const path = require("path");
const whatwgURL = require("whatwg-url");
const { domSymbolTree } = require("./living/helpers/internal-constants");
const perfHooks = require("perf_hooks");
const SYMBOL_TREE_POSITION = require("symbol-tree").TreePosition;

exports.toFileUrl = function (fileName) {
Expand Down Expand Up @@ -145,9 +144,6 @@ exports.treeOrderSorter = function (a, b) {
return 0;
};

// TODO: remove once Node v16 is the minimum version.
exports.performance = globalThis.performance || perfHooks.performance;

/* eslint-disable global-require */

exports.Canvas = null;
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsdom",
"version": "21.1.2",
"version": "22.0.0",
"description": "A JavaScript implementation of many web standards",
"keywords": [
"dom",
Expand Down Expand Up @@ -60,24 +60,23 @@
"benchmark": "^2.1.4",
"browserify": "^17.0.0",
"chai": "^4.3.7",
"eslint": "^8.36.0",
"eslint": "^8.39.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-jsdom-internal": "link:./scripts/eslint-plugin",
"js-yaml": "^4.1.0",
"karma": "^6.4.1",
"karma": "^6.4.2",
"karma-browserify": "^8.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-chrome-launcher": "^3.2.0",
"karma-mocha": "^2.0.1",
"karma-mocha-webworker": "^1.3.0",
"minimatch": "^7.4.2",
"minimatch": "^9.0.0",
"mocha": "^10.2.0",
"mocha-sugar-free": "^1.4.0",
"pngjs": "^7.0.0",
"rimraf": "^4.4.0",
"server-destroy": "^1.0.1",
"watchify": "^4.0.0",
"webidl2js": "^17.1.0",
"yargs": "^17.7.1"
"yargs": "^17.7.2"
},
"browser": {
"canvas": false,
Expand All @@ -97,7 +96,7 @@
"test-browser": "yarn test-browser-iframe && yarn test-browser-worker",
"lint": "eslint . --cache --ext .js,.html",
"init-wpt": "git submodule update --init --recursive",
"reset-wpt": "rimraf ./test/web-platform-tests/tests && yarn init-wpt",
"reset-wpt": "rm -rf ./test/web-platform-tests/tests && yarn init-wpt",
"update-wpt": "git submodule update --recursive --remote && cd test/web-platform-tests/tests && python3 wpt.py manifest --path ../wpt-manifest.json",
"update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS.txt",
"benchmark": "node ./benchmark/runner",
Expand All @@ -107,6 +106,6 @@
},
"main": "./lib/api.js",
"engines": {
"node": ">=14"
"node": ">=16"
}
}
3 changes: 1 addition & 2 deletions scripts/webidl/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

const path = require("path");
const fs = require("fs");
const rimraf = require("rimraf");

const Webidl2js = require("webidl2js");

Expand Down Expand Up @@ -169,7 +168,7 @@ addDir("../../lib/jsdom/living/xhr");
const outputDir = path.resolve(__dirname, "../../lib/jsdom/living/generated/");

// Clean up any old stuff lying around.
rimraf.sync(outputDir);
fs.rmSync(outputDir, { force: true, recursive: true, maxRetries: 2 });
fs.mkdirSync(outputDir);

transformer.generate(outputDir)
Expand Down
2 changes: 1 addition & 1 deletion test/to-port-to-wpts/node-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("node-contains", { skipIfBrowser: true }, () => {
case "whatToShow":
case "filter":
case "toString":
assert.ok(!Object.prototype.hasOwnProperty.call(it, key), key + " should not be an 'own' property");
assert.ok(!Object.hasOwn(it, key), key + " should not be an 'own' property");
break;
default:
assert.ok(false, key + " is not a valid NodeIterator property");
Expand Down

0 comments on commit ee7957a

Please sign in to comment.