Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Feb 13, 2019
1 parent c07ff2b commit 95114d9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
37 changes: 20 additions & 17 deletions js/dom_types.ts
Expand Up @@ -539,34 +539,35 @@ export interface Response extends Body {

export interface Location {
/**
* Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing
* context to the top-level browsing context.
* Returns a DOMStringList object listing the origins of the ancestor browsing
* contexts, from the parent browsing context to the top-level browsing
* context.
*/
readonly ancestorOrigins: string[];
/**
* Returns the Location object's URL's fragment (includes leading "#" if non-empty).
* Can be set, to navigate to the same URL with a changed fragment (ignores leading "#").
* Returns the Location object's URL's fragment (includes leading "#" if
* non-empty).
* Can be set, to navigate to the same URL with a changed fragment (ignores
* leading "#").
*/
hash: string;
/**
* Returns the Location object's URL's host and port (if different from the default
* port for the scheme).
* Can be set, to navigate to the same URL with a changed host and port.
* Returns the Location object's URL's host and port (if different from the
* default port for the scheme). Can be set, to navigate to the same URL with
* a changed host and port.
*/
host: string;
/**
* Returns the Location object's URL's host.
* Can be set, to navigate to the same URL with a changed host.
* Returns the Location object's URL's host. Can be set, to navigate to the
* same URL with a changed host.
*/
hostname: string;
/**
* Returns the Location object's URL.
* Can be set, to navigate to the given URL.
* Returns the Location object's URL. Can be set, to navigate to the given
* URL.
*/
href: string;
/**
* Returns the Location object's URL's origin.
*/
/** Returns the Location object's URL's origin. */
readonly origin: string;
/**
* Returns the Location object's URL's path.
Expand All @@ -584,8 +585,9 @@ export interface Location {
*/
protocol: string;
/**
* Returns the Location object's URL's query (includes leading "?" if non-empty).
* Can be set, to navigate to the same URL with a changed query (ignores leading "?").
* Returns the Location object's URL's query (includes leading "?" if
* non-empty). Can be set, to navigate to the same URL with a changed query
* (ignores leading "?").
*/
search: string;
/**
Expand All @@ -599,7 +601,8 @@ export interface Location {
/** @deprecated */
reload(forcedReload: boolean): void;
/**
* Removes the current page from the session history and navigates to the given URL.
* Removes the current page from the session history and navigates to the
* given URL.
*/
replace(url: string): void;
}
7 changes: 1 addition & 6 deletions js/globals.ts
Expand Up @@ -23,7 +23,6 @@ import * as url from "./url";
import * as urlSearchParams from "./url_search_params";
import * as workers from "./workers";
import * as performanceUtil from "./performance";
import * as locationTypes from "./location";

// These imports are not exposed and therefore are fine to just import the
// symbols required.
Expand All @@ -43,11 +42,6 @@ export const window = globalEval("this");
// A self reference to the global object.
window.window = window;

export function setLocation(url: string): void {
window.location = new locationTypes.LocationImpl(url);
Object.freeze(window.location);
}

// This is the Deno namespace, it is handled differently from other window
// properties when building the runtime type library, as the whole module
// is flattened into a single namespace.
Expand All @@ -64,6 +58,7 @@ window.clearInterval = timers.clearTimer;
window.console = new consoleTypes.Console(libdeno.print);
window.setTimeout = timers.setTimeout;
window.setInterval = timers.setInterval;
// tslint:disable-next-line:no-any
window.location = (undefined as any) as domTypes.Location;

// When creating the runtime type library, we use modifications to `window` to
Expand Down
8 changes: 7 additions & 1 deletion js/location.ts
Expand Up @@ -2,12 +2,18 @@
import { URL } from "./url";
import { notImplemented } from "./util";
import { Location } from "./dom_types";
import { window } from "./globals";

// See also setLocation() in globals.ts

export function setLocation(url: string): void {
window.location = new LocationImpl(url);
Object.freeze(window.location);
}

export class LocationImpl implements Location {
constructor(url: string) {
let u = new URL(url);
const u = new URL(url);
this.url = u;
this.hash = u.hash;
this.host = u.host;
Expand Down
12 changes: 9 additions & 3 deletions js/main.ts
Expand Up @@ -4,11 +4,12 @@

import "./globals";

import { log } from "./util";
import { assert, log } from "./util";
import * as os from "./os";
import { libdeno } from "./libdeno";
import { args } from "./deno";
import { replLoop } from "./repl";
import { setLocation } from "./location";

// builtin modules
import * as deno from "./deno";
Expand Down Expand Up @@ -40,6 +41,12 @@ export default function denoMain() {
os.exit(0);
}

const mainModule = startResMsg.mainModule();
if (mainModule) {
assert(mainModule.length > 0);
setLocation(mainModule);
}

const cwd = startResMsg.cwd();
log("cwd", cwd);

Expand All @@ -49,8 +56,7 @@ export default function denoMain() {
log("args", args);
Object.freeze(args);

const inputFn = startResMsg.mainModule();
if (!inputFn) {
if (!mainModule) {
replLoop();
}
}
7 changes: 0 additions & 7 deletions js/os.ts
Expand Up @@ -5,7 +5,6 @@ import * as flatbuffers from "./flatbuffers";
import { libdeno } from "./libdeno";
import { assert } from "./util";
import * as util from "./util";
import { setLocation } from "./globals";

/** The current process id of the runtime. */
export let pid: number;
Expand Down Expand Up @@ -190,12 +189,6 @@ export function start(source?: string): msg.StartRes {

util.setLogDebug(startResMsg.debugFlag(), source);

const mainModule = startResMsg.mainModule();
if (mainModule) {
assert(mainModule.length > 0);
setLocation(mainModule);
}

setGlobals(startResMsg.pid(), startResMsg.noColor());

return startResMsg;
Expand Down

0 comments on commit 95114d9

Please sign in to comment.