parse <slot> as element in custom element mode

pull/1367/head
Rich Harris 7 years ago
parent bb30e26d21
commit 67e4a90f18

@ -11,6 +11,7 @@ import error from '../utils/error';
interface ParserOptions {
filename?: string;
bind?: boolean;
customElement?: boolean;
}
type ParserState = (parser: Parser) => (ParserState | void);
@ -18,6 +19,7 @@ type ParserState = (parser: Parser) => (ParserState | void);
export class Parser {
readonly template: string;
readonly filename?: string;
readonly customElement: boolean;
index: number;
stack: Array<Node>;
@ -36,6 +38,7 @@ export class Parser {
this.template = template.replace(/\s+$/, '');
this.filename = options.filename;
this.customElement = options.customElement;
this.allowBindings = options.bind !== false;

@ -125,7 +125,7 @@ export default function tag(parser: Parser) {
? metaTags.get(name)
: (/[A-Z]/.test(name[0]) || name === 'svelte:self' || name === 'svelte:component') ? 'Component'
: name === 'title' && parentIsHead(parser.stack) ? 'Title'
: name === 'slot' ? 'Slot' : 'Element';
: name === 'slot' && !parser.customElement ? 'Slot' : 'Element';
const element: Node = {
start,

@ -11,7 +11,7 @@ export default function validateComponent(
stack: Node[],
elementStack: Node[]
) {
if (!validator.components.has(node.name)) {
if (node.name !== 'svelte:self' && node.name !== 'svelte:component' && !validator.components.has(node.name)) {
validator.error(node, {
code: `missing-component`,
message: `${node.name} component is not defined`

Loading…
Cancel
Save