diff --git a/src/compiler/parse/index.ts b/src/compiler/parse/index.ts index 04025ae0fc..f378fced41 100644 --- a/src/compiler/parse/index.ts +++ b/src/compiler/parse/index.ts @@ -177,9 +177,9 @@ export class Parser { return identifier; } - read_until(pattern: RegExp) { + read_until(pattern: RegExp, error?: {code: string; message: string}) { if (this.index >= this.template.length) - this.error({ + this.error(error || { code: `unexpected-eof`, message: 'Unexpected end of input' }); diff --git a/src/compiler/parse/read/script.ts b/src/compiler/parse/read/script.ts index 3fadab9fbe..6a719250ef 100644 --- a/src/compiler/parse/read/script.ts +++ b/src/compiler/parse/read/script.ts @@ -28,16 +28,15 @@ function get_context(parser: Parser, attributes: any[], start: number): string { export default function read_script(parser: Parser, start: number, attributes: Node[]): Script { const script_start = parser.index; - const script_end = /<\/script\s*>/.exec(parser.template.slice(script_start)); - - if (!script_end) parser.error({ + const error_message ={ code: `unclosed-script`, message: `