-
Notifications
You must be signed in to change notification settings - Fork 439
wire api fix #5294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
wire api fix #5294
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
86d466e
fix: test for wire invocation order
jhefferman-sfdc ab43d99
fix: added wired method invocation test
jhefferman-sfdc 451179c
feat: api + wire test
jhefferman-sfdc f3b7ec7
fix: api/wire invocation order
jhefferman-sfdc fe623d3
chore: remove .only
jhefferman-sfdc 41d8273
chore: typo and .only
jhefferman-sfdc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...ges/@lwc/engine-server/src/__tests__/fixtures/wire/invocation-sequence/method/config.json
This file contains hidden or 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 @@ | ||
| { | ||
| "entry": "x/parent" | ||
| } |
Empty file.
20 changes: 20 additions & 0 deletions
20
...s/@lwc/engine-server/src/__tests__/fixtures/wire/invocation-sequence/method/expected.html
This file contains hidden or 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,20 @@ | ||
| <fixture-test> | ||
| <template shadowrootmode="open"> | ||
| <x-wire> | ||
| <template shadowrootmode="open"> | ||
| <div> | ||
| Invocation sequence: | ||
| 1. component: setApiValue(parent provided (initial) value) | ||
| 2. adapter: connect() | ||
| 3. component: getApiValue(parent provided (initial) value) | ||
| 4. adapter: update() | ||
| 5. component: wiredMethod(wire provided value) | ||
| 6. component: setApiValue(wire provided value) | ||
| </div> | ||
| <div> | ||
| Api Value: wire provided value | ||
| </div> | ||
| </template> | ||
| </x-wire> | ||
| </template> | ||
| </fixture-test> |
3 changes: 3 additions & 0 deletions
3
...erver/src/__tests__/fixtures/wire/invocation-sequence/method/modules/x/parent/parent.html
This file contains hidden or 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> | ||
| <x-wire api-value={apiValue}></x-wire> | ||
| </template> |
5 changes: 5 additions & 0 deletions
5
...-server/src/__tests__/fixtures/wire/invocation-sequence/method/modules/x/parent/parent.js
This file contains hidden or 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 Parent extends LightningElement { | ||
| apiValue = 'parent provided (initial) value'; | ||
| } |
18 changes: 18 additions & 0 deletions
18
...e-server/src/__tests__/fixtures/wire/invocation-sequence/method/modules/x/wire/adapter.js
This file contains hidden or 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,18 @@ | ||
| export let invocationSequence = []; | ||
|
|
||
| export class adapter { | ||
| constructor(dataCallback) { | ||
| this.dc = dataCallback; | ||
| } | ||
|
|
||
| connect() { | ||
| invocationSequence.push('adapter: connect()'); | ||
| } | ||
|
|
||
| update() { | ||
| invocationSequence.push('adapter: update()'); | ||
| this.dc('wire provided value'); | ||
| } | ||
|
|
||
| disconnect() {} | ||
| } |
4 changes: 4 additions & 0 deletions
4
...ne-server/src/__tests__/fixtures/wire/invocation-sequence/method/modules/x/wire/wire.html
This file contains hidden or 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,4 @@ | ||
| <template> | ||
| <div>Invocation sequence: {invocationSequence}</div> | ||
| <div>Api Value: {apiValue}</div> | ||
| </template> |
26 changes: 26 additions & 0 deletions
26
...gine-server/src/__tests__/fixtures/wire/invocation-sequence/method/modules/x/wire/wire.js
This file contains hidden or 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,26 @@ | ||
| import { LightningElement, wire, api } from 'lwc'; | ||
|
|
||
| import { adapter, invocationSequence } from './adapter'; | ||
|
|
||
| export default class Wire extends LightningElement { | ||
| @api | ||
| set apiValue(value) { | ||
| invocationSequence.push(`component: setApiValue(${value})`); | ||
| this._apiValue = value; | ||
| } | ||
|
|
||
| get apiValue() { | ||
| invocationSequence.push(`component: getApiValue(${this._apiValue})`); | ||
| return this._apiValue; | ||
| } | ||
|
|
||
| @wire(adapter, { apiValue: '$apiValue' }) | ||
| wiredMethod(value) { | ||
| invocationSequence.push(`component: wiredMethod(${value})`); | ||
| this.apiValue = value; | ||
| } | ||
|
|
||
| get invocationSequence() { | ||
| return invocationSequence.map((invocation, i) => `\n ${i + 1}. ${invocation}`).join(''); | ||
| } | ||
| } |
Empty file.
3 changes: 3 additions & 0 deletions
3
packages/@lwc/engine-server/src/__tests__/fixtures/wire/invocation-sequence/prop/config.json
This file contains hidden or 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 @@ | ||
| { | ||
| "entry": "x/wire" | ||
| } |
Empty file.
12 changes: 12 additions & 0 deletions
12
...ges/@lwc/engine-server/src/__tests__/fixtures/wire/invocation-sequence/prop/expected.html
This file contains hidden or 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,12 @@ | ||
| <fixture-test> | ||
| <template shadowrootmode="open"> | ||
| <div> | ||
| Wire adapter invocation sequence: | ||
| 1. adaptor connect() | ||
| 2. adaptor update() | ||
| </div> | ||
| <div> | ||
| Wired prop: true | ||
| </div> | ||
| </template> | ||
| </fixture-test> | ||
18 changes: 18 additions & 0 deletions
18
...ine-server/src/__tests__/fixtures/wire/invocation-sequence/prop/modules/x/wire/adapter.js
This file contains hidden or 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,18 @@ | ||
| export let invocationSequence = []; | ||
|
|
||
| export class adapter { | ||
| constructor(dataCallback) { | ||
| this.dc = dataCallback; | ||
| } | ||
|
|
||
| connect() { | ||
| invocationSequence.push('adaptor connect()'); | ||
| } | ||
|
|
||
| update() { | ||
| invocationSequence.push('adaptor update()'); | ||
| this.dc(true); | ||
| } | ||
|
|
||
| disconnect() {} | ||
| } |
4 changes: 4 additions & 0 deletions
4
...gine-server/src/__tests__/fixtures/wire/invocation-sequence/prop/modules/x/wire/wire.html
This file contains hidden or 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,4 @@ | ||
| <template> | ||
| <div>Wire adapter invocation sequence: {invocationSequence}</div> | ||
| <div>Wired prop: {wiredProp}</div> | ||
| </template> |
12 changes: 12 additions & 0 deletions
12
...engine-server/src/__tests__/fixtures/wire/invocation-sequence/prop/modules/x/wire/wire.js
This file contains hidden or 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,12 @@ | ||
| import { LightningElement, wire } from 'lwc'; | ||
|
|
||
| import { adapter, invocationSequence } from './adapter'; | ||
|
|
||
| export default class Wire extends LightningElement { | ||
| @wire(adapter) | ||
| wiredProp; | ||
|
|
||
| get invocationSequence() { | ||
| return invocationSequence.map((invocation, i) => `\n ${i + 1}. ${invocation}`).join(''); | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -46,7 +46,6 @@ const bGenerateMarkup = esTemplate` | |
| }); | ||
|
|
||
| __establishContextfulRelationship(contextfulParent, instance); | ||
| ${/*connect wire*/ is.statement} | ||
|
|
||
| instance[__SYMBOL__SET_INTERNALS]( | ||
| props, | ||
|
|
@@ -59,6 +58,7 @@ const bGenerateMarkup = esTemplate` | |
| instance.connectedCallback(); | ||
| __mutationTracker.disable(instance); | ||
| } | ||
| ${/*connect wire*/ is.statement} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉🎉🎉 |
||
| // If a render() function is defined on the class or any of its superclasses, then that takes priority. | ||
| // Next, if the class or any of its superclasses has an implicitly-associated template, then that takes | ||
| // second priority (e.g. a foo.html file alongside a foo.js file). Finally, there is a fallback empty template. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.