Skip to content

Raise Error when template contains interpolation string outside of root node. #4789

@simonmurdock

Description

@simonmurdock

To replicate:

  • create a simple component and bind something immediately inside the template tag
<template>
    {{title}}
    <div class="example"></div>
</template>

I have been tripped up by this a couple of times (vue 2.8.0), where a simple binding outside the root div gives no output to the DOM, but also gives no error, like you would receive if you had two root nodes:

template syntax error Component template should contain exactly one root element:
...
If you are using v-if on multiple elements, use v-else-if to chain them instead.

Is there a valid reason to allow bindings like this in the root? If not it is a very small thing but it might help very new users from scratching their head like I did

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions