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

Function setSelected

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

Source from the content-addressed store, hash-verified

6301};
6302
6303function 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
6336function hasNoMatchingOption (value, options) {
6337 for (var i = 0, l = options.length; i < l; i++) {

Callers 2

cbFunction · 0.70
vue.runtime.esm.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected