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

Function setSelected

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

Source from the content-addressed store, hash-verified

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

Callers 2

cbFunction · 0.70
vue.common.jsFile · 0.70

Calls 4

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

Tested by

no test coverage detected