Skip to content

[feature request] new v-slot syntax does not support slot names that start with a square bracket [ or names with spaces #10390

Closed
@tmorehouse

Description

@tmorehouse

What problem does this feature solve?

We use slot names that use a bracketed syntax (specifically for dynamic slot names) i.e. slot="[foo][bar]").

v-slot: currently supports slots names with square brackets, as long as they are not the first character of the slot name. i.e. v-slot:foo[bar]="scope" (works), but not v-slot:[foo][bar]="scope" (does not work)

HTML5 allows for custom attributes with square brackets in the attribute name, as long as they do not start with restricted characters. However, in the case of v-slot, the attribute starts with v, so slot names that start with [ should work as expected (i.e. v-slot:[foo.bar] or v-slot:[foo][bar])

Using the deprecated slot="[foo]" syntax works as expected.

What does the proposed API look like?

v-slot adds support for slot names that start with a [, such as v-slot:[foo][bar]="scope"

There is no actual change to the API from the user perspective, just a change to the underlying code.

My guess that this is an issue with Vue template compiler:

From the template compiler on the Vuejs.org site (https://vuejs.org/v2/guide/render-function.html#Template-Compilation):

Does not work:

image

Does Work:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions