read tag option from <svelte:meta>

pull/1864/head
Rich Harris 7 years ago
parent 7f3cd0d655
commit 699328b165

@ -227,8 +227,17 @@ export default class Component {
if (options.customElement === true) {
this.customElement = {
tag: this.tag,
props: this.props
tag: null,
props: [] // TODO!!!
};
// find <svelte:meta> tag
const meta = this.ast.html.children.find(node => node.name === 'svelte:meta');
if (meta) {
const tag_attribute = meta.attributes.find(a => a.name === 'tag');
if (tag_attribute) {
this.customElement.tag = tag_attribute.value[0].data;
}
}
} else {
this.customElement = options.customElement;

@ -0,0 +1,6 @@
import Node from './shared/Node';
export default class Meta extends Node {
type: 'Meta';
data: string;
}

@ -6,6 +6,7 @@ import Element from '../Element';
import Head from '../Head';
import IfBlock from '../IfBlock';
import InlineComponent from '../InlineComponent';
import Meta from '../Meta';
import MustacheTag from '../MustacheTag';
import RawMustacheTag from '../RawMustacheTag';
import DebugTag from '../DebugTag';
@ -25,6 +26,7 @@ function getConstructor(type): typeof Node {
case 'Head': return Head;
case 'IfBlock': return IfBlock;
case 'InlineComponent': return InlineComponent;
case 'Meta': return Meta;
case 'MustacheTag': return MustacheTag;
case 'RawMustacheTag': return RawMustacheTag;
case 'DebugTag': return DebugTag;

Loading…
Cancel
Save