mirror of https://github.com/sveltejs/svelte
use anchors for slotted content - fixes #822
parent
5255957692
commit
975a974578
@ -1,5 +1,7 @@
|
|||||||
|
import { DomGenerator } from '../../index';
|
||||||
import { Node } from '../../../../interfaces';
|
import { Node } from '../../../../interfaces';
|
||||||
|
|
||||||
export default function isDomNode(node: Node) {
|
export default function isDomNode(node: Node, generator: DomGenerator) {
|
||||||
return node.type === 'Element' || node.type === 'Text' || node.type === 'MustacheTag';
|
if (node.type === 'Element') return !generator.components.has(node.name);
|
||||||
|
return node.type === 'Text' || node.type === 'MustacheTag';
|
||||||
}
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
<slot/>
|
||||||
|
</div>
|
@ -0,0 +1,16 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<div>
|
||||||
|
<p>unconditional</p>
|
||||||
|
</div>`,
|
||||||
|
|
||||||
|
test(assert, component, target) {
|
||||||
|
component.set({ foo: true });
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<div>
|
||||||
|
<p>unconditional</p>
|
||||||
|
<p>conditional</p>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,17 @@
|
|||||||
|
<Nested>
|
||||||
|
<p>unconditional</p>
|
||||||
|
|
||||||
|
{{#if foo}}
|
||||||
|
<p>conditional</p>
|
||||||
|
{{/if}}
|
||||||
|
</Nested>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Nested from './Nested.html';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
Nested
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in new issue