summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/web/01_dom_exception.js38
1 files changed, 23 insertions, 15 deletions
diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js
index 31d2cdc29..54d47beaf 100644
--- a/ext/web/01_dom_exception.js
+++ b/ext/web/01_dom_exception.js
@@ -26,6 +26,7 @@ import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
const _name = Symbol("name");
const _message = Symbol("message");
const _code = Symbol("code");
+const _error = Symbol("error");
// Defined in WebIDL 4.3.
// https://webidl.spec.whatwg.org/#idl-DOMException
@@ -111,21 +112,8 @@ class DOMException {
this[_code] = code;
this[webidl.brand] = webidl.brand;
- const error = new Error(message);
- error.name = "DOMException";
- ObjectDefineProperty(this, "stack", {
- value: error.stack,
- writable: true,
- configurable: true,
- });
-
- // `DOMException` isn't a native error, so `Error.prepareStackTrace()` is
- // not called when accessing `.stack`, meaning our structured stack trace
- // hack doesn't apply. This patches it in.
- ObjectDefineProperty(this, "__callSiteEvals", {
- value: ArrayPrototypeSlice(error.__callSiteEvals, 1),
- configurable: true,
- });
+ this[_error] = new Error(message);
+ this[_error].name = "DOMException";
}
get message() {
@@ -160,6 +148,26 @@ class DOMException {
}
}
+ObjectDefineProperty(DOMException.prototype, "stack", {
+ get() {
+ return this[_error].stack;
+ },
+ set(value) {
+ this[_error].stack = value;
+ },
+ configurable: true,
+});
+
+// `DOMException` isn't a native error, so `Error.prepareStackTrace()` is
+// not called when accessing `.stack`, meaning our structured stack trace
+// hack doesn't apply. This patches it in.
+ObjectDefineProperty(DOMException.prototype, "__callSiteEvals", {
+ get() {
+ return ArrayPrototypeSlice(this[_error].__callSiteEvals, 1);
+ },
+ configurable: true,
+});
+
ObjectSetPrototypeOf(DOMException.prototype, ErrorPrototype);
webidl.configurePrototype(DOMException);