Skip to content

Commit

Permalink
Change the default of `parserOptions.vueFeatures.interpolationAsNonHT…
Browse files Browse the repository at this point in the history
…ML` to `true`. (#130)

* Change the default of `parserOptions.vueFeatures.interpolationAsNonHTML` to true.

* Update tests

* format and fix tests
  • Loading branch information
ota-meshi authored Oct 19, 2021
1 parent 2586806 commit f7a7a1e
Show file tree
Hide file tree
Showing 19 changed files with 3,251 additions and 501 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ For example:
"parserOptions": {
"vueFeatures": {
"filter": true,
"interpolationAsNonHTML": false,
"interpolationAsNonHTML": true,
"styleCSSVariableInjection": true,
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ However, the following template that are valid in Vue 2 cannot be parsed.

### parserOptions.vueFeatures.interpolationAsNonHTML

You can use `parserOptions.vueFeatures.interpolationAsNonHTML` property to specify whether to parse the interpolation as HTML. If you specify `true`, the parser handles the interpolation as non-HTML (However, you can use HTML escaping in the interpolation).
You can use `parserOptions.vueFeatures.interpolationAsNonHTML` property to specify whether to parse the interpolation as HTML. If you specify `true`, the parser handles the interpolation as non-HTML (However, you can use HTML escaping in the interpolation). Default is `true`.
For example:

```json
Expand Down
2 changes: 1 addition & 1 deletion src/common/parser-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ParserOptions {
// vue-eslint-parser options
parser?: boolean | string
vueFeatures?: {
interpolationAsNonHTML?: boolean // default false
interpolationAsNonHTML?: boolean // default true
filter?: boolean // default true
styleCSSVariableInjection?: boolean // default true
}
Expand Down
7 changes: 6 additions & 1 deletion src/html/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,12 @@ export class Tokenizer {
this.appendTokenValue(LEFT_CURLY_BRACKET, null)
this.appendTokenValue(LEFT_CURLY_BRACKET, null)

if (!this.parserOptions.vueFeatures?.interpolationAsNonHTML) {
if (
!(
this.parserOptions.vueFeatures?.interpolationAsNonHTML ??
true
)
) {
return this.returnState
}

Expand Down
Loading

0 comments on commit f7a7a1e

Please sign in to comment.