mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
add CSS scoping classes when stringifying child nodes - fixes #1223
This commit is contained in:
parent
dc4fdcf77e
commit
eae98f952d
@ -438,8 +438,8 @@ export default class Element extends Node {
|
||||
}
|
||||
|
||||
node.attributes.forEach((attr: Node) => {
|
||||
const value = node._needsCssAttribute && attr.name === 'class'
|
||||
? attr.value.concat({ type: 'Text', data: ` ${generator.stylesheet.id}` })
|
||||
const value = (node._needsCssAttribute && attr.name === 'class')
|
||||
? [{ type: 'Text', data: `${attr.value[0].data} ${generator.stylesheet.id}` }]
|
||||
: attr.value;
|
||||
|
||||
open += ` ${fixAttributeCasing(attr.name)}${stringifyAttributeValue(value)}`
|
||||
|
7
test/css/samples/cascade-false-nested/_config.js
Normal file
7
test/css/samples/cascade-false-nested/_config.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default {
|
||||
cascade: false,
|
||||
|
||||
data: {
|
||||
dynamic: 'x'
|
||||
}
|
||||
};
|
1
test/css/samples/cascade-false-nested/expected.css
Normal file
1
test/css/samples/cascade-false-nested/expected.css
Normal file
@ -0,0 +1 @@
|
||||
.foo.svelte-xyz{color:red}.bar.svelte-xyz{font-style:italic}
|
2
test/css/samples/cascade-false-nested/expected.html
Normal file
2
test/css/samples/cascade-false-nested/expected.html
Normal file
@ -0,0 +1,2 @@
|
||||
<span class="foo svelte-xyz"><span class="bar svelte-xyz">text</span></span>
|
||||
<span class="foo svelte-xyz"><span class="bar svelte-xyz">x</span></span>
|
16
test/css/samples/cascade-false-nested/input.html
Normal file
16
test/css/samples/cascade-false-nested/input.html
Normal file
@ -0,0 +1,16 @@
|
||||
<span class='foo'>
|
||||
<span class='bar'>text</span>
|
||||
</span>
|
||||
|
||||
<span class='foo'>
|
||||
<span class='bar'>{{dynamic}}</span>
|
||||
</span>
|
||||
|
||||
<style>
|
||||
.foo {
|
||||
color: red;
|
||||
}
|
||||
.bar {
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user