0
0
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:
Rich Harris 2018-03-12 11:25:11 -04:00
parent dc4fdcf77e
commit eae98f952d
5 changed files with 28 additions and 2 deletions

View File

@ -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)}`

View File

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

View File

@ -0,0 +1 @@
.foo.svelte-xyz{color:red}.bar.svelte-xyz{font-style:italic}

View 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>

View 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>