MCPcopy Create free account
hub / github.com/TruthHun/BookStack / setSelected

Function setSelected

static/vuejs/vue.runtime.common.js:6305–6336  ·  view source on GitHub ↗
(el, binding, vm)

Source from the content-addressed store, hash-verified

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

Callers 2

cbFunction · 0.70

Calls 4

looseIndexOfFunction · 0.70
getValueFunction · 0.70
looseEqualFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected