Skip to content

Commit 15bf6e5

Browse files
simonhaenischmanucorporat
authored andcommitted
fix(context): resolve publicPath (#1536)
1 parent 3cf39fd commit 15bf6e5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/runtime/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const getContext = (_elm: HTMLElement, context: string) => {
1111
return doc;
1212
} else if (context === 'isServer') {
1313
return BUILD.hydrateServerSide;
14-
} else if (context === 'resourcesUrl') {
14+
} else if (context === 'resourcesUrl' || context === 'publicPath') {
1515
return getAssetPath('.');
1616
} else if (context === 'queue') {
1717
return {

src/runtime/test/context.spec.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('context', () => {
1414
@Prop({ context: 'document' }) doc: Document;
1515
@Prop({ context: 'isServer' }) isServer: boolean;
1616
@Prop({ context: 'resourcesUrl' }) resourcesUrl: string;
17+
@Prop({ context: 'publicPath' }) publicPath: string;
1718
@Prop({ context: 'queue' }) queue: QueueApi;
1819
}
1920
const {win, doc, rootInstance} = await newSpecPage({
@@ -24,6 +25,7 @@ describe('context', () => {
2425
expect(rootInstance.win).toEqual(win);
2526
expect(rootInstance.doc).toEqual(doc);
2627
expect(rootInstance.resourcesUrl).toEqual('/');
28+
expect(rootInstance.publicPath).toEqual('/');
2729
expect(rootInstance.queue.write).toEqual(writeTask);
2830
expect(rootInstance.queue.read).toEqual(readTask);
2931
expect(rootInstance.queue.tick).not.toBeUndefined();
@@ -35,15 +37,18 @@ describe('context', () => {
3537
})
3638
class CmpA {
3739
@Prop({ context: 'resourcesUrl' }) resourcesUrl: boolean;
40+
@Prop({ context: 'publicPath' }) publicPath: boolean;
3841
}
3942
const {rootInstance} = await newSpecPage({
4043
components: [CmpA],
4144
html: `<cmp-a></cmp-a>`,
4245
context: {
43-
resourcesUrl: '/blabla'
46+
resourcesUrl: '/blabla',
47+
publicPath: '/blubblub'
4448
}
4549
});
4650
expect(rootInstance.resourcesUrl).toEqual('/blabla');
51+
expect(rootInstance.publicPath).toEqual('/blubblub');
4752
});
4853

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

0 commit comments

Comments
 (0)