-
Notifications
You must be signed in to change notification settings - Fork 398
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 context providers work again (#5004)
Co-authored-by: John Hefferman <[email protected]> Co-authored-by: Nolan Lawson <[email protected]>
- Loading branch information
1 parent
6b40dc6
commit 7701069
Showing
38 changed files
with
234 additions
and
14 deletions.
There are no files selected for viewing
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
packages/@lwc/engine-server/src/__tests__/fixtures/context-slotted/light/expected.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,11 @@ | ||
<x-root> | ||
<x-provider> | ||
<!----> | ||
<x-consumer> | ||
<div> | ||
some context | ||
</div> | ||
</x-consumer> | ||
<!----> | ||
</x-provider> | ||
</x-root> |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...gine-server/src/__tests__/fixtures/context-slotted/light/modules/x/consumer/consumer.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,3 @@ | ||
<template lwc:render-mode="light"> | ||
<div>{foo}</div> | ||
</template> |
7 changes: 7 additions & 0 deletions
7
...engine-server/src/__tests__/fixtures/context-slotted/light/modules/x/consumer/consumer.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,7 @@ | ||
import { LightningElement, wire } from 'lwc'; | ||
import { WireAdapter } from '../../../wire-adapter'; | ||
|
||
export default class SlottedConsumerComponent extends LightningElement { | ||
static renderMode = 'light'; | ||
@wire(WireAdapter) foo; | ||
} |
3 changes: 3 additions & 0 deletions
3
...gine-server/src/__tests__/fixtures/context-slotted/light/modules/x/provider/provider.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,3 @@ | ||
<template lwc:render-mode="light"> | ||
<slot></slot> | ||
</template> |
15 changes: 15 additions & 0 deletions
15
...engine-server/src/__tests__/fixtures/context-slotted/light/modules/x/provider/provider.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,15 @@ | ||
import { LightningElement } from 'lwc'; | ||
import { contextualizer } from '../../../wire-adapter'; | ||
|
||
export default class ProviderComponent extends LightningElement { | ||
static renderMode = 'light'; | ||
connectedCallback() { | ||
contextualizer(this, { | ||
consumerConnectedCallback(consumer) { | ||
consumer.provide({ | ||
value: 'some context', | ||
}); | ||
}, | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.../@lwc/engine-server/src/__tests__/fixtures/context-slotted/light/modules/x/root/root.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,5 @@ | ||
<template lwc:render-mode="light"> | ||
<x-provider> | ||
<x-consumer></x-consumer> | ||
</x-provider> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...es/@lwc/engine-server/src/__tests__/fixtures/context-slotted/light/modules/x/root/root.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,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Rootcomponent extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
File renamed without changes.
Empty file.
16 changes: 16 additions & 0 deletions
16
packages/@lwc/engine-server/src/__tests__/fixtures/context-slotted/scoped/expected.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-root> | ||
<x-provider> | ||
<!----> | ||
<!----> | ||
<x-consumer> | ||
<span> | ||
some context | ||
</span> | ||
</x-consumer> | ||
<span> | ||
id - name | ||
</span> | ||
<!----> | ||
<!----> | ||
</x-provider> | ||
</x-root> |
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/context-slotted/scoped/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-root'; | ||
export { default } from 'x/root'; | ||
export * from 'x/root'; |
3 changes: 3 additions & 0 deletions
3
...ine-server/src/__tests__/fixtures/context-slotted/scoped/modules/x/consumer/consumer.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,3 @@ | ||
<template lwc:render-mode="light"> | ||
<span>{foo}</span> | ||
</template> |
7 changes: 7 additions & 0 deletions
7
...ngine-server/src/__tests__/fixtures/context-slotted/scoped/modules/x/consumer/consumer.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,7 @@ | ||
import { LightningElement, wire } from 'lwc'; | ||
import { WireAdapter } from '../../../wire-adapter'; | ||
|
||
export default class SlottedConsumerComponent extends LightningElement { | ||
static renderMode = 'light'; | ||
@wire(WireAdapter) foo; | ||
} |
3 changes: 3 additions & 0 deletions
3
...ine-server/src/__tests__/fixtures/context-slotted/scoped/modules/x/provider/provider.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,3 @@ | ||
<template lwc:render-mode="light"> | ||
<slot lwc:slot-bind={item}></slot> | ||
</template> |
19 changes: 19 additions & 0 deletions
19
...ngine-server/src/__tests__/fixtures/context-slotted/scoped/modules/x/provider/provider.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,19 @@ | ||
import { LightningElement } from 'lwc'; | ||
import { contextualizer } from '../../../wire-adapter'; | ||
|
||
export default class ProviderComponent extends LightningElement { | ||
static renderMode = 'light'; | ||
item = { | ||
id: 'id', | ||
name: 'name', | ||
}; | ||
connectedCallback() { | ||
contextualizer(this, { | ||
consumerConnectedCallback(consumer) { | ||
consumer.provide({ | ||
value: 'some context', | ||
}); | ||
}, | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...@lwc/engine-server/src/__tests__/fixtures/context-slotted/scoped/modules/x/root/root.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,8 @@ | ||
<template lwc:render-mode="light"> | ||
<x-provider> | ||
<template lwc:slot-data="data"> | ||
<x-consumer></x-consumer> | ||
<span>{data.id} - {data.name}</span> | ||
</template> | ||
</x-provider> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...s/@lwc/engine-server/src/__tests__/fixtures/context-slotted/scoped/modules/x/root/root.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,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Rootcomponent extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/@lwc/engine-server/src/__tests__/fixtures/context-slotted/scoped/wire-adapter.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,30 @@ | ||
import { createContextProvider } from 'lwc'; | ||
|
||
export class WireAdapter { | ||
contextValue = { value: 'missing' }; | ||
static contextSchema = { value: 'required' }; | ||
|
||
constructor(callback) { | ||
this._callback = callback; | ||
} | ||
|
||
connect() { | ||
// noop | ||
} | ||
|
||
disconnect() { | ||
// noop | ||
} | ||
|
||
update(_config, context) { | ||
if (context) { | ||
if (!context.hasOwnProperty('value')) { | ||
throw new Error(`Invalid context provided`); | ||
} | ||
this.contextValue = context.value; | ||
this._callback(this.contextValue); | ||
} | ||
} | ||
} | ||
|
||
export const contextualizer = createContextProvider(WireAdapter); |
Empty file.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/context-slotted/shadow/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-root'; | ||
export { default } from 'x/root'; | ||
export * from 'x/root'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
packages/@lwc/engine-server/src/__tests__/fixtures/context-slotted/shadow/wire-adapter.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,30 @@ | ||
import { createContextProvider } from 'lwc'; | ||
|
||
export class WireAdapter { | ||
contextValue = { value: 'missing' }; | ||
static contextSchema = { value: 'required' }; | ||
|
||
constructor(callback) { | ||
this._callback = callback; | ||
} | ||
|
||
connect() { | ||
// noop | ||
} | ||
|
||
disconnect() { | ||
// noop | ||
} | ||
|
||
update(_config, context) { | ||
if (context) { | ||
if (!context.hasOwnProperty('value')) { | ||
throw new Error(`Invalid context provided`); | ||
} | ||
this.contextValue = context.value; | ||
this._callback(this.contextValue); | ||
} | ||
} | ||
} | ||
|
||
export const contextualizer = createContextProvider(WireAdapter); |
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
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
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
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
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
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
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
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