mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-17 13:30:00 -04:00
sa
This commit is contained in:
parent
e9f1379e22
commit
19ea7e8a02
5 changed files with 200 additions and 8 deletions
|
@ -1,11 +1,15 @@
|
|||
class LocationApi {
|
||||
import EventEmitter from "./events.js";
|
||||
|
||||
class LocationApi extends EventEmitter {
|
||||
constructor(ctx) {
|
||||
super();
|
||||
this.ctx = ctx;
|
||||
this.window = ctx.window;
|
||||
this.location = this.window.location;
|
||||
this.WorkerLocation = this.ctx.worker ? this.window.WorkerLocation : null;
|
||||
this.workerLocProto = this.WorkerLocation ? this.WorkerLocation.prototype : {};
|
||||
this.keys = ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash', 'origin'];
|
||||
this.HashChangeEvent = this.window.HashChangeEvent || null;
|
||||
this.href = this.WorkerLocation ? ctx.nativeMethods.getOwnPropertyDescriptor(this.workerLocProto, 'href') :
|
||||
ctx.nativeMethods.getOwnPropertyDescriptor(this.location, 'href');
|
||||
};
|
||||
|
@ -42,7 +46,7 @@ class LocationApi {
|
|||
that.location.href = wrap(val);
|
||||
break;
|
||||
case 'hash':
|
||||
that.location.hash = val;
|
||||
that.emit('hashchange', emulation.href, (val.trim().startsWith('#') ? new URL(val.trim(), emulation.href).href : new URL('#' + val.trim(), emulation.href).href), that);
|
||||
break;
|
||||
default:
|
||||
const url = new URL(emulation.href);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue