Skip to content

disallow v-text/v-html on components #1724

Closed
@jacekkarczmarczyk

Description

@jacekkarczmarczyk

Please describe what the rule should do:
Components can have internal html structure that will be destroyed if you use v-html or v-text on them. Here's codepen example

https://codepen.io/jkarczm/pen/MWvRLYa

    <v-btn>foo</v-btn>
    <v-btn v-text="'foo'" />

and the generated markup:

    <button type="button" class="...">
      <span class="v-btn__content">foo</span>
    </button>
    <button type="button" class="...">
      foo
    </button>

As you see the second one misses the v-btn__content div, which in this particular case doesn't seem to break anything (EDIT: actually it does vuetifyjs/vuetify#11792 (comment)) but it could potentially

What category should the rule belong to?

[ ] Enforces code style (layout)
[X] Warns about a potential error (problem)
[X] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<template>
  <!-- warn -->
  <some-component v-text="'content'" />
  <some-component v-html="'content'" />

  <!-- ok -->
  <div v-text="'content'" />

  <!-- not sure, should probably warn too, could be configurable -->
  <web-component v-text="'content'" />

Additional context

Initially I thought about a new rule but I think that it could be just a configuration option for vue/no-v-text and vue/no-v-html rules ({ allowNativeTags: true })

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