finalize parse

pull/8569/head
Simon Holthausen 3 years ago
parent 7a860eb212
commit 1069a2be21

@ -57,7 +57,7 @@ export class Parser {
meta_tags = {}; meta_tags = {};
/** /**
* @type {LastAutoClosedTag} * @type {{tag: string; reason: string; depth: number;}}
*/ */
last_auto_closed_tag = undefined; last_auto_closed_tag = undefined;
@ -80,6 +80,11 @@ export class Parser {
children: [] children: []
}; };
this.stack.push(this.html); this.stack.push(this.html);
/**
* @typedef {(parser: Parser) => ParserState | void} ParserState
*/
/** @type {ParserState} */ /** @type {ParserState} */
let state = fragment; let state = fragment;
while (this.index < this.template.length) { while (this.index < this.template.length) {
@ -278,16 +283,3 @@ export default function parse(template, options = {}) {
module: module_scripts[0] module: module_scripts[0]
}; };
} }
/**
* @internal
* @typedef {(parser: Parser) => ParserState | void} ParserState
*/
/**
* @internal
* @typedef {Object} LastAutoClosedTag
* @property {string} tag
* @property {string} reason
* @property {number} depth
*/

@ -379,7 +379,8 @@ function read_attribute(parser, unique_names) {
const first_value = value[0]; const first_value = value[0];
let expression = null; let expression = null;
if (first_value) { if (first_value) {
const attribute_contains_text = value.length > 1 || first_value.type === 'Text'; const attribute_contains_text =
/** @type {any[]} */ (value).length > 1 || first_value.type === 'Text';
if (attribute_contains_text) { if (attribute_contains_text) {
parser.error(parser_errors.invalid_directive_value, first_value.start); parser.error(parser_errors.invalid_directive_value, first_value.start);
} else { } else {

@ -128,7 +128,7 @@ const disallowed_contents = new Map([
/** /**
* @param {string} current * @param {string} current
* @param {string} next * @param {string} [next]
*/ */
export function closing_tag_omitted(current, next) { export function closing_tag_omitted(current, next) {
if (disallowed_contents.has(current)) { if (disallowed_contents.has(current)) {

Loading…
Cancel
Save