-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support !important in style directive
- Loading branch information
Showing
7 changed files
with
111 additions
and
4 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
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
34 changes: 34 additions & 0 deletions
34
test/runtime-puppeteer/samples/inline-style-directive-important/_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,34 @@ | ||
export default { | ||
html: ` | ||
<h1 class="svelte-udf14z" style="background-color: red;">hello</h1> | ||
<h1 class="svelte-udf14z">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red !important;">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red !important;">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red !important;">hello</h1> | ||
<h2 class="svelte-udf14z" style="--background-color:red;">hello</h2> | ||
<h2 class="svelte-udf14z" style="--background-color:red !important;">hello</h2> | ||
`, | ||
|
||
ssrHtml: ` | ||
<h1 class="svelte-udf14z" style="background-color: red;">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red important;">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red !important;">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red !important;">hello</h1> | ||
<h1 class="svelte-udf14z" style="background-color: red !important">hello</h1> | ||
<h2 class="svelte-udf14z" style="--background-color: red;">hello</h2> | ||
<h2 class="svelte-udf14z" style="--background-color: red !important;">hello</h2> | ||
`, | ||
|
||
test({ assert, target, window }) { | ||
const h1s = target.querySelectorAll('h1'); | ||
const h2s = target.querySelectorAll('h2'); | ||
|
||
assert.equal(window.getComputedStyle(h1s[0])['backgroundColor'], 'rgb(0, 0, 255)'); | ||
assert.equal(window.getComputedStyle(h1s[1])['backgroundColor'], 'rgb(0, 0, 255)'); | ||
assert.equal(window.getComputedStyle(h1s[2])['backgroundColor'], 'rgb(255, 0, 0)'); | ||
assert.equal(window.getComputedStyle(h1s[3])['backgroundColor'], 'rgb(255, 0, 0)'); | ||
assert.equal(window.getComputedStyle(h1s[4])['backgroundColor'], 'rgb(255, 0, 0)'); | ||
assert.equal(window.getComputedStyle(h2s[0])['backgroundColor'], 'rgb(0, 0, 255)'); | ||
assert.equal(window.getComputedStyle(h2s[1])['backgroundColor'], 'rgb(255, 0, 0)'); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
test/runtime-puppeteer/samples/inline-style-directive-important/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,21 @@ | ||
<script> | ||
export let color = 'red' | ||
</script> | ||
|
||
<h1 style:background-color={color} >hello</h1> | ||
<h1 style:background-color="{color} important">hello</h1> | ||
<h1 style:background-color="{color} !important">hello</h1> | ||
<h1 style:background-color="{color} !important;">hello</h1> | ||
<h1 style="background-color: {color} !important">hello</h1> | ||
<h2 style:--background-color={color}>hello</h2> | ||
<h2 style:--background-color="{color} !important;">hello</h2> | ||
|
||
<style> | ||
h1 { | ||
background-color: blue !important; | ||
} | ||
h2 { | ||
--background-color: blue !important; | ||
background-color: var(--background-color); | ||
} | ||
</style> |
27 changes: 27 additions & 0 deletions
27
test/runtime/samples/inline-style-directive-important/_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,27 @@ | ||
export default { | ||
html: ` | ||
<h1 class="svelte-szzkfu" style="background-color: red;">hello</h1> | ||
<h1 class="svelte-szzkfu">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red;">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red;">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red;">hello</h1> | ||
`, | ||
|
||
ssrHtml: ` | ||
<h1 class="svelte-szzkfu" style="background-color: red;">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red important;">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red !important;">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red !important;">hello</h1> | ||
<h1 class="svelte-szzkfu" style="background-color: red !important">hello</h1> | ||
`, | ||
|
||
test({ assert, target, window }) { | ||
const h1s = target.querySelectorAll('h1'); | ||
|
||
assert.equal(window.getComputedStyle(h1s[0])['backgroundColor'], 'red'); | ||
assert.equal(window.getComputedStyle(h1s[1])['backgroundColor'], 'blue'); | ||
assert.equal(window.getComputedStyle(h1s[2])['backgroundColor'], 'red'); | ||
assert.equal(window.getComputedStyle(h1s[3])['backgroundColor'], 'red'); | ||
assert.equal(window.getComputedStyle(h1s[4])['backgroundColor'], 'red'); | ||
} | ||
}; |
15 changes: 15 additions & 0 deletions
15
test/runtime/samples/inline-style-directive-important/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,15 @@ | ||
<script> | ||
export let color = 'red' | ||
</script> | ||
|
||
<h1 style:background-color={color} >hello</h1> | ||
<h1 style:background-color="{color} important">hello</h1> | ||
<h1 style:background-color="{color} !important">hello</h1> | ||
<h1 style:background-color="{color} !important;">hello</h1> | ||
<h1 style="background-color: {color} !important">hello</h1> | ||
|
||
<style> | ||
h1 { | ||
background-color: blue !important; | ||
} | ||
</style> |