mirror of https://github.com/sveltejs/svelte
parent
6ac7038e47
commit
a2e1f6f2b6
@ -0,0 +1 @@
|
||||
<div style:color|important={myColor}></div>
|
||||
@ -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": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -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)');
|
||||
}
|
||||
};
|
||||
@ -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>
|
||||
@ -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');
|
||||
}
|
||||
};
|
||||
@ -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>
|
||||
@ -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
|
||||
}]
|
||||
@ -0,0 +1 @@
|
||||
<button style:color|bad='red'></button>
|
||||
Loading…
Reference in new issue