The <option> value attribute behaves differently #4494

Closed
cnwhy opened this Issue Dec 16, 2016 · 3 comments

Projects

None yet

4 participants

@cnwhy
cnwhy commented Dec 16, 2016 edited

Vue.js version

2.1.6

Reproduction Link

http://sandbox.runjs.cn/show/g9bqfzhr

Steps to reproduce

<div id="app">
    <select id="s1">
        <option value="111">111</option>
        <option :value="v">{{v}}</option>
        <option :value="v" v-text="v"></option>
        <option :value="v">111</option>
        <option value="111">{{v}}</option>
    </select>
</div>
<script>
new Vue({
    el: "#app",
    data: {
        v: "111"
    }
})
</script>

What is Expected?

<div id="app">
    <select id="s1">
        <option value="111">111</option>
        <option value="111">111</option>
        <option value="111">111</option>
        <option value="111">111</option>
        <option value="111">111</option>
    </select>
</div>

What is actually happening?

<div id="app">
    <select id="s1">
        <option value="111">111</option>
        <option>111</option>
        <option value="111">111</option>
        <option>111</option>
        <option value="111">111</option>
    </select>
</div>
@defcc
Member
defcc commented Dec 16, 2016

Maybe we need to force value setting for option? https://github.com/vuejs/vue/blob/dev/src/platforms/web/runtime/modules/dom-props.js#L38

<option>text</option>

For option with emty value, option.value will be the text, which is the same in this issue.

@defcc defcc added the 2.x label Dec 16, 2016
@yyx990803
Collaborator

@defcc yeah, just need a special case for 'option'.

@Aierui
Aierui commented Dec 16, 2016

meaningful!

@yyx990803 yyx990803 closed this in #4505 Dec 21, 2016
@yyx990803 yyx990803 added a commit that referenced this issue Dec 21, 2016
@defcc @yyx990803 defcc + yyx990803 update dom prop for option.value (fix #4494) (#4505)
* update dom prop for option.value

* refactor value update logic
be9210f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment