MCPcopy Create free account
hub / github.com/keepfool/vue-tutorials / getValue

Function getValue

02.Components/Part-1/js/vue.js:4938–4954  ·  view source on GitHub ↗

* Get select value * * @param {SelectElement} el * @param {Boolean} multi * @param {Boolean} init * @return {Array|*}

(el, multi, init)

Source from the content-addressed store, hash-verified

4936 */
4937
4938 function getValue(el, multi, init) {
4939 var res = multi ? [] : null;
4940 var op, val, selected;
4941 for (var i = 0, l = el.options.length; i < l; i++) {
4942 op = el.options[i];
4943 selected = init ? op.hasAttribute('selected') : op.selected;
4944 if (selected) {
4945 val = op.hasOwnProperty('_value') ? op._value : op.value;
4946 if (multi) {
4947 res.push(val);
4948 } else {
4949 return val;
4950 }
4951 }
4952 }
4953 return res;
4954 }
4955
4956 /**
4957 * Native Array.indexOf uses strict equal, but in this

Callers 1

vue.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected