Skip to content

Commit 6d9ff2c

Browse files
committed
Remove abab dependency
1 parent 7027a3d commit 6d9ff2c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/jsdom/browser/Window.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const { fireAPageTransitionEvent } = require("../living/helpers/page-transition-
1515
const namedPropertiesWindow = require("../living/named-properties-window");
1616
const postMessage = require("../living/post-message");
1717
const DOMException = require("domexception/webidl2js-wrapper");
18-
const { btoa, atob } = require("abab");
1918
const idlUtils = require("../living/generated/utils");
2019
const WebSocketImpl = require("../living/websockets/WebSocket-impl").implementation;
2120
const BarProp = require("../living/generated/BarProp");
@@ -757,25 +756,27 @@ function Window(options) {
757756
this.postMessage = postMessage(window);
758757

759758
this.atob = function (str) {
760-
const result = atob(str);
761-
if (result === null) {
759+
try {
760+
return atob(str);
761+
} catch (e) {
762+
// Convert Node.js DOMException to one from our global.
762763
throw DOMException.create(window, [
763764
"The string to be decoded contains invalid characters.",
764765
"InvalidCharacterError"
765766
]);
766767
}
767-
return result;
768768
};
769769

770770
this.btoa = function (str) {
771-
const result = btoa(str);
772-
if (result === null) {
771+
try {
772+
return btoa(str);
773+
} catch (e) {
774+
// Convert Node.js DOMException to one from our global.
773775
throw DOMException.create(window, [
774776
"The string to be encoded contains invalid characters.",
775777
"InvalidCharacterError"
776778
]);
777779
}
778-
return result;
779780
};
780781

781782
this.stop = function () {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"license": "MIT",
2121
"repository": "jsdom/jsdom",
2222
"dependencies": {
23-
"abab": "^2.0.6",
2423
"cssstyle": "^3.0.0",
2524
"data-urls": "^4.0.0",
2625
"decimal.js": "^10.4.3",

0 commit comments

Comments
 (0)