|
|
|
@ -53,13 +53,16 @@ function parent_is_head(stack) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const regex_closing_textarea_tag = /^<\/textarea(\s[^>]*)?>/i;
|
|
|
|
|
|
|
|
const regex_closing_comment = /-->/;
|
|
|
|
|
|
|
|
|
|
|
|
export default function tag(parser: Parser) {
|
|
|
|
export default function tag(parser: Parser) {
|
|
|
|
const start = parser.index++;
|
|
|
|
const start = parser.index++;
|
|
|
|
|
|
|
|
|
|
|
|
let parent = parser.current();
|
|
|
|
let parent = parser.current();
|
|
|
|
|
|
|
|
|
|
|
|
if (parser.eat('!--')) {
|
|
|
|
if (parser.eat('!--')) {
|
|
|
|
const data = parser.read_until(/-->/);
|
|
|
|
const data = parser.read_until(regex_closing_comment);
|
|
|
|
parser.eat('-->', true, parser_errors.unclosed_comment);
|
|
|
|
parser.eat('-->', true, parser_errors.unclosed_comment);
|
|
|
|
|
|
|
|
|
|
|
|
parser.current().children.push({
|
|
|
|
parser.current().children.push({
|
|
|
|
@ -218,11 +221,10 @@ export default function tag(parser: Parser) {
|
|
|
|
// special case
|
|
|
|
// special case
|
|
|
|
element.children = read_sequence(
|
|
|
|
element.children = read_sequence(
|
|
|
|
parser,
|
|
|
|
parser,
|
|
|
|
() =>
|
|
|
|
() => regex_closing_textarea_tag.test(parser.template.slice(parser.index)),
|
|
|
|
/^<\/textarea(\s[^>]*)?>/i.test(parser.template.slice(parser.index)),
|
|
|
|
|
|
|
|
'inside <textarea>'
|
|
|
|
'inside <textarea>'
|
|
|
|
);
|
|
|
|
);
|
|
|
|
parser.read(/^<\/textarea(\s[^>]*)?>/i);
|
|
|
|
parser.read(regex_closing_textarea_tag);
|
|
|
|
element.end = parser.index;
|
|
|
|
element.end = parser.index;
|
|
|
|
} else if (name === 'script' || name === 'style') {
|
|
|
|
} else if (name === 'script' || name === 'style') {
|
|
|
|
// special case
|
|
|
|
// special case
|
|
|
|
@ -237,6 +239,8 @@ export default function tag(parser: Parser) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const regex_whitespace_or_slash_or_closing_tag = /(\s|\/|>)/;
|
|
|
|
|
|
|
|
|
|
|
|
function read_tag_name(parser: Parser) {
|
|
|
|
function read_tag_name(parser: Parser) {
|
|
|
|
const start = parser.index;
|
|
|
|
const start = parser.index;
|
|
|
|
|
|
|
|
|
|
|
|
@ -266,7 +270,7 @@ function read_tag_name(parser: Parser) {
|
|
|
|
|
|
|
|
|
|
|
|
if (parser.read(SLOT)) return 'svelte:fragment';
|
|
|
|
if (parser.read(SLOT)) return 'svelte:fragment';
|
|
|
|
|
|
|
|
|
|
|
|
const name = parser.read_until(/(\s|\/|>)/);
|
|
|
|
const name = parser.read_until(regex_whitespace_or_slash_or_closing_tag);
|
|
|
|
|
|
|
|
|
|
|
|
if (meta_tags.has(name)) return name;
|
|
|
|
if (meta_tags.has(name)) return name;
|
|
|
|
|
|
|
|
|
|
|
|
@ -286,6 +290,10 @@ function read_tag_name(parser: Parser) {
|
|
|
|
return name;
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-useless-escape
|
|
|
|
|
|
|
|
const regex_token_ending_character = /[\s=\/>"']/;
|
|
|
|
|
|
|
|
const regex_quote_characters = /["']/;
|
|
|
|
|
|
|
|
|
|
|
|
function read_attribute(parser: Parser, unique_names: Set<string>) {
|
|
|
|
function read_attribute(parser: Parser, unique_names: Set<string>) {
|
|
|
|
const start = parser.index;
|
|
|
|
const start = parser.index;
|
|
|
|
|
|
|
|
|
|
|
|
@ -344,8 +352,7 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-useless-escape
|
|
|
|
const name = parser.read_until(regex_token_ending_character);
|
|
|
|
const name = parser.read_until(/[\s=\/>"']/);
|
|
|
|
|
|
|
|
if (!name) return null;
|
|
|
|
if (!name) return null;
|
|
|
|
|
|
|
|
|
|
|
|
let end = parser.index;
|
|
|
|
let end = parser.index;
|
|
|
|
@ -360,7 +367,7 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
|
|
|
|
parser.allow_whitespace();
|
|
|
|
parser.allow_whitespace();
|
|
|
|
value = read_attribute_value(parser);
|
|
|
|
value = read_attribute_value(parser);
|
|
|
|
end = parser.index;
|
|
|
|
end = parser.index;
|
|
|
|
} else if (parser.match_regex(/["']/)) {
|
|
|
|
} else if (parser.match_regex(regex_quote_characters)) {
|
|
|
|
parser.error(parser_errors.unexpected_token('='), parser.index);
|
|
|
|
parser.error(parser_errors.unexpected_token('='), parser.index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|