Skip to content

fix: avoid compiler generating incorrect code#290

Merged
yyx990803 merged 1 commit intovuejs:masterfrom
HcySunYang:fix-generate-wrong-code
Oct 15, 2019
Merged

fix: avoid compiler generating incorrect code#290
yyx990803 merged 1 commit intovuejs:masterfrom
HcySunYang:fix-generate-wrong-code

Conversation

@HcySunYang
Copy link
Copy Markdown
Member

I noticed that empty interpolation will be compiled into toString(_ctx.).

E.g:

{{}}

Generated:

import { toString } from "vue"

export default function render() {
  const _ctx = this
  return toString(_ctx.)
}

@jacekkarczmarczyk
Copy link
Copy Markdown
Contributor

Shouldn't it throw or at least warn? Not sure how it works in 2.x tho

@HcySunYang
Copy link
Copy Markdown
Member Author

In the 2.x version, the template below:

<div>{{}}</div>

The delimiters will be considered plain text.

If the template is as follows:

<div>{{  }}</div>

Will generate empty text(''), but neither case throws an error or warn.

@jacekkarczmarczyk
Copy link
Copy Markdown
Contributor

I see. Do i understand correctly it's a breaking change ({{}} => '' instead of {{}} => '{{}}')?

@yyx990803
Copy link
Copy Markdown
Member

I'd say the current 2.x behavior is a bug.

@yyx990803 yyx990803 merged commit 3385480 into vuejs:master Oct 15, 2019
@vue-bot
Copy link
Copy Markdown
Contributor

vue-bot commented Oct 15, 2019

Hey @HcySunYang, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants