diff --git a/src/compiler/parse/index.ts b/src/compiler/parse/index.ts index fed39f6bfd..e552374698 100644 --- a/src/compiler/parse/index.ts +++ b/src/compiler/parse/index.ts @@ -82,15 +82,6 @@ export class Parser { return this.stack[this.stack.length - 1]; } - find_in_stack(fn) { - for (let i=this.stack.length -1; i>=0; i--) { - if (fn(this.stack[i])) { - return true; - } - } - return false; - } - acorn_error(err: any) { this.error({ code: `parse-error`, diff --git a/src/compiler/parse/state/mustache.ts b/src/compiler/parse/state/mustache.ts index a0241fe8b9..b04f0aab83 100644 --- a/src/compiler/parse/state/mustache.ts +++ b/src/compiler/parse/state/mustache.ts @@ -108,7 +108,7 @@ export default function mustache(parser: Parser) { if (parser.eat('if')) { const block = parser.current(); if (block.type !== 'IfBlock') { - if (parser.find_in_stack(block => block.type === 'IfBlock')) { + if (parser.stack.some(block => block.type === 'IfBlock')) { parser.error({ code: 'unclosed-open-tag', message: `Expect to close ${to_string(block)} before {:else if ...} block` @@ -151,7 +151,7 @@ export default function mustache(parser: Parser) { else { const block = parser.current(); if (block.type !== 'IfBlock' && block.type !== 'EachBlock') { - if (parser.find_in_stack(block => block.type === 'IfBlock' || block.type === 'EachBlock')) { + if (parser.stack.some(block => block.type === 'IfBlock' || block.type === 'EachBlock')) { parser.error({ code: 'unclosed-open-tag', message: `Expect to close ${to_string(block)} before {:else} block` @@ -182,7 +182,7 @@ export default function mustache(parser: Parser) { if (is_then) { if (block.type !== 'PendingBlock') { - if (parser.find_in_stack(block => block.type === 'PendingBlock')) { + if (parser.stack.some(block => block.type === 'PendingBlock')) { parser.error({ code: 'unclosed-open-tag', message: `Expect to close ${to_string(block)} before {:then} block` @@ -195,7 +195,7 @@ export default function mustache(parser: Parser) { } } else { if (block.type !== 'ThenBlock' && block.type !== 'PendingBlock') { - if (parser.find_in_stack(block => block.type === 'ThenBlock' || block.type === 'PendingBlock')) { + if (parser.stack.some(block => block.type === 'ThenBlock' || block.type === 'PendingBlock')) { parser.error({ code: 'unclosed-open-tag', message: `Expect to close ${to_string(block)} before {:catch} block`