mirror of https://github.com/sveltejs/svelte
dont slot elements inside custom elements - fixes #827
parent
5ed74df4d3
commit
3879d52616
@ -0,0 +1,13 @@
|
||||
import { Node } from '../../../interfaces';
|
||||
import Generator from '../../Generator';
|
||||
|
||||
export default function isChildOfComponent(node: Node, generator: Generator) {
|
||||
while (node = node.parent) {
|
||||
if (node.type !== 'Element') continue;
|
||||
if (generator.components.has(node.name)) return true;
|
||||
if (/-/.test(node.name)) return false;
|
||||
}
|
||||
|
||||
// TODO do this in validation
|
||||
throw new Error(`Element with a slot='...' attribute must be a descendant of a component or custom element`);
|
||||
}
|
Loading…
Reference in new issue