DeepSource has joined Harness. Learn more
JavaScript logoJavaScript/
JS-0638

Found invalid `v-once` directivesJS-0638

Major severityMajor
Bug Risk categoryBug Risk
vue

v-once directive renders the element and component once only. On subsequent re-renders, the element/component and all its children will be treated as static content and skipped. This can be used to optimize update performance.

v-once directive is invalid when :

  • The directive has an argument.
  • The directive has a modifier.
  • The directive has an attribute value.

The issue is fixed by removing the argument, modifier and attribute value.

Bad Practice

<!-- 'v-once' directives require no argument -->
<div v-once:aaa/>

<!-- 'v-once' directives require no modifier -->
<div v-once.bbb/>

<!-- 'v-once' directives require no attribute value -->
<div v-once="ccc"/>
<!-- removed modifier, attribute, argument -->
<div v-once/>

References