Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using v-for in IE10 #7946

Closed
parapada73 opened this issue Apr 2, 2018 · 22 comments · Fixed by #8048
Closed

Error when using v-for in IE10 #7946

parapada73 opened this issue Apr 2, 2018 · 22 comments · Fixed by #8048

Comments

@parapada73
Copy link

parapada73 commented Apr 2, 2018

Version

2.5.16 / 2.5.17

Reproduction link

https://jsfiddle.net/plasmaeng/ndmjjkho/1/

Steps to reproduce

Running the code below in IE10 will result in the following error:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Page Title</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<script src="vue.js"></script>
</head>
<body>
<div id="app_test">
	<form>
	<select>
		<option v-for="value in L">{{value}}</option>
	</select>
	</form>
</div>

<script>
	var appTest = new Vue({
	el: '#app_test',
		data: {
			L : [ '1', '2' ,'3']
		}
	});
</script>
</body>
</html>

Here is the error message from IE10.

[Vue warn]: Error compiling template:

<div id="app_test">
	<form>
	<select>
		<option v-for="value in L">{{value}}</option>
	</select>
	</form>
</div>

invalid expression: Syntax error in  Raw expression: v-for="value in L"
invalid v-for alias "" in expression: v-for="value in L"

image

image

What is expected?

<option> is generated from 1 to 3.

What is actually happening?

<option> is not generated with error !!!


I have persuaded a senior for a long time to introduce Vue.js.
If this problem is solved, we plan to reorganize the site into Vue.js.
Please solve the problem.

@schoonc
Copy link
Contributor

schoonc commented Apr 2, 2018

Confirm.

I insert:
console.log(render)
before line:
vnode = render.call(vm._renderProxy, vm.$createElement);

Generated render function in chrome, for example:
with(this){return _c('div',{attrs:{"id":"app_test"}},[_c('form',[_c('select',_l((l),function(value){return _c('option',[_v(_s(value))])}))])])}

In ie 10:
with(this){return _c('div',{attrs:{"id":"app_test"}},[_c('form',[_c('select',[_c('option',[_v(_s(value))])],2)])])}

P.S. With vue 2.5.15 no problem.

@schoonc
Copy link
Contributor

schoonc commented Apr 3, 2018

If in vue 2.5.16 revert this commit (71b4b25) then problem disappears.

@linkser
Copy link

linkser commented Apr 3, 2018

IE9 also has this problem

@LinusBorg
Copy link
Member

probably the changes to the regex don'T work in <IE11 ?

@schoonc
Copy link
Contributor

schoonc commented Apr 3, 2018

Yes.

    console.clear()
    var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/;
    console.log('value in list'.match(forAliasRE))

Output in chrome:

["value in list", "value", "list"]

Output in ie10:

[" in list", "", ""]

@schoonc
Copy link
Contributor

schoonc commented Apr 3, 2018

http://sjhannah.com/blog/2011/05/17/javascript-matching-all-characters-including-new-line/

May be replace [^] on [\s\S] ?

@maetteam
Copy link

maetteam commented Apr 5, 2018

Hallo, yeah that should fix the problem.
'\s' <=IE8 doesn't include all white spaces, non-breaking space (\xA0) and thin space (\x2009) are not included, if you are planning to run it on IE8 and below ;).

@LinusBorg
Copy link
Member

VUe doesn't support <IE9.

@pbelyaev
Copy link

Any updates?

@huanghui8030
Copy link

huanghui8030 commented Apr 19, 2018

Update vue version to v2.5.16 or v2.5.15, but error reporting. Don't know why?

resolved, Thanks!
posva@405c815

@weijuer
Copy link

weijuer commented May 4, 2018

What can I do, if I need to use it in ie9+? Wait for next release version or change to 2.5.15?

@LinusBorg
Copy link
Member

Right now, those are your two options, yes.

@symmetriq
Copy link

If you need one of the other fixes in 2.5.16, you can also just patch it yourself.

Search: /([^]*?)\s+(?:in|of)\s+([^]*)/
Replace: /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/

This worked for me, but I decided to revert to 2.5.15 anyway (don't need any of the other changes in 2.5.16).

@ufozy
Copy link

ufozy commented Aug 15, 2018

<script src="https://cdn.jsdelivr.net/npm/vue@2.4.2/dist/vue.js"></script>

use “version 2.4.2” is ok

@murilobd
Copy link

I'm on version 2.5.7 and still getting this issue with damn IE

@TheWebTech
Copy link

to anyone still experiencing this issue. @symmetriq's tip #7946 (comment)

was spot on, reverting to 2.5.15 solves it. I'd assume he's also correct on the regex adjustment.

@tfnigel
Copy link

tfnigel commented Oct 3, 2018

Using 2.5.15, fixed it for me; I was seeing the problem on 2.5.17 on IE9.

@alanwei43
Copy link

Vue@2.5.15 is ok

@mrquokka
Copy link

Vue@2.5.15 is ok

2.5.17 have some error on IE9
object is

  css_allowed_styles = {
    'default': '',
    'darkness': 'dark_theme.css'
```}
crashed template
` v-for="(file_name, item) in css_allowed_styles" :value="item" :key="item">`

@qinshenxue
Copy link

the problem disappears in vue@2.5.17 when using ie9

@mrquokka
Copy link

mrquokka commented Dec 1, 2018

the problem disappears in vue@2.5.17 when using ie9

disagree, have some error on 2.5.17, and fix help me

@posva
Copy link
Member

posva commented Dec 1, 2018

This will be released in the next version which is coming soon 🙂

@vuejs vuejs locked as spam and limited conversation to collaborators Dec 1, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
aJean pushed a commit to aJean/vue that referenced this issue Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.