Subscribe on changes!
avatar
Apr 28th 2022

Version

3.2.33

Reproduction link

sfc.vuejs.org/

Steps to reproduce

v-for only spaces after in or of

What is expected?

in this case, should report an X_V_FOR_MALFORMED_EXPRESSION error during compiler

What is actually happening?

error reporting during runtime. (Unexpected token ','. )

avatar
Apr 28th 2022

Personally, I think the forAliasRE can be changed

// origin
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/

// suggestion
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([^\s]+)/
avatar
Apr 28th 2022

@hchlq PR welcome.

avatar
Apr 29th 2022

Personally, I think the forAliasRE can be changed

// origin
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/

// suggestion
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([^\s]+)/

I think this causes issues with expressions that contain spaces after in/of. You can try with v-for="item in store . items" . This might be a good test case to add. I think the following regex fixes the issue const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/