diff options
Diffstat (limited to 'extensions/web/12_location.js')
-rw-r--r-- | extensions/web/12_location.js | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/extensions/web/12_location.js b/extensions/web/12_location.js index dd56fb47b..40dd545fe 100644 --- a/extensions/web/12_location.js +++ b/extensions/web/12_location.js @@ -1,9 +1,23 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. "use strict"; +/// <reference path="../../core/internal.d.ts" /> + ((window) => { const { URL } = window.__bootstrap.url; const { DOMException } = window.__bootstrap.domException; + const { + Error, + ObjectDefineProperties, + ReferenceError, + Symbol, + SymbolFor, + SymbolToStringTag, + TypeError, + WeakMap, + WeakMapPrototypeGet, + WeakMapPrototypeSet, + } = window.__bootstrap.primordials; const locationConstructorKey = Symbol("locationConstuctorKey"); @@ -20,7 +34,7 @@ const url = new URL(href); url.username = ""; url.password = ""; - Object.defineProperties(this, { + ObjectDefineProperties(this, { hash: { get() { return url.hash; @@ -167,7 +181,7 @@ }, enumerable: true, }, - [Symbol.for("Deno.privateCustomInspect")]: { + [SymbolFor("Deno.privateCustomInspect")]: { value: function (inspect) { const object = { hash: this.hash, @@ -187,8 +201,8 @@ } } - Object.defineProperties(Location.prototype, { - [Symbol.toStringTag]: { + ObjectDefineProperties(Location.prototype, { + [SymbolToStringTag]: { value: "Location", configurable: true, }, @@ -204,14 +218,14 @@ const url = new URL(href); url.username = ""; url.password = ""; - workerLocationUrls.set(this, url); + WeakMapPrototypeSet(workerLocationUrls, this, url); } } - Object.defineProperties(WorkerLocation.prototype, { + ObjectDefineProperties(WorkerLocation.prototype, { hash: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -222,7 +236,7 @@ }, host: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -233,7 +247,7 @@ }, hostname: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -244,7 +258,7 @@ }, href: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -255,7 +269,7 @@ }, origin: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -266,7 +280,7 @@ }, pathname: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -277,7 +291,7 @@ }, port: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -288,7 +302,7 @@ }, protocol: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -299,7 +313,7 @@ }, search: { get() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -310,7 +324,7 @@ }, toString: { value: function toString() { - const url = workerLocationUrls.get(this); + const url = WeakMapPrototypeGet(workerLocationUrls, this); if (url == null) { throw new TypeError("Illegal invocation."); } @@ -320,11 +334,11 @@ enumerable: true, writable: true, }, - [Symbol.toStringTag]: { + [SymbolToStringTag]: { value: "WorkerLocation", configurable: true, }, - [Symbol.for("Deno.privateCustomInspect")]: { + [SymbolFor("Deno.privateCustomInspect")]: { value: function (inspect) { const object = { hash: this.hash, |