Meituan-Dianping/mpvue · error

Mal-formatted tag at end of template

Error message

Mal-formatted tag at end of template: "${html}"

What it means

Dev-only warning from parseHTML when the parser reaches the end of the template with residual unconsumed html text and an empty tag stack — i.e. trailing content that is neither text nor a well-formed tag, usually a stray '<', malformed closing markup, or an unclosed construct that consumed the rest of the input.

Solutions

  1. Inspect the trailing fragment printed in the message and fix the malformed markup
  2. Escape stray '<' characters as &lt; if literal text was intended
  3. Check for unclosed comments or attribute quotes swallowing the rest of the template
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/compiler/parser/html-parser.js:188 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02). Data as JSON: /api/errors/c71047cf002cba3a. Report an issue: GitHub.

Appendix: source

Thrown at src/compiler/parser/html-parser.js:188

            .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1')
        }
        if (shouldIgnoreFirstNewline(stackedTag, text)) {
          text = text.slice(1)
        }
        if (options.chars) {
          options.chars(text)
        }
        return ''
      })
      index += html.length - rest.length
      html = rest
      parseEndTag(stackedTag, index - endTagLength, index)
    }

    if (html === last) {
      options.chars && options.chars(html)
      if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
        options.warn(`Mal-formatted tag at end of template: "${html}"`)
      }
      break
    }
  }

  // Clean up any remaining tags
  parseEndTag()

  function advance (n) {
    index += n
    html = html.substring(n)
  }

  function parseStartTag () {
    const start = html.match(startTagOpen)
    if (start) {
      const match = {
        tagName: start[1],

View on GitHub (pinned to 6c5d78ee04)