Skip to content

Commit 6ac0aa3

Browse files
committed
fixup! lib,src: implement QuotaExceededError as DOMException-derived interface
1 parent f056a79 commit 6ac0aa3

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

lib/internal/per_context/domexception.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,11 @@ for (const { 0: name, 1: codeName, 2: value } of [
207207

208208
exports.DOMException = DOMException;
209209

210-
const quotaExceededInternalsMap = new SafeWeakMap();
211-
212210
// https://webidl.spec.whatwg.org/#quotaexceedederror
213211
class QuotaExceededError extends DOMException {
212+
#quota;
213+
#requested;
214+
214215
constructor(message = '', options = { __proto__: null }) {
215216
super(message, 'QuotaExceededError');
216217
this[transfer_mode_private_symbol] = kCloneable;
@@ -253,40 +254,36 @@ class QuotaExceededError extends DOMException {
253254
throw new RangeError('options.requested must not be less than options.quota');
254255
}
255256

256-
quotaExceededInternalsMap.set(this, { quota, requested });
257+
this.#quota = quota;
258+
this.#requested = requested;
257259
}
258260

259261
[messaging_clone_symbol]() {
260262
const domExceptionClone = DOMExceptionPrototype[messaging_clone_symbol].call(this);
261-
const { quota, requested } = quotaExceededInternalsMap.get(this);
262-
domExceptionClone.data.quota = quota;
263-
domExceptionClone.data.requested = requested;
263+
domExceptionClone.data.quota = this.#quota;
264+
domExceptionClone.data.requested = this.#requested;
264265
domExceptionClone.deserializeInfo = 'internal/worker/clone_dom_exception:QuotaExceededError';
265266
return domExceptionClone;
266267
}
267268

268269
[messaging_deserialize_symbol](data) {
269270
DOMExceptionPrototype[messaging_deserialize_symbol].call(this, data);
270-
quotaExceededInternalsMap.set(this, {
271-
quota: data.quota,
272-
requested: data.requested,
273-
});
271+
this.#quota = data.quota;
272+
this.#requested = data.requested;
274273
}
275274

276275
get quota() {
277-
const internals = quotaExceededInternalsMap.get(this);
278-
if (internals === undefined) {
276+
if (!(#quota in this)) {
279277
throwInvalidThisError(TypeError, 'QuotaExceededError');
280278
}
281-
return internals.quota;
279+
return this.#quota;
282280
}
283281

284282
get requested() {
285-
const internals = quotaExceededInternalsMap.get(this);
286-
if (internals === undefined) {
283+
if (!(#requested in this)) {
287284
throwInvalidThisError(TypeError, 'QuotaExceededError');
288285
}
289-
return internals.requested;
286+
return this.#requested;
290287
}
291288
}
292289

0 commit comments

Comments
 (0)