Skip to content

Commit 9d79013

Browse files
committed
fix(build): fix mode and resourceUrl
1 parent 2022ca5 commit 9d79013

5 files changed

Lines changed: 23 additions & 18 deletions

File tree

src/compiler/app/app-global-scripts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async function wrapGlobalJs(config: Config, compilerCtx: CompilerCtx, buildCtx:
157157
jsContent = await minifyJs(config, compilerCtx, buildCtx.diagnostics, jsContent, sourceTarget, false);
158158
}
159159

160-
return `\n(function(resourcesUrl){${jsContent}\n})(resourcesUrl);\n`;
160+
return `\n(function(Context, resourcesUrl){${jsContent}\n})(x,r);\n`;
161161
}
162162

163163

src/compiler/app/test/app-core.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ describe('app-core', () => {
3535

3636
it('wraps the JS content in an IFEE, arrow function', () => {
3737
const lines = core.wrapCoreJs(config, 'this is JavaScript code, really it is', cmpRegistry, {} as any).split('\n');
38-
expect(lines[1]).toEqual(`((w,d,x,n,h,c,r)=>{"use strict";`);
39-
expect(lines[3]).toEqual('this is JavaScript code, really it is');
40-
expect(lines[4]).toEqual(`})(window,document,{},"${config.namespace}","${config.hydratedCssClass}",[]);`);
38+
expect(lines[1].toString().startsWith(`((w,d,x,n,h,c,r)=>{`)).toBe(true);
39+
expect(lines[2]).toEqual('this is JavaScript code, really it is');
40+
expect(lines[3]).toEqual(`})(window,document,{},"${config.namespace}","${config.hydratedCssClass}",[]);`);
4141
});
4242

4343
it('wraps the JS content in an IFEE, es5', () => {
@@ -50,7 +50,7 @@ describe('app-core', () => {
5050

5151
it('trims the JS content', () => {
5252
const lines = core.wrapCoreJs(config, ' this is JavaScript code, really it is ', cmpRegistry, {} as any).split('\n');
53-
expect(lines[3]).toEqual('this is JavaScript code, really it is');
53+
expect(lines[2]).toEqual('this is JavaScript code, really it is');
5454
});
5555

5656
});

src/core/host-snapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const initHostSnapshot = (domApi: d.DomApi, cmpMeta: d.ComponentMeta, hos
88
// have finished adding attributes and child nodes to the host
99
// before we go all out and hydrate this beast
1010
// let's first take a snapshot of its original layout before render
11-
if (_BUILD_.hasMode && !hostElm.mode) {
11+
if (!hostElm.mode) {
1212
// looks like mode wasn't set as a property directly yet
1313
// first check if there's an attribute
1414
// next check the app's global

src/renderer/dom-api.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export const createDomApi = (App: AppGlobal, win: any, doc: Document): DomApi =>
9292
$hasAttribute: (elm: Element, key) =>
9393
elm.hasAttribute(key),
9494

95+
$getMode: (elm: Element) =>
96+
elm.getAttribute('mode') || (App.Context || {}).mode,
97+
9598
$elementRef: (elm: any, referenceName: string) => {
9699
if (referenceName === 'child') {
97100
return elm.firstElementChild;
@@ -260,11 +263,6 @@ export const createDomApi = (App: AppGlobal, win: any, doc: Document): DomApi =>
260263
domApi.$attachShadow = (elm, shadowRootInit) => elm.attachShadow(shadowRootInit);
261264
}
262265

263-
if (_BUILD_.hasMode) {
264-
domApi.$getMode = (elm: Element) =>
265-
domApi.$getAttribute(elm, 'mode') || (App.Context || {}).mode;
266-
}
267-
268266
if (!App.ael) {
269267
App.ael = (elm, eventName, cb, opts) => elm.addEventListener(eventName, cb, opts);
270268
App.rel = (elm, eventName, cb, opts) => elm.removeEventListener(eventName, cb, opts);

src/util/test/build-conditionals.spec.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ describe('build conditionals', () => {
362362
prop: true,
363363
event: false,
364364
listener: false,
365-
hostTheme: false
365+
hostTheme: false,
366+
updatable: true
366367
});
367368
});
368369

@@ -379,7 +380,8 @@ describe('build conditionals', () => {
379380
propMutable: true,
380381
event: false,
381382
listener: false,
382-
hostTheme: false
383+
hostTheme: false,
384+
updatable: true
383385
});
384386
});
385387

@@ -395,7 +397,8 @@ describe('build conditionals', () => {
395397
state: true,
396398
event: false,
397399
listener: false,
398-
hostTheme: false
400+
hostTheme: false,
401+
updatable: true
399402
});
400403
});
401404

@@ -413,7 +416,8 @@ describe('build conditionals', () => {
413416
event: false,
414417
listener: false,
415418
hostTheme: false,
416-
observeAttr: true
419+
observeAttr: true,
420+
updatable: true
417421
});
418422
});
419423

@@ -431,7 +435,8 @@ describe('build conditionals', () => {
431435
event: false,
432436
listener: false,
433437
hostTheme: false,
434-
observeAttr: true
438+
observeAttr: true,
439+
updatable: true
435440
});
436441
});
437442

@@ -449,7 +454,8 @@ describe('build conditionals', () => {
449454
prop: true,
450455
listener: false,
451456
hostTheme: false,
452-
observeAttr: true
457+
observeAttr: true,
458+
updatable: true
453459
});
454460
});
455461

@@ -467,7 +473,8 @@ describe('build conditionals', () => {
467473
event: false,
468474
listener: false,
469475
hostTheme: false,
470-
observeAttr: true
476+
observeAttr: true,
477+
updatable: true
471478
});
472479
});
473480

0 commit comments

Comments
 (0)