question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
jacekkarczmarczykcommented, Aug 14, 2019

@sirlancelot it works with backticks though (see my example), maybe it should be documented?

2reactions
tmorehousecommented, Aug 14, 2019

It is too bad the new slot/scope syntax wasn’t split into two “directives”:

<!-- pass a string literal as the slot name -->
<template v-slot="'slotName'" v-scope="{ some, props, here }"></template>

<!-- pass a variable containing the slot name -->
<template v-slot="someVar" v-scope="{ some, props, here }"></template>

As this would retain case sensitivity on slot names (when using browser templates), allow spaces in slot names, and get around the restrictions that attribute names have (case insensitivity, special chars, and spaces)

Within render functions, one can always use this.$scopedSlots[slotname](scope)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the new v-slot directive in Vue.js - VueDose
Simplify the use of scoped slots with the new v-slot syntax introduced in Vue.js 2.6.0 beta 3.
Read more >
vue.js - error related with v-slot in my IDE, or some other issue
Seems to be an unresolved issue with WebStorm IDE. For what it's worth, I've not seen this problem when using Visual Studio Code....
Read more >
Template Syntax | Vue.js
Vue uses an HTML-based template syntax that allows you to declaratively bind the rendered DOM to the underlying component instance's data.
Read more >
IBM Spectrum LSF Configuration Reference - SAS Support
No blank or space characters are permitted as part of a name. ... RESUME_CONTROL parameter does not require square brackets ([ ]) around...
Read more >
SAN512B-6 Installation, Service, and User Guide - IBM
If you do not install a module or a power supply in a slot, you must keep the slot ... v IBM Storage...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found