-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): make internals non-configurable (#5208)
* fix(ssr): make internals non-configurable * test(ssr): add check that internals are safe * chore: remove rogue file * chore: use correct file extension for test output
- Loading branch information
Showing
9 changed files
with
125 additions
and
44 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/@lwc/engine-server/src/__tests__/fixtures/ssr-internals/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ssrFiles": { | ||
"error": "error-ssr.txt", | ||
"expected": "expected-ssr.html" | ||
} | ||
} |
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions
16
packages/@lwc/engine-server/src/__tests__/fixtures/ssr-internals/expected-ssr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<x-component> | ||
<template shadowrootmode="open"> | ||
<p> | ||
this only matters for ssr-compiler; engine-server does not have the same internals | ||
</p> | ||
<p> | ||
generateMarkup overridden: false | ||
</p> | ||
<p> | ||
tmpl overridden: false | ||
</p> | ||
<p> | ||
public props overridden: false | ||
</p> | ||
</template> | ||
</x-component> |
Empty file.
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/ssr-internals/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-component'; | ||
export { default } from 'x/component'; | ||
export * from 'x/component'; |
6 changes: 6 additions & 0 deletions
6
...lwc/engine-server/src/__tests__/fixtures/ssr-internals/modules/x/component/component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<p>this only matters for ssr-compiler; engine-server does not have the same internals</p> | ||
<p>generateMarkup overridden: {isGenerateMarkupOverridden}</p> | ||
<p>tmpl overridden: {isTmplOverridden}</p> | ||
<p>public props overridden: {isPublicPropsOverridden}</p> | ||
</template> |
24 changes: 24 additions & 0 deletions
24
.../@lwc/engine-server/src/__tests__/fixtures/ssr-internals/modules/x/component/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { LightningElement } from 'lwc'; | ||
import { SYMBOL__DEFAULT_TEMPLATE, SYMBOL__GENERATE_MARKUP } from '@lwc/ssr-runtime'; | ||
|
||
const myGenerateMarkup = () => '<p>hili</p>'; | ||
const myPublicProperties = ['philip']; | ||
const myTmpl = () => { | ||
throw new Error('PHILIP'); | ||
}; | ||
|
||
export default class Component extends LightningElement { | ||
static [SYMBOL__DEFAULT_TEMPLATE] = myTmpl; | ||
static [SYMBOL__GENERATE_MARKUP] = myGenerateMarkup; | ||
static ['__lwcPublicProperties__'] = myPublicProperties; | ||
|
||
get isGenerateMarkupOverridden() { | ||
return Component[SYMBOL__DEFAULT_TEMPLATE] === myGenerateMarkup; | ||
} | ||
get isTmplOverridden() { | ||
return Component[SYMBOL__GENERATE_MARKUP] === myTmpl; | ||
} | ||
get isPublicPropsOverridden() { | ||
return Component['__lwcPublicProperties__'] === myPublicProperties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters