-
-
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.
important modifier for style directive
- Loading branch information
Showing
16 changed files
with
194 additions
and
7 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
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
1 change: 1 addition & 0 deletions
1
test/parser/samples/attribute-style-directive-modifiers/input.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 @@ | ||
<div style:color|important={myColor}></div> |
50 changes: 50 additions & 0 deletions
50
test/parser/samples/attribute-style-directive-modifiers/output.json
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,50 @@ | ||
{ | ||
"html": { | ||
"start": 0, | ||
"end": 43, | ||
"type": "Fragment", | ||
"children": [ | ||
{ | ||
"start": 0, | ||
"end": 43, | ||
"type": "Element", | ||
"name": "div", | ||
"attributes": [ | ||
{ | ||
"start": 5, | ||
"end": 36, | ||
"type": "StyleDirective", | ||
"name": "color", | ||
"modifiers": [ | ||
"important" | ||
], | ||
"value": [ | ||
{ | ||
"start": 27, | ||
"end": 36, | ||
"type": "MustacheTag", | ||
"expression": { | ||
"type": "Identifier", | ||
"start": 28, | ||
"end": 35, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 28 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 35 | ||
} | ||
}, | ||
"name": "myColor" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"children": [] | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"end": 26, | ||
"type": "StyleDirective", | ||
"name": "color", | ||
"modifiers": [], | ||
"value": [ | ||
{ | ||
"start": 17, | ||
|
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
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 !important;">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> | ||
`, | ||
|
||
test({ assert, target, window, component }) { | ||
const h1s = target.querySelectorAll('h1'); | ||
|
||
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)'); | ||
|
||
component.color = 'yellow'; | ||
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, 255, 0)'); | ||
} | ||
}; |
13 changes: 13 additions & 0 deletions
13
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,13 @@ | ||
<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|important="{color}">hello</h1> | ||
|
||
<style> | ||
h1 { | ||
background-color: blue !important; | ||
} | ||
</style> |
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
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 !important;">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> | ||
`, | ||
skip: true, | ||
test({ assert, target, window, component }) { | ||
const h1s = target.querySelectorAll('h1'); | ||
|
||
assert.equal(window.getComputedStyle(h1s[0])['backgroundColor'], 'blue'); // TODO: This should be blue but ends up being red | ||
assert.equal(window.getComputedStyle(h1s[1])['backgroundColor'], 'blue'); | ||
assert.equal(window.getComputedStyle(h1s[2])['backgroundColor'], 'red'); | ||
|
||
component.color = 'yellow'; | ||
assert.equal(window.getComputedStyle(h1s[0])['backgroundColor'], 'blue'); | ||
assert.equal(window.getComputedStyle(h1s[1])['backgroundColor'], 'blue'); | ||
assert.equal(window.getComputedStyle(h1s[2])['backgroundColor'], 'yellow'); | ||
} | ||
}; |
13 changes: 13 additions & 0 deletions
13
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,13 @@ | ||
<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|important="{color}">hello</h1> | ||
|
||
<style> | ||
h1 { | ||
background-color: blue !important; | ||
} | ||
</style> |
15 changes: 15 additions & 0 deletions
15
test/validator/samples/style-directive-modifiers-invalid/errors.json
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 @@ | ||
[{ | ||
"message": "Valid modifiers for style directives are: important", | ||
"code": "invalid-style-directive-modifier", | ||
"start": { | ||
"line": 1, | ||
"column": 8, | ||
"character": 8 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 29, | ||
"character": 29 | ||
}, | ||
"pos": 8 | ||
}] |
1 change: 1 addition & 0 deletions
1
test/validator/samples/style-directive-modifiers-invalid/input.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 @@ | ||
<button style:color|bad='red'></button> |