1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 23:34:47 -05:00

refactor: use primordials for extensions/webstorage (#11239)

This commit is contained in:
Divy Srivastava 2021-07-03 15:19:41 +05:30 committed by GitHub
parent caf87694d0
commit e90b97ada2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,18 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
/// <reference path="../../core/internal.d.ts" />
((window) => {
const core = window.Deno.core;
const webidl = window.__bootstrap.webidl;
const {
Symbol,
ObjectDefineProperty,
ObjectFromEntries,
ObjectEntries,
ReflectGet,
Proxy,
} = window.__bootstrap.primordials;
const _persistent = Symbol("[[persistent]]");
@ -96,7 +106,7 @@
},
defineProperty(target, key, descriptor) {
if (typeof key == "symbol") {
Object.defineProperty(target, key, descriptor);
ObjectDefineProperty(target, key, descriptor);
} else {
target.setItem(key, descriptor.value);
}
@ -105,14 +115,14 @@
get(target, key) {
if (typeof key == "symbol") return target[key];
if (key in target) {
return Reflect.get(...arguments);
return ReflectGet(...arguments);
} else {
return target.getItem(key) ?? undefined;
}
},
set(target, key, value) {
if (typeof key == "symbol") {
Object.defineProperty(target, key, {
ObjectDefineProperty(target, key, {
value,
configurable: true,
});
@ -151,7 +161,7 @@
return `${this.constructor.name} ${
inspect({
length: this.length,
...Object.fromEntries(Object.entries(proxy)),
...ObjectFromEntries(ObjectEntries(proxy)),
})
}`;
};