handle ~= attribute selector operator

pull/689/head
Rich Harris 7 years ago
parent 74d15ea877
commit 3dfe92b54f

@ -134,6 +134,10 @@ function attributeMatches(node: Node, selector: Node) {
return actualValue === expectedValue;
}
if(selector.operator === '~=') {
return actualValue.split(/\s/).indexOf(expectedValue) !== -1;
}
return true;
}

@ -0,0 +1,6 @@
export default {
cascade: false,
data: {
dynamic: 'whatever'
}
};

@ -0,0 +1,2 @@
<div><p svelte-25731322="" data-foo="whatever">this is styled</p>
<p data-foo="qux baz">this is unstyled</p></div>

@ -0,0 +1,10 @@
<div>
<p data-foo='{{dynamic}}'>this is styled</p>
<p data-foo='qux baz'>this is unstyled</p>
</div>
<style>
[data-foo~='bar'] {
color: red;
}
</style>

@ -0,0 +1,4 @@
[data-foo~='bar'][svelte-1786044856] {
color: red;
}

@ -0,0 +1,2 @@
<div><p svelte-1786044856="" data-foo="qux bar">this is styled</p>
<p data-foo="qux baz">this is unstyled</p></div>

@ -0,0 +1,10 @@
<div>
<p data-foo='qux bar'>this is styled</p>
<p data-foo='qux baz'>this is unstyled</p>
</div>
<style>
[data-foo~='bar'] {
color: red;
}
</style>
Loading…
Cancel
Save