functionmodel (el, dir, _warn) { warn$1 = _warn; var value = dir.value; var modifiers = dir.modifiers; var tag = el.tag; var type = el.attrsMap.type;
{ // inputs with type="file" are read only and setting the input's // value will throw an error. if (tag === 'input' && type === 'file') { warn$1( "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" + "File inputs are read only. Use a v-on:change listener instead.", el.rawAttrsMap['v-model'] ); } }
if (el.component) { genComponentModel(el, value, modifiers); // component v-model doesn't need extra runtime returnfalse } elseif (tag === 'select') { genSelect(el, value, modifiers); } elseif (tag === 'input' && type === 'checkbox') { genCheckboxModel(el, value, modifiers); } elseif (tag === 'input' && type === 'radio') { genRadioModel(el, value, modifiers); } elseif (tag === 'input' || tag === 'textarea') { genDefaultModel(el, value, modifiers); } elseif (!config.isReservedTag(tag)) { genComponentModel(el, value, modifiers); // component v-model doesn't need extra runtime returnfalse } else { warn$1( "<" + (el.tag) + " v-model=\"" + value + "\">: " + "v-model is not supported on this element type. " + 'If you are working with contenteditable, it\'s recommended to ' + 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model'] ); }
name = name.replace(onRE, ''); isDynamic = dynamicArgRE.test(name); if (isDynamic) { name = name.slice(1, -1); } addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
// addHandler functionaddHandler (el,name,value,modifiers,important,warn,range,dynamic) { modifiers = modifiers || emptyObject; // warn prevent and passive modifier /* istanbul ignore if */ if ( warn && modifiers.prevent && modifiers.passive ) { warn( 'passive and prevent can\'t be used together. ' + 'Passive handler can\'t prevent default event.', range ); }
// normalize click.right and click.middle since they don't actually fire // this is technically browser-specific, but at least for now browsers are // the only target envs that have right/middle clicks. if (modifiers.right) { if (dynamic) { name = "(" + name + ")==='click'?'contextmenu':(" + name + ")"; } elseif (name === 'click') { name = 'contextmenu'; delete modifiers.right; } } elseif (modifiers.middle) { if (dynamic) { name = "(" + name + ")==='click'?'mouseup':(" + name + ")"; } elseif (name === 'click') { name = 'mouseup'; } } // check capture modifier if (modifiers.capture) { delete modifiers.capture; name = prependModifierMarker('!', name, dynamic); } if (modifiers.once) { delete modifiers.once; name = prependModifierMarker('~', name, dynamic); } /* istanbul ignore if */ if (modifiers.passive) { delete modifiers.passive; name = prependModifierMarker('&', name, dynamic); }
functionprocessSlotContent (el) { var slotScope; if (el.tag === 'template') { slotScope = getAndRemoveAttr(el, 'scope'); /* istanbul ignore if */ if (slotScope) { warn$2( "the \"scope\" attribute for scoped slots have been deprecated and " + "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " + "can also be used on plain elements in addition to <template> to " + "denote scoped slots.", el.rawAttrsMap['scope'], true ); } el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope'); } elseif ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) { /* istanbul ignore if */ if (el.attrsMap['v-for']) { warn$2( "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " + "(v-for takes higher priority). Use a wrapper <template> for the " + "scoped slot to make it clearer.", el.rawAttrsMap['slot-scope'], true ); } el.slotScope = slotScope; }
// slot="xxx" var slotTarget = getBindingAttr(el, 'slot'); if (slotTarget) { el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']); // preserve slot as an attribute for native shadow DOM compat // only for non-scoped slots. if (el.tag !== 'template' && !el.slotScope) { addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot')); } }
// 2.6 v-slot syntax { if (el.tag === 'template') { // v-slot on <template> var slotBinding = getAndRemoveAttrByRegex(el, slotRE); if (slotBinding) { { if (el.slotTarget || el.slotScope) { warn$2( "Unexpected mixed usage of different slot syntaxes.", el ); } if (el.parent && !maybeComponent(el.parent)) { warn$2( "<template v-slot> can only appear at the root level inside " + "the receiving component", el ); } } var ref = getSlotName(slotBinding); var name = ref.name; var dynamic = ref.dynamic; el.slotTarget = name; el.slotTargetDynamic = dynamic; el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf } } else { // v-slot on component, denotes default slot var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE); if (slotBinding$1) { { if (!maybeComponent(el)) { warn$2( "v-slot can only be used on components or <template>.", slotBinding$1 ); } if (el.slotScope || el.slotTarget) { warn$2( "Unexpected mixed usage of different slot syntaxes.", el ); } if (el.scopedSlots) { warn$2( "To avoid scope ambiguity, the default slot should also use " + "<template> syntax when there are other named slots.", slotBinding$1 ); } } // add the component's children to its default slot var slots = el.scopedSlots || (el.scopedSlots = {}); var ref$1 = getSlotName(slotBinding$1); var name$1 = ref$1.name; var dynamic$1 = ref$1.dynamic; var slotContainer = slots[name$1] = createASTElement('template', [], el); slotContainer.slotTarget = name$1; slotContainer.slotTargetDynamic = dynamic$1; slotContainer.children = el.children.filter(function (c) { if (!c.slotScope) { c.parent = slotContainer; returntrue } }); slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken; // remove children as they are returned from scopedSlots now el.children = []; // mark el non-plain so data gets generated el.plain = false; } } } }