-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: style directive not updating when style attribute is present and…
… style directive is updated via an object prop. fixes #9185 (#9187) fixes #9185. I narrowed down the issue to the bug surfacing when we use object properties to update style attributes and directives. This fix removes the size check (because a single object will be of size 1 but can affect n attributes/directives via its properties). In addition, the order of the OR is switched as the earlier condition has some reactive assignments which are not run in the current order when style_changed_var is truthy.
- Loading branch information
Showing
4 changed files
with
38 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: update style directive when style attribute is present and is updated via an object prop |
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
...ages/svelte/test/runtime/samples/inline-style-directive-update-object-property/_config.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 { | ||
html: ` | ||
<p style="background-color: green; font-size: 12px;"></p> | ||
`, | ||
|
||
test({ assert, target, window, component }) { | ||
const p = target.querySelector('p'); | ||
const styles = window.getComputedStyle(p); | ||
assert.equal(styles.backgroundColor, 'green'); | ||
assert.equal(styles.fontSize, '12px'); | ||
|
||
{ | ||
component.modify = true; | ||
const p = target.querySelector('p'); | ||
const styles = window.getComputedStyle(p); | ||
assert.equal(styles.backgroundColor, 'green'); | ||
assert.equal(styles.fontSize, '50px'); | ||
} | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
...ges/svelte/test/runtime/samples/inline-style-directive-update-object-property/main.svelte
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,12 @@ | ||
<script> | ||
let settings = { | ||
fontSize: 12, | ||
bg: 'green' | ||
}; | ||
export let modify = false; | ||
$: if (modify) { | ||
settings.fontSize = 50; | ||
} | ||
</script> | ||
|
||
<p style:font-size="{settings.fontSize}px" style="background-color: {settings.bg}" /> |