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

Function setSelected

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

Source from the content-addressed store, hash-verified

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

Callers 2

cbFunction · 0.70
vue.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected