-
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: skip hydration validation when static parts have static classes (#…
…4278) --------- Co-authored-by: Nolan Lawson <[email protected]>
- Loading branch information
1 parent
752cc83
commit 345c68d
Showing
10 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
...on-karma/test-hydration/mismatches/class-attr/static-same-with-static-parts/index.spec.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,20 @@ | ||
export default { | ||
props: { | ||
s1: 's1', | ||
}, | ||
snapshot(target) { | ||
const p = target.shadowRoot.querySelector('p'); | ||
return { | ||
p, | ||
classes: p.className, | ||
}; | ||
}, | ||
test(target, snapshots, consoleCalls) { | ||
const p = target.shadowRoot.querySelector('p'); | ||
|
||
expect(p).toBe(snapshots.p); | ||
expect(p.className).toBe(snapshots.classes); | ||
// static classes are skipped by hydration validation | ||
expect(consoleCalls.error).toHaveSize(0); | ||
}, | ||
}; |
4 changes: 4 additions & 0 deletions
4
...karma/test-hydration/mismatches/class-attr/static-same-with-static-parts/x/main/main.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,4 @@ | ||
<template> | ||
<!-- presence of a dynamic attribute creates a static part --> | ||
<p class="c1" style={s1}>text</p> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...n-karma/test-hydration/mismatches/class-attr/static-same-with-static-parts/x/main/main.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, api } from 'lwc'; | ||
|
||
export default class Main extends LightningElement { | ||
@api s1; | ||
} |
15 changes: 15 additions & 0 deletions
15
...ges/@lwc/integration-karma/test-hydration/mismatches/class-attr/static-same/index.spec.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 @@ | ||
export default { | ||
snapshot(target) { | ||
const p = target.shadowRoot.querySelector('p'); | ||
return { | ||
p, | ||
classes: p.className, | ||
}; | ||
}, | ||
test(target, snapshots) { | ||
const p = target.shadowRoot.querySelector('p'); | ||
|
||
expect(p).toBe(snapshots.p); | ||
expect(p.className).toBe(snapshots.classes); | ||
}, | ||
}; |
3 changes: 3 additions & 0 deletions
3
.../@lwc/integration-karma/test-hydration/mismatches/class-attr/static-same/x/main/main.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> | ||
<p class="c1">text</p> | ||
</template> |
3 changes: 3 additions & 0 deletions
3
...es/@lwc/integration-karma/test-hydration/mismatches/class-attr/static-same/x/main/main.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 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Main extends LightningElement {} |
20 changes: 20 additions & 0 deletions
20
...on-karma/test-hydration/mismatches/style-attr/static/same-with-static-parts/index.spec.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,20 @@ | ||
export default { | ||
props: { | ||
c1: 'c1', | ||
}, | ||
snapshot(target) { | ||
const p = target.shadowRoot.querySelector('p'); | ||
return { | ||
p, | ||
style: p.getAttribute('style'), | ||
}; | ||
}, | ||
test(target, snapshots, consoleCalls) { | ||
const p = target.shadowRoot.querySelector('p'); | ||
|
||
expect(p).toBe(snapshots.p); | ||
expect(p.getAttribute('style')).toBe(snapshots.style); | ||
// static classes are skipped by hydration validation | ||
expect(consoleCalls.error).toHaveSize(0); | ||
}, | ||
}; |
4 changes: 4 additions & 0 deletions
4
...karma/test-hydration/mismatches/style-attr/static/same-with-static-parts/x/main/main.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,4 @@ | ||
<template> | ||
<!-- presence of a dynamic attribute creates a static part --> | ||
<p class={c1} style="background: blue">text</p> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...n-karma/test-hydration/mismatches/style-attr/static/same-with-static-parts/x/main/main.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, api } from 'lwc'; | ||
|
||
export default class Main extends LightningElement { | ||
@api c1; | ||
} |