Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
waynzh committed Nov 15, 2024
1 parent f3d794a commit f3a6ad1
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions docs/rules/no-v-text-v-html-on-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ If you use v-text / v-html on a component, it will overwrite the component's con
<!-- ✓ GOOD -->
<div v-text="content"></div>
<div v-html="html"></div>
<svg><g v-text="content" /></svg>
<math><mi v-text="content" /></math>
<MyComponent>{{ content }}</MyComponent>
<!-- ✗ BAD -->
<MyComponent v-text="content"></MyComponent>
<MyComponent v-html="html"></MyComponent>
<g v-text="content" />
<mi v-text="content" />
</template>
```

Expand All @@ -39,14 +43,15 @@ If you use v-text / v-html on a component, it will overwrite the component's con

```json
{
"vue/no-v-text-v-html-on-component": [
"error",
{ "allow": ["router-link", "nuxt-link"] }
]
"vue/no-v-text-v-html-on-component": ["error", {
"allow": ["router-link", "nuxt-link"],
"ignoreElementNamespaces": false
}]
}
```

- `allow` (`string[]`) ... Specify a list of custom components for which the rule should not apply.
- `ignoreElementNamespaces` (`boolean`) ... Specify whether to ignore the namespace restrictions for SVG and MathML elements, so that the rule should not apply. Default is `false`.

### `{ "allow": ["router-link", "nuxt-link"] }`

Expand All @@ -65,6 +70,20 @@ If you use v-text / v-html on a component, it will overwrite the component's con

</eslint-code-block>

### `{ "ignoreElementNamespaces": true }`

<eslint-code-block :rules="{'vue/no-v-text-v-html-on-component': ['error', { ignoreElementNamespaces: true }]}">

```vue
<template>
<!-- ✓ GOOD -->
<g v-text="content" /> <!-- <svg> -->
<mi v-text="content" /> <!-- <math> -->
</template>
```

</eslint-code-block>

## :rocket: Version

This rule was introduced in eslint-plugin-vue v8.4.0
Expand Down

0 comments on commit f3a6ad1

Please sign in to comment.