Skip to content

Commit

Permalink
fix(context): resolve publicPath (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhaenisch authored and manucorporat committed May 16, 2019
1 parent 3cf39fd commit 15bf6e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/runtime/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getContext = (_elm: HTMLElement, context: string) => {
return doc;
} else if (context === 'isServer') {
return BUILD.hydrateServerSide;
} else if (context === 'resourcesUrl') {
} else if (context === 'resourcesUrl' || context === 'publicPath') {
return getAssetPath('.');
} else if (context === 'queue') {
return {
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/test/context.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('context', () => {
@Prop({ context: 'document' }) doc: Document;
@Prop({ context: 'isServer' }) isServer: boolean;
@Prop({ context: 'resourcesUrl' }) resourcesUrl: string;
@Prop({ context: 'publicPath' }) publicPath: string;
@Prop({ context: 'queue' }) queue: QueueApi;
}
const {win, doc, rootInstance} = await newSpecPage({
Expand All @@ -24,6 +25,7 @@ describe('context', () => {
expect(rootInstance.win).toEqual(win);
expect(rootInstance.doc).toEqual(doc);
expect(rootInstance.resourcesUrl).toEqual('/');
expect(rootInstance.publicPath).toEqual('/');
expect(rootInstance.queue.write).toEqual(writeTask);
expect(rootInstance.queue.read).toEqual(readTask);
expect(rootInstance.queue.tick).not.toBeUndefined();
Expand All @@ -35,15 +37,18 @@ describe('context', () => {
})
class CmpA {
@Prop({ context: 'resourcesUrl' }) resourcesUrl: boolean;
@Prop({ context: 'publicPath' }) publicPath: boolean;
}
const {rootInstance} = await newSpecPage({
components: [CmpA],
html: `<cmp-a></cmp-a>`,
context: {
resourcesUrl: '/blabla'
resourcesUrl: '/blabla',
publicPath: '/blubblub'
}
});
expect(rootInstance.resourcesUrl).toEqual('/blabla');
expect(rootInstance.publicPath).toEqual('/blubblub');
});

it('should extend context', async () => {
Expand Down

0 comments on commit 15bf6e5

Please sign in to comment.