Skip to content

Commit

Permalink
fix(runtime): grab location from window
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 29, 2019
1 parent acf0f79 commit 26fd3cf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/import-shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const patchBrowser = async () => {
s.getAttribute('data-namespace') === NAMESPACE
));

const resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, doc.location.href));
const resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href));
patchDynamicImport(resourcesUrl.href);

if (!window.customElements) {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/transformers/test/parse-comments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ describe('parse comments', () => {
'text': '',
},
],
'return': '{}',
'return': 'unknown',
'references': {},
'signature': '(prop: string) => {}',
'signature': '(prop: string) => unknown',
},
'docs': {
'tags': [],
Expand Down
12 changes: 12 additions & 0 deletions src/mock-doc/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ export class MockDocument extends MockElement {
}
}

get location() {
if (this.defaultView != null) {
return (this.defaultView as Window).location;
}
return null;
}
set location(val: Location) {
if (this.defaultView != null) {
(this.defaultView as Window).location = val;
}
}

get baseURI() {
if (this.defaultView != null) {
return (this.defaultView as Window).location.href;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/bootstrap-lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const bootstrapLazy = (lazyBundles: d.LazyBundlesRuntimeData, options: d.
const y = /*@__PURE__*/head.querySelector('meta[charset]');
const visibilityStyle = /*@__PURE__*/doc.createElement('style');
Object.assign(plt, options);
plt.$resourcesUrl$ = new URL(options.resourcesUrl || '/', doc.location.href).href;
plt.$resourcesUrl$ = new URL(options.resourcesUrl || '/', win.location.href).href;
if (options.syncQueue) {
plt.$flags$ |= PLATFORM_FLAGS.queueSync;
}
Expand Down

0 comments on commit 26fd3cf

Please sign in to comment.