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

Function setSelected

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

Source from the content-addressed store, hash-verified

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

Callers 2

cbFunction · 0.70
vue.runtime.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected