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.

v-once whitelist and additional directives

See original GitHub issue

What problem does this feature solve?

If a single child of a v-once parent requires reactivity then we can not use v-once on the parent element but must apply it to all the siblings of the reactive element/component instead. It would be nicer if we could whitelist the reactive children of an element or component that has v-once with some additional proposed directives.

Whitelists are usually a better strategy, especially for security, than blacklists.

What does the proposed API look like?

Ideally we would be able to do this:

<div v-once>
	<h1>static text</h1>
	<h1 v-exclude>{{non-static text}}</h1>
	<h1>static text</h1>
	<h1>static text</h1>
</div>

instead of the following:

<div>
	<h1 v-once>static text</h1>
	<h1>{{non-static text}}</h1>
	<h1 v-once>static text</h1>
	<h1 v-once>static text</h1>
</div>

Some additional directives proposed:

  • v-always: takes precedent over v-never and always excludes an element/component and its children
  • v-never: takes precedent over v-exclude and never excludes an element/component and its children
  • v-exclude: exclude a specific element/component and its children from v-once

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
yyx990803commented, Sep 1, 2017

v-once should really only be used on chunks of template that are significantly large and costly to render, otherwise the benefit would be negligible. Most applications perform perfectly fine without the need for v-once at all. The cost of introducing these additional directives/concepts, both technical and API surface increase, are not really worth it.

1reaction
javoskicommented, Jul 26, 2017

@posva See https://github.com/vuejs/vue/blob/dev/src/compiler/optimizer.js#L75, template below will generate static render function.

<div>
    <p class="hey">{{ text }}</p>
    <p><span class="ha">Hello</span></p>
</div>

IMO the costs of implementing this feature is heavily outweigh its benefits.

Read more comments on GitHub >

github_iconTop Results From Across the Web

V Shred Email Whitelist Instructions
Enter the email address vince@vshred.com in the text box. Click "Add to list"; Vince will now be added to your list of "Safe...
Read more >
Other provider – Whitelist Guide
Guide provides easy step-by-step instructions for updating safe sender or email white list settings for all the most popular email providers and we...
Read more >
How to whitelist ip to a specific domain | Linode Questions
I have owncloud installed on my linode. I was wondering if it was possible to set an iptable rule to only allow my...
Read more >
Pixellot Streaming Requirements for Windows Clients and ...
2) The tool does not factor in whitelisted domains and/or content ... In addition, please whitelist the REQUIRED domains in any active ...
Read more >
CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists ...
For additional directives to provide a meaningful security benefit, the site must first use a safe policy that success- fully prevents script ...
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