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

Function setSelected

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

Source from the content-addressed store, hash-verified

6749};
6750
6751function setSelected (el, binding, vm) {
6752 var value = binding.value;
6753 var isMultiple = el.multiple;
6754 if (isMultiple && !Array.isArray(value)) {
6755 process.env.NODE_ENV !== 'production' && warn(
6756 "<select multiple v-model=\"" + (binding.expression) + "\"> " +
6757 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
6758 vm
6759 );
6760 return
6761 }
6762 var selected, option;
6763 for (var i = 0, l = el.options.length; i < l; i++) {
6764 option = el.options[i];
6765 if (isMultiple) {
6766 selected = looseIndexOf(value, getValue(option)) > -1;
6767 if (option.selected !== selected) {
6768 option.selected = selected;
6769 }
6770 } else {
6771 if (looseEqual(getValue(option), value)) {
6772 if (el.selectedIndex !== i) {
6773 el.selectedIndex = i;
6774 }
6775 return
6776 }
6777 }
6778 }
6779 if (!isMultiple) {
6780 el.selectedIndex = -1;
6781 }
6782}
6783
6784function hasNoMatchingOption (value, options) {
6785 for (var i = 0, l = options.length; i < l; i++) {

Callers 2

cbFunction · 0.70
vue.esm.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected