(el, binding, vm)
| 6301 | }; |
| 6302 | |
| 6303 | function setSelected (el, binding, vm) { |
| 6304 | var value = binding.value; |
| 6305 | var isMultiple = el.multiple; |
| 6306 | if (isMultiple && !Array.isArray(value)) { |
| 6307 | process.env.NODE_ENV !== 'production' && warn( |
| 6308 | "<select multiple v-model=\"" + (binding.expression) + "\"> " + |
| 6309 | "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)), |
| 6310 | vm |
| 6311 | ); |
| 6312 | return |
| 6313 | } |
| 6314 | var selected, option; |
| 6315 | for (var i = 0, l = el.options.length; i < l; i++) { |
| 6316 | option = el.options[i]; |
| 6317 | if (isMultiple) { |
| 6318 | selected = looseIndexOf(value, getValue(option)) > -1; |
| 6319 | if (option.selected !== selected) { |
| 6320 | option.selected = selected; |
| 6321 | } |
| 6322 | } else { |
| 6323 | if (looseEqual(getValue(option), value)) { |
| 6324 | if (el.selectedIndex !== i) { |
| 6325 | el.selectedIndex = i; |
| 6326 | } |
| 6327 | return |
| 6328 | } |
| 6329 | } |
| 6330 | } |
| 6331 | if (!isMultiple) { |
| 6332 | el.selectedIndex = -1; |
| 6333 | } |
| 6334 | } |
| 6335 | |
| 6336 | function hasNoMatchingOption (value, options) { |
| 6337 | for (var i = 0, l = options.length; i < l; i++) { |
no test coverage detected