run ESLint

Several bugs were found (and fixed):
src/client/index.js:71
the following if() was equivalent to if (false in obj)

src/client/dom/element.js:207
the following if() was equivalent to if (!element || false in element)

src/client/rewrite/html.js:179
an undefined iterate() was referenced
This commit is contained in:
David Reed 2022-11-23 12:37:00 -05:00
parent f0611a980c
commit 561a1ee190
No known key found for this signature in database
GPG key ID: 2211691D8A1EE72F
19 changed files with 161 additions and 220 deletions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
dist

12
.eslintrc Normal file
View file

@ -0,0 +1,12 @@
{
"env": {
"browser": true,
"worker": true,
"serviceworker": true,
"es6": true,
"node": true
},
"globals": { "globalThis": true, "importScripts": true },
"parserOptions": { "sourceType": "module", "ecmaVersion": "latest" },
"extends": ["eslint:recommended"]
}

1
.prettierignore Normal file
View file

@ -0,0 +1 @@
dist

213
package-lock.json generated
View file

@ -22,7 +22,7 @@
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.8.0",
"eslint": "^8.28.0",
"prettier": "^2.7.1",
"terser-webpack-plugin": "^5.3.6",
"webpack": "^5.74.0",
@ -39,9 +39,9 @@
}
},
"node_modules/@eslint/eslintrc": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz",
"integrity": "sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ==",
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz",
"integrity": "sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==",
"dev": true,
"dependencies": {
"ajv": "^6.12.4",
@ -62,29 +62,19 @@
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz",
"integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==",
"version": "0.11.7",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz",
"integrity": "sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw==",
"dev": true,
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
"debug": "^4.1.1",
"minimatch": "^3.0.4"
"minimatch": "^3.0.5"
},
"engines": {
"node": ">=10.10.0"
}
},
"node_modules/@humanwhocodes/gitignore-to-minimatch": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz",
"integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/nzakas"
}
},
"node_modules/@humanwhocodes/module-importer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
@ -557,15 +547,6 @@
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"node_modules/array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -987,15 +968,15 @@
}
},
"node_modules/eslint": {
"version": "8.23.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.0.tgz",
"integrity": "sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA==",
"version": "8.28.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.28.0.tgz",
"integrity": "sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==",
"dev": true,
"dependencies": {
"@eslint/eslintrc": "^1.3.1",
"@humanwhocodes/config-array": "^0.10.4",
"@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
"@eslint/eslintrc": "^1.3.3",
"@humanwhocodes/config-array": "^0.11.6",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
@ -1011,15 +992,15 @@
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
"find-up": "^5.0.0",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
"glob-parent": "^6.0.2",
"globals": "^13.15.0",
"globby": "^11.1.0",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"is-path-inside": "^3.0.3",
"js-sdsl": "^4.1.4",
"js-yaml": "^4.1.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
@ -1100,9 +1081,9 @@
}
},
"node_modules/espree": {
"version": "9.4.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz",
"integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==",
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz",
"integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==",
"dev": true,
"dependencies": {
"acorn": "^8.8.0",
@ -1301,12 +1282,6 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"node_modules/functional-red-black-tree": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==",
"dev": true
},
"node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -1346,9 +1321,9 @@
"dev": true
},
"node_modules/globals": {
"version": "13.17.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
"integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
"version": "13.18.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz",
"integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==",
"dev": true,
"dependencies": {
"type-fest": "^0.20.2"
@ -1360,26 +1335,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dev": true,
"dependencies": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
@ -1538,6 +1493,15 @@
"node": ">=0.12.0"
}
},
"node_modules/is-path-inside": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
@ -1594,6 +1558,16 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/js-sdsl": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz",
"integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==",
"dev": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/js-sdsl"
}
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
@ -2263,15 +2237,6 @@
"node": ">=8"
}
},
"node_modules/slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@ -2708,9 +2673,9 @@
"dev": true
},
"@eslint/eslintrc": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz",
"integrity": "sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ==",
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz",
"integrity": "sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==",
"dev": true,
"requires": {
"ajv": "^6.12.4",
@ -2725,22 +2690,16 @@
}
},
"@humanwhocodes/config-array": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz",
"integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==",
"version": "0.11.7",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz",
"integrity": "sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw==",
"dev": true,
"requires": {
"@humanwhocodes/object-schema": "^1.2.1",
"debug": "^4.1.1",
"minimatch": "^3.0.4"
"minimatch": "^3.0.5"
}
},
"@humanwhocodes/gitignore-to-minimatch": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz",
"integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==",
"dev": true
},
"@humanwhocodes/module-importer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
@ -3140,12 +3099,6 @@
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -3438,15 +3391,15 @@
"dev": true
},
"eslint": {
"version": "8.23.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.0.tgz",
"integrity": "sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA==",
"version": "8.28.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.28.0.tgz",
"integrity": "sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==",
"dev": true,
"requires": {
"@eslint/eslintrc": "^1.3.1",
"@humanwhocodes/config-array": "^0.10.4",
"@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
"@eslint/eslintrc": "^1.3.3",
"@humanwhocodes/config-array": "^0.11.6",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
@ -3462,15 +3415,15 @@
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
"find-up": "^5.0.0",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
"glob-parent": "^6.0.2",
"globals": "^13.15.0",
"globby": "^11.1.0",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"is-path-inside": "^3.0.3",
"js-sdsl": "^4.1.4",
"js-yaml": "^4.1.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
@ -3526,9 +3479,9 @@
}
},
"espree": {
"version": "9.4.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz",
"integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==",
"version": "9.4.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz",
"integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==",
"dev": true,
"requires": {
"acorn": "^8.8.0",
@ -3684,12 +3637,6 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"functional-red-black-tree": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==",
"dev": true
},
"glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -3720,28 +3667,14 @@
"dev": true
},
"globals": {
"version": "13.17.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz",
"integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==",
"version": "13.18.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz",
"integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==",
"dev": true,
"requires": {
"type-fest": "^0.20.2"
}
},
"globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dev": true,
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
}
},
"graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
@ -3858,6 +3791,12 @@
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"is-path-inside": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
"dev": true
},
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
@ -3901,6 +3840,12 @@
}
}
},
"js-sdsl": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz",
"integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==",
"dev": true
},
"js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
@ -4368,12 +4313,6 @@
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",

View file

@ -32,7 +32,7 @@
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.8.0",
"eslint": "^8.28.0",
"prettier": "^2.7.1",
"terser-webpack-plugin": "^5.3.6",
"webpack": "^5.74.0",

View file

@ -193,21 +193,6 @@ class DocumentHook extends EventEmitter {
},
});
}
overrideReferrer() {
this.ctx.overrideDescriptor(this.docProto, 'referrer', {
get: (target, that) => {
const event = new HookEvent(
{ value: target.call(that) },
target,
that
);
this.emit('referrer', event);
if (event.intercepted) return event.returnValue;
return event.data.value;
},
});
}
overrideCookie() {
this.ctx.overrideDescriptor(this.docProto, 'cookie', {
get: (target, that) => {

View file

@ -204,7 +204,7 @@ class ElementApi extends EventEmitter {
);
}
hookProperty(element, prop, handler) {
if (!element || !prop in element) return false;
if (!element || !(prop in element)) return false;
if (this.ctx.nativeMethods.isArray(element)) {
for (const elem of element) {

View file

@ -68,7 +68,7 @@ class UVClient extends EventEmitter {
);
}
override(obj, prop, wrapper, construct) {
if (!prop in obj) return false;
if (!(prop in obj)) return false;
const wrapped = this.wrap(obj, prop, wrapper, construct);
return (obj[prop] = wrapped);
}
@ -92,7 +92,7 @@ class UVClient extends EventEmitter {
},
}.attach;
if (!!construct) {
if (construct) {
wrapped.prototype = fn.prototype;
wrapped.prototype.constructor = wrapped;
}

View file

@ -37,7 +37,7 @@ class LocationApi extends EventEmitter {
for (const key of this.keys) {
this.ctx.overrideDescriptor(this.workerLocProto, key, {
get: (target, that) => {
get: () => {
return parse(uv.href.get.call(this.location))[key];
},
});
@ -78,10 +78,13 @@ class LocationApi extends EventEmitter {
);
break;
default:
{
const url = new URL(emulation.href);
url[key] = val;
that.location.href = wrap(url.href);
}
break;
}
}
: undefined,
configurable: false,

View file

@ -21,7 +21,7 @@ function validateCookie(cookie, meta, js = false) {
async function db(openDB) {
const db = await openDB('__op', 1, {
upgrade(db, oldVersion, newVersion, transaction) {
upgrade(db) {
const store = db.createObjectStore('cookies', {
keyPath: 'id',
});

View file

@ -176,7 +176,7 @@ class P5Element extends EventEmitter {
if (this.stream) return null;
let str = '';
iterate(this.node, (node) => {
this.iterate(this.node, (node) => {
if (node.nodeName === '#text') str += node.value;
});

View file

@ -365,7 +365,7 @@ export default (function (exports) {
* Calculate specificity of a selector.
* If the selector is a list, the max specificity is returned.
*/
function specificity(selector, { format = 'array' } = {}) {
function specificity(selector) {
let ast =
typeof selector === 'object'
? selector

View file

@ -1,5 +1,5 @@
function attributes(ctx, meta = ctx.meta) {
const { html, js, css, attributePrefix, handlerScript, bundleScript } = ctx;
const { html, js, attributePrefix } = ctx;
const origPrefix = attributePrefix + '-attr-';
html.on('attr', (attr, type) => {
@ -68,8 +68,8 @@ function attributes(ctx, meta = ctx.meta) {
});
}
function text(ctx, meta = ctx.meta) {
const { html, js, css, attributePrefix } = ctx;
function text(ctx) {
const { html, js, css } = ctx;
html.on('text', (text, type) => {
if (text.element.tagName === 'script') {
@ -181,8 +181,7 @@ function isEvent(name) {
}
function injectHead(ctx) {
const { html, js, css, attributePrefix } = ctx;
const origPrefix = attributePrefix + '-attr-';
const { html } = ctx;
html.on('element', (element, type) => {
if (type !== 'rewrite') return false;
if (element.tagName !== 'head') return false;

View file

@ -261,6 +261,7 @@ function unwrap(ctx) {
switch (node.callee.property.name) {
case '$wrap':
{
if (
!node.arguments ||
node.parent.type !== Syntax.MemberExpression ||
@ -280,9 +281,11 @@ function unwrap(ctx) {
end: node.end,
});
};
}
break;
case '$get':
case 'rewriteUrl':
{
const [arg] = node.arguments;
data.changes.push({
@ -296,8 +299,10 @@ function unwrap(ctx) {
end: node.end,
});
};
}
break;
case 'rewrite':
{
const [script] = node.arguments;
data.changes.push({
start: node.callee.start,
@ -310,6 +315,8 @@ function unwrap(ctx) {
});
};
}
break;
}
});
}

View file

@ -1,3 +1,4 @@
/*global UVServiceWorker*/
importScripts('/uv.bundle.js');
importScripts('/uv.config.js');
importScripts('/uv.sw.js');

View file

@ -1,3 +1,4 @@
/*global Ultraviolet*/
self.__uv$config = {
prefix: '/service/',
bare: 'https://incog.dev/bare/',

View file

@ -481,7 +481,7 @@ function __uvHook(window, config = {}, bare = '/bare/') {
});
client.overrideDescriptor(window, 'origin', {
get: (target, that) => {
get: () => {
return __uv.location.origin;
},
});
@ -1318,20 +1318,13 @@ function __uvHook(window, config = {}, bare = '/bare/') {
});
// Proper hash emulation.
if (!!window.window) {
__uv.addEventListener.call(window, 'hashchange', (event) => {
if (event.__uv$dispatched) return false;
event.stopImmediatePropagation();
const hash = window.location.hash;
client.history.replaceState.call(
window.history,
'',
'',
event.oldURL
);
client.history.replaceState.call(window.history, '', '', event.oldURL);
__uv.location.hash = hash;
});
}
client.location.on('hashchange', (oldUrl, newUrl, ctx) => {
if (ctx.HashChangeEvent && client.history.replaceState) {

View file

@ -1,3 +1,4 @@
/*globals __uv$config*/
// Users must import the config (and bundle) prior to importing uv.sw.js
// This is to allow us to produce a generic bundle with no hard-coded paths.
@ -29,7 +30,6 @@ const cspHeaders = [
'x-xss-protection',
];
const emptyMethods = ['GET', 'HEAD'];
const emptyStatus = [204, 304];
class UVServiceWorker extends Ultraviolet.EventEmitter {
constructor(config = __uv$config) {

View file

@ -1,4 +1,3 @@
import webpack from 'webpack';
import { fileURLToPath } from 'url';
import TerserPlugin from 'terser-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin';