.',
+ list[i]
);
}
}
- addAttr(el, name, JSON.stringify(value));
+ addAttr(el, name, JSON.stringify(value), list[i]);
// #6887 firefox doesn't update muted state if set via attribute
// even immediately after element creation
if (!el.component &&
name === 'muted' &&
platformMustUseProp(el.tag, el.attrsMap.type, name)) {
- addProp(el, name, 'true');
+ addProp(el, name, 'true', list[i]);
}
}
}
@@ -10179,10 +10914,9 @@ function makeAttrsMap (attrs) {
var map = {};
for (var i = 0, l = attrs.length; i < l; i++) {
if (
- "development" !== 'production' &&
map[attrs[i].name] && !isIE && !isEdge
) {
- warn$2('duplicate attribute: ' + attrs[i].name);
+ warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
}
map[attrs[i].name] = attrs[i].value;
}
@@ -10229,7 +10963,8 @@ function checkForAliasModel (el, value) {
"You are binding v-model directly to a v-for iteration alias. " +
"This will not be able to modify the v-for source array because " +
"writing to the alias is like modifying a function local variable. " +
- "Consider using an array of objects and use v-model on an object property instead."
+ "Consider using an array of objects and use v-model on an object property instead.",
+ el.rawAttrsMap['v-model']
);
}
_el = _el.parent;
@@ -10238,16 +10973,6 @@ function checkForAliasModel (el, value) {
/* */
-/**
- * Expand input[v-model] with dyanmic type bindings into v-if-else chains
- * Turn this:
- *
- * into this:
- *
- *
- *
- */
-
function preTransformNode (el, options) {
if (el.tag === 'input') {
var map = el.attrsMap;
@@ -10314,21 +11039,21 @@ function cloneASTElement (el) {
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
}
-var model$2 = {
+var model$1 = {
preTransformNode: preTransformNode
-}
+};
var modules$1 = [
klass$1,
style$1,
- model$2
-]
+ model$1
+];
/* */
function text (el, dir) {
if (dir.value) {
- addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
+ addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
}
}
@@ -10336,7 +11061,7 @@ function text (el, dir) {
function html (el, dir) {
if (dir.value) {
- addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
+ addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
}
}
@@ -10344,7 +11069,7 @@ var directives$1 = {
model: model,
text: text,
html: html
-}
+};
/* */
@@ -10391,7 +11116,7 @@ function optimize (root, options) {
function genStaticKeys$1 (keys) {
return makeMap(
- 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
+ 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
(keys ? ',' + keys : '')
)
}
@@ -10491,6 +11216,7 @@ function isDirectChildOfTemplateFor (node) {
/* */
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
+var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// KeyboardEvent.keyCode aliases
@@ -10508,16 +11234,19 @@ var keyCodes = {
// KeyboardEvent.key aliases
var keyNames = {
- esc: 'Escape',
+ // #7880: IE11 and Edge use `Esc` for Escape key name.
+ esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
- space: ' ',
+ // #9112: IE11 uses `Spacebar` for Space key name.
+ space: [' ', 'Spacebar'],
// #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
- 'delete': ['Backspace', 'Delete']
+ // #9112: IE11 uses `Del` for Delete key name.
+ 'delete': ['Backspace', 'Delete', 'Del']
};
// #4868: modifiers that prevent the execution of the listener
@@ -10540,37 +11269,45 @@ var modifierCode = {
function genHandlers (
events,
- isNative,
- warn
+ isNative
) {
- var res = isNative ? 'nativeOn:{' : 'on:{';
+ var prefix = isNative ? 'nativeOn:' : 'on:';
+ var staticHandlers = "";
+ var dynamicHandlers = "";
for (var name in events) {
- res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
+ var handlerCode = genHandler(events[name]);
+ if (events[name] && events[name].dynamic) {
+ dynamicHandlers += name + "," + handlerCode + ",";
+ } else {
+ staticHandlers += "\"" + name + "\":" + handlerCode + ",";
+ }
+ }
+ staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
+ if (dynamicHandlers) {
+ return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
+ } else {
+ return prefix + staticHandlers
}
- return res.slice(0, -1) + '}'
}
-function genHandler (
- name,
- handler
-) {
+function genHandler (handler) {
if (!handler) {
return 'function(){}'
}
if (Array.isArray(handler)) {
- return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
+ return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
}
var isMethodPath = simplePathRE.test(handler.value);
var isFunctionExpression = fnExpRE.test(handler.value);
+ var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
return handler.value
}
- /* istanbul ignore if */
- return ("function($event){" + (handler.value) + "}") // inline statement
+ return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
} else {
var code = '';
var genModifierCode = '';
@@ -10605,14 +11342,21 @@ function genHandler (
? ("return " + (handler.value) + "($event)")
: isFunctionExpression
? ("return (" + (handler.value) + ")($event)")
- : handler.value;
- /* istanbul ignore if */
+ : isFunctionInvocation
+ ? ("return " + (handler.value))
+ : handler.value;
return ("function($event){" + code + handlerCode + "}")
}
}
function genKeyFilter (keys) {
- return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
+ return (
+ // make sure the key filters only apply to KeyboardEvents
+ // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
+ // key events that do not have keyCode property...
+ "if(!$event.type.indexOf('key')&&" +
+ (keys.map(genFilterCode).join('&&')) + ")return null;"
+ )
}
function genFilterCode (key) {
@@ -10635,7 +11379,7 @@ function genFilterCode (key) {
/* */
function on (el, dir) {
- if ("development" !== 'production' && dir.modifiers) {
+ if (dir.modifiers) {
warn("v-on without argument does not support modifiers.");
}
el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
@@ -10655,10 +11399,14 @@ var baseDirectives = {
on: on,
bind: bind$1,
cloak: noop
-}
+};
/* */
+
+
+
+
var CodegenState = function CodegenState (options) {
this.options = options;
this.warn = options.warn || baseWarn;
@@ -10666,9 +11414,10 @@ var CodegenState = function CodegenState (options) {
this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
this.directives = extend(extend({}, baseDirectives), options.directives);
var isReservedTag = options.isReservedTag || no;
- this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
+ this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
this.onceId = 0;
this.staticRenderFns = [];
+ this.pre = false;
};
@@ -10686,6 +11435,10 @@ function generate (
}
function genElement (el, state) {
+ if (el.parent) {
+ el.pre = el.pre || el.parent.pre;
+ }
+
if (el.staticRoot && !el.staticProcessed) {
return genStatic(el, state)
} else if (el.once && !el.onceProcessed) {
@@ -10694,7 +11447,7 @@ function genElement (el, state) {
return genFor(el, state)
} else if (el.if && !el.ifProcessed) {
return genIf(el, state)
- } else if (el.tag === 'template' && !el.slotTarget) {
+ } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
return genChildren(el, state) || 'void 0'
} else if (el.tag === 'slot') {
return genSlot(el, state)
@@ -10704,7 +11457,10 @@ function genElement (el, state) {
if (el.component) {
code = genComponent(el.component, el, state);
} else {
- var data = el.plain ? undefined : genData$2(el, state);
+ var data;
+ if (!el.plain || (el.pre && state.maybeComponent(el))) {
+ data = genData$2(el, state);
+ }
var children = el.inlineTemplate ? null : genChildren(el, state, true);
code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
@@ -10720,7 +11476,15 @@ function genElement (el, state) {
// hoist static sub-trees out
function genStatic (el, state) {
el.staticProcessed = true;
+ // Some elements (templates) need to behave differently inside of a v-pre
+ // node. All pre nodes are static roots, so we can use this as a location to
+ // wrap a state change and reset it upon exiting the pre node.
+ var originalPreState = state.pre;
+ if (el.pre) {
+ state.pre = el.pre;
+ }
state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
+ state.pre = originalPreState;
return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
}
@@ -10740,8 +11504,9 @@ function genOnce (el, state) {
parent = parent.parent;
}
if (!key) {
- "development" !== 'production' && state.warn(
- "v-once can only be used inside v-for that is keyed. "
+ state.warn(
+ "v-once can only be used inside v-for that is keyed. ",
+ el.rawAttrsMap['v-once']
);
return genElement(el, state)
}
@@ -10799,8 +11564,7 @@ function genFor (
var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
- if ("development" !== 'production' &&
- state.maybeComponent(el) &&
+ if (state.maybeComponent(el) &&
el.tag !== 'slot' &&
el.tag !== 'template' &&
!el.key
@@ -10809,6 +11573,7 @@ function genFor (
"<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
"v-for should have explicit keys. " +
"See https://vuejs.org/guide/list.html#key for more info.",
+ el.rawAttrsMap['v-for'],
true /* tip */
);
}
@@ -10853,18 +11618,18 @@ function genData$2 (el, state) {
}
// attributes
if (el.attrs) {
- data += "attrs:{" + (genProps(el.attrs)) + "},";
+ data += "attrs:" + (genProps(el.attrs)) + ",";
}
// DOM props
if (el.props) {
- data += "domProps:{" + (genProps(el.props)) + "},";
+ data += "domProps:" + (genProps(el.props)) + ",";
}
// event handlers
if (el.events) {
- data += (genHandlers(el.events, false, state.warn)) + ",";
+ data += (genHandlers(el.events, false)) + ",";
}
if (el.nativeEvents) {
- data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
+ data += (genHandlers(el.nativeEvents, true)) + ",";
}
// slot target
// only for non-scoped slots
@@ -10873,7 +11638,7 @@ function genData$2 (el, state) {
}
// scoped slots
if (el.scopedSlots) {
- data += (genScopedSlots(el.scopedSlots, state)) + ",";
+ data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
}
// component v-model
if (el.model) {
@@ -10887,6 +11652,12 @@ function genData$2 (el, state) {
}
}
data = data.replace(/,$/, '') + '}';
+ // v-bind dynamic argument wrap
+ // v-bind with dynamic arguments must be applied using the same v-bind object
+ // merge helper so that class/style/mustUseProp attrs are handled correctly.
+ if (el.dynamicAttrs) {
+ data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
+ }
// v-bind data wrap
if (el.wrapData) {
data = el.wrapData(data);
@@ -10915,7 +11686,7 @@ function genDirectives (el, state) {
}
if (needRuntime) {
hasRuntime = true;
- res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
+ res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
}
}
if (hasRuntime) {
@@ -10925,57 +11696,114 @@ function genDirectives (el, state) {
function genInlineTemplate (el, state) {
var ast = el.children[0];
- if ("development" !== 'production' && (
- el.children.length !== 1 || ast.type !== 1
- )) {
- state.warn('Inline-template components must have exactly one child element.');
+ if (el.children.length !== 1 || ast.type !== 1) {
+ state.warn(
+ 'Inline-template components must have exactly one child element.',
+ { start: el.start }
+ );
}
- if (ast.type === 1) {
+ if (ast && ast.type === 1) {
var inlineRenderFns = generate(ast, state.options);
return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
}
}
function genScopedSlots (
+ el,
slots,
state
) {
- return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
- return genScopedSlot(key, slots[key], state)
- }).join(',')) + "])")
+ // by default scoped slots are considered "stable", this allows child
+ // components with only scoped slots to skip forced updates from parent.
+ // but in some cases we have to bail-out of this optimization
+ // for example if the slot contains dynamic names, has v-if or v-for on them...
+ var needsForceUpdate = Object.keys(slots).some(function (key) {
+ var slot = slots[key];
+ return (
+ slot.slotTargetDynamic ||
+ slot.if ||
+ slot.for ||
+ containsSlotChild(slot) // is passing down slot from parent which may be dynamic
+ )
+ });
+
+ // #9534: if a component with scoped slots is inside a conditional branch,
+ // it's possible for the same component to be reused but with different
+ // compiled slot content. To avoid that, we generate a unique key based on
+ // the generated code of all the slot contents.
+ var needsKey = !!el.if;
+
+ // OR when it is inside another scoped slot or v-for (the reactivity may be
+ // disconnected due to the intermediate scope variable)
+ // #9438, #9506
+ // TODO: this can be further optimized by properly analyzing in-scope bindings
+ // and skip force updating ones that do not actually use scope variables.
+ if (!needsForceUpdate) {
+ var parent = el.parent;
+ while (parent) {
+ if (
+ (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
+ parent.for
+ ) {
+ needsForceUpdate = true;
+ break
+ }
+ if (parent.if) {
+ needsKey = true;
+ }
+ parent = parent.parent;
+ }
+ }
+
+ var generatedSlots = Object.keys(slots)
+ .map(function (key) { return genScopedSlot(slots[key], state); })
+ .join(',');
+
+ return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
+}
+
+function hash(str) {
+ var hash = 5381;
+ var i = str.length;
+ while(i) {
+ hash = (hash * 33) ^ str.charCodeAt(--i);
+ }
+ return hash >>> 0
+}
+
+function containsSlotChild (el) {
+ if (el.type === 1) {
+ if (el.tag === 'slot') {
+ return true
+ }
+ return el.children.some(containsSlotChild)
+ }
+ return false
}
function genScopedSlot (
- key,
el,
state
) {
- if (el.for && !el.forProcessed) {
- return genForScopedSlot(key, el, state)
+ var isLegacySyntax = el.attrsMap['slot-scope'];
+ if (el.if && !el.ifProcessed && !isLegacySyntax) {
+ return genIf(el, state, genScopedSlot, "null")
}
- var fn = "function(" + (String(el.slotScope)) + "){" +
+ if (el.for && !el.forProcessed) {
+ return genFor(el, state, genScopedSlot)
+ }
+ var slotScope = el.slotScope === emptySlotScopeToken
+ ? ""
+ : String(el.slotScope);
+ var fn = "function(" + slotScope + "){" +
"return " + (el.tag === 'template'
- ? el.if
- ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
+ ? el.if && isLegacySyntax
+ ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
: genChildren(el, state) || 'undefined'
: genElement(el, state)) + "}";
- return ("{key:" + key + ",fn:" + fn + "}")
-}
-
-function genForScopedSlot (
- key,
- el,
- state
-) {
- var exp = el.for;
- var alias = el.alias;
- var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
- var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
- el.forProcessed = true; // avoid recursion
- return "_l((" + exp + ")," +
- "function(" + alias + iterator1 + iterator2 + "){" +
- "return " + (genScopedSlot(key, el, state)) +
- '})'
+ // reverse proxy v-slot without scope on this.$slots
+ var reverseProxy = slotScope ? "" : ",proxy:true";
+ return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
}
function genChildren (
@@ -10994,13 +11822,16 @@ function genChildren (
el$1.tag !== 'template' &&
el$1.tag !== 'slot'
) {
- return (altGenElement || genElement)(el$1, state)
+ var normalizationType = checkSkip
+ ? state.maybeComponent(el$1) ? ",1" : ",0"
+ : "";
+ return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
}
- var normalizationType = checkSkip
+ var normalizationType$1 = checkSkip
? getNormalizationType(children, state.maybeComponent)
: 0;
var gen = altGenNode || genNode;
- return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
+ return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
}
}
@@ -11038,7 +11869,7 @@ function needsNormalization (el) {
function genNode (node, state) {
if (node.type === 1) {
return genElement(node, state)
- } if (node.type === 3 && node.isComment) {
+ } else if (node.type === 3 && node.isComment) {
return genComment(node)
} else {
return genText(node)
@@ -11059,7 +11890,14 @@ function genSlot (el, state) {
var slotName = el.slotName || '"default"';
var children = genChildren(el, state);
var res = "_t(" + slotName + (children ? ("," + children) : '');
- var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
+ var attrs = el.attrs || el.dynamicAttrs
+ ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
+ // slot props are camelized
+ name: camelize(attr.name),
+ value: attr.value,
+ dynamic: attr.dynamic
+ }); }))
+ : null;
var bind$$1 = el.attrsMap['v-bind'];
if ((attrs || bind$$1) && !children) {
res += ",null";
@@ -11084,15 +11922,23 @@ function genComponent (
}
function genProps (props) {
- var res = '';
+ var staticProps = "";
+ var dynamicProps = "";
for (var i = 0; i < props.length; i++) {
var prop = props[i];
- /* istanbul ignore if */
- {
- res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
+ var value = transformSpecialNewlines(prop.value);
+ if (prop.dynamic) {
+ dynamicProps += (prop.name) + "," + value + ",";
+ } else {
+ staticProps += "\"" + (prop.name) + "\":" + value + ",";
}
}
- return res.slice(0, -1)
+ staticProps = "{" + (staticProps.slice(0, -1)) + "}";
+ if (dynamicProps) {
+ return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
+ } else {
+ return staticProps
+ }
}
// #3895, #4268
@@ -11104,6 +11950,8 @@ function transformSpecialNewlines (text) {
/* */
+
+
// these keywords should not appear inside expressions, but operators like
// typeof, instanceof and in are allowed
var prohibitedKeywordRE = new RegExp('\\b' + (
@@ -11121,89 +11969,92 @@ var unaryOperatorsRE = new RegExp('\\b' + (
var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
// detect problematic expressions in a template
-function detectErrors (ast) {
- var errors = [];
+function detectErrors (ast, warn) {
if (ast) {
- checkNode(ast, errors);
+ checkNode(ast, warn);
}
- return errors
}
-function checkNode (node, errors) {
+function checkNode (node, warn) {
if (node.type === 1) {
for (var name in node.attrsMap) {
if (dirRE.test(name)) {
var value = node.attrsMap[name];
if (value) {
+ var range = node.rawAttrsMap[name];
if (name === 'v-for') {
- checkFor(node, ("v-for=\"" + value + "\""), errors);
+ checkFor(node, ("v-for=\"" + value + "\""), warn, range);
} else if (onRE.test(name)) {
- checkEvent(value, (name + "=\"" + value + "\""), errors);
+ checkEvent(value, (name + "=\"" + value + "\""), warn, range);
} else {
- checkExpression(value, (name + "=\"" + value + "\""), errors);
+ checkExpression(value, (name + "=\"" + value + "\""), warn, range);
}
}
}
}
if (node.children) {
for (var i = 0; i < node.children.length; i++) {
- checkNode(node.children[i], errors);
+ checkNode(node.children[i], warn);
}
}
} else if (node.type === 2) {
- checkExpression(node.expression, node.text, errors);
+ checkExpression(node.expression, node.text, warn, node);
}
}
-function checkEvent (exp, text, errors) {
+function checkEvent (exp, text, warn, range) {
var stipped = exp.replace(stripStringRE, '');
var keywordMatch = stipped.match(unaryOperatorsRE);
if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
- errors.push(
+ warn(
"avoid using JavaScript unary operator as property name: " +
- "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
+ "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
+ range
);
}
- checkExpression(exp, text, errors);
+ checkExpression(exp, text, warn, range);
}
-function checkFor (node, text, errors) {
- checkExpression(node.for || '', text, errors);
- checkIdentifier(node.alias, 'v-for alias', text, errors);
- checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
- checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
+function checkFor (node, text, warn, range) {
+ checkExpression(node.for || '', text, warn, range);
+ checkIdentifier(node.alias, 'v-for alias', text, warn, range);
+ checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
+ checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
}
function checkIdentifier (
ident,
type,
text,
- errors
+ warn,
+ range
) {
if (typeof ident === 'string') {
try {
new Function(("var " + ident + "=_"));
} catch (e) {
- errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
+ warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
}
}
}
-function checkExpression (exp, text, errors) {
+function checkExpression (exp, text, warn, range) {
try {
new Function(("return " + exp));
} catch (e) {
var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
if (keywordMatch) {
- errors.push(
+ warn(
"avoid using JavaScript keyword as property name: " +
- "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
+ "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
+ range
);
} else {
- errors.push(
+ warn(
"invalid expression: " + (e.message) + " in\n\n" +
" " + exp + "\n\n" +
- " Raw expression: " + (text.trim()) + "\n"
+ " Raw expression: " + (text.trim()) + "\n",
+ range
);
}
}
@@ -11211,6 +12062,62 @@ function checkExpression (exp, text, errors) {
/* */
+var range = 2;
+
+function generateCodeFrame (
+ source,
+ start,
+ end
+) {
+ if ( start === void 0 ) start = 0;
+ if ( end === void 0 ) end = source.length;
+
+ var lines = source.split(/\r?\n/);
+ var count = 0;
+ var res = [];
+ for (var i = 0; i < lines.length; i++) {
+ count += lines[i].length + 1;
+ if (count >= start) {
+ for (var j = i - range; j <= i + range || end > count; j++) {
+ if (j < 0 || j >= lines.length) { continue }
+ res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
+ var lineLength = lines[j].length;
+ if (j === i) {
+ // push underline
+ var pad = start - (count - lineLength) + 1;
+ var length = end > count ? lineLength - pad : end - start;
+ res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
+ } else if (j > i) {
+ if (end > count) {
+ var length$1 = Math.min(end - count, lineLength);
+ res.push(" | " + repeat$1("^", length$1));
+ }
+ count += lineLength + 1;
+ }
+ }
+ break
+ }
+ }
+ return res.join('\n')
+}
+
+function repeat$1 (str, n) {
+ var result = '';
+ if (n > 0) {
+ while (true) { // eslint-disable-line
+ if (n & 1) { result += str; }
+ n >>>= 1;
+ if (n <= 0) { break }
+ str += str;
+ }
+ }
+ return result
+}
+
+/* */
+
+
+
function createFunction (code, errors) {
try {
return new Function(code)
@@ -11233,7 +12140,7 @@ function createCompileToFunctionFn (compile) {
delete options.warn;
/* istanbul ignore if */
- if (true) {
+ {
// detect possible CSP restriction
try {
new Function('return 1');
@@ -11262,16 +12169,30 @@ function createCompileToFunctionFn (compile) {
var compiled = compile(template, options);
// check compilation errors/tips
- if (true) {
+ {
if (compiled.errors && compiled.errors.length) {
- warn$$1(
- "Error compiling template:\n\n" + template + "\n\n" +
- compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
- vm
- );
+ if (options.outputSourceRange) {
+ compiled.errors.forEach(function (e) {
+ warn$$1(
+ "Error compiling template:\n\n" + (e.msg) + "\n\n" +
+ generateCodeFrame(template, e.start, e.end),
+ vm
+ );
+ });
+ } else {
+ warn$$1(
+ "Error compiling template:\n\n" + template + "\n\n" +
+ compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
+ vm
+ );
+ }
}
if (compiled.tips && compiled.tips.length) {
- compiled.tips.forEach(function (msg) { return tip(msg, vm); });
+ if (options.outputSourceRange) {
+ compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
+ } else {
+ compiled.tips.forEach(function (msg) { return tip(msg, vm); });
+ }
}
}
@@ -11287,7 +12208,7 @@ function createCompileToFunctionFn (compile) {
// this should only happen if there is a bug in the compiler itself.
// mostly for codegen development use
/* istanbul ignore if */
- if (true) {
+ {
if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
warn$$1(
"Failed to generate render function:\n\n" +
@@ -11317,11 +12238,29 @@ function createCompilerCreator (baseCompile) {
var finalOptions = Object.create(baseOptions);
var errors = [];
var tips = [];
- finalOptions.warn = function (msg, tip) {
+
+ var warn = function (msg, range, tip) {
(tip ? tips : errors).push(msg);
};
if (options) {
+ if (options.outputSourceRange) {
+ // $flow-disable-line
+ var leadingSpaceLength = template.match(/^\s*/)[0].length;
+
+ warn = function (msg, range, tip) {
+ var data = { msg: msg };
+ if (range) {
+ if (range.start != null) {
+ data.start = range.start + leadingSpaceLength;
+ }
+ if (range.end != null) {
+ data.end = range.end + leadingSpaceLength;
+ }
+ }
+ (tip ? tips : errors).push(data);
+ };
+ }
// merge custom modules
if (options.modules) {
finalOptions.modules =
@@ -11342,9 +12281,11 @@ function createCompilerCreator (baseCompile) {
}
}
- var compiled = baseCompile(template, finalOptions);
- if (true) {
- errors.push.apply(errors, detectErrors(compiled.ast));
+ finalOptions.warn = warn;
+
+ var compiled = baseCompile(template.trim(), finalOptions);
+ {
+ detectErrors(compiled.ast, warn);
}
compiled.errors = errors;
compiled.tips = tips;
@@ -11382,6 +12323,7 @@ var createCompiler = createCompilerCreator(function baseCompile (
/* */
var ref$1 = createCompiler(baseOptions);
+var compile = ref$1.compile;
var compileToFunctions = ref$1.compileToFunctions;
/* */
@@ -11415,7 +12357,7 @@ Vue.prototype.$mount = function (
/* istanbul ignore if */
if (el === document.body || el === document.documentElement) {
- "development" !== 'production' && warn(
+ warn(
"Do not mount Vue to or - mount to normal elements instead."
);
return this
@@ -11430,7 +12372,7 @@ Vue.prototype.$mount = function (
if (template.charAt(0) === '#') {
template = idToTemplate(template);
/* istanbul ignore if */
- if ("development" !== 'production' && !template) {
+ if (!template) {
warn(
("Template element not found or is empty: " + (options.template)),
this
@@ -11440,7 +12382,7 @@ Vue.prototype.$mount = function (
} else if (template.nodeType) {
template = template.innerHTML;
} else {
- if (true) {
+ {
warn('invalid template option:' + template, this);
}
return this
@@ -11450,11 +12392,12 @@ Vue.prototype.$mount = function (
}
if (template) {
/* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
+ if (config.performance && mark) {
mark('compile');
}
var ref = compileToFunctions(template, {
+ outputSourceRange: "development" !== 'production',
shouldDecodeNewlines: shouldDecodeNewlines,
shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
delimiters: options.delimiters,
@@ -11466,7 +12409,7 @@ Vue.prototype.$mount = function (
options.staticRenderFns = staticRenderFns;
/* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
+ if (config.performance && mark) {
mark('compile end');
measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
}
@@ -11495,6 +12438,18 @@ module.exports = Vue;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js"), __webpack_require__("./node_modules/timers-browserify/main.js").setImmediate))
+/***/ }),
+
+/***/ "./node_modules/vue/dist/vue.common.js":
+/***/ (function(module, exports, __webpack_require__) {
+
+if (false) {
+ module.exports = require('./vue.common.prod.js')
+} else {
+ module.exports = __webpack_require__("./node_modules/vue/dist/vue.common.dev.js")
+}
+
+
/***/ }),
/***/ "./node_modules/webpack/buildin/global.js":
diff --git a/public/js/localization.min.js b/public/js/localization.min.js
index 2eb5f8193602..1a6c7dc78363 100644
--- a/public/js/localization.min.js
+++ b/public/js/localization.min.js
@@ -530,13 +530,13 @@ o[t.label]=e,o)),t._v(" "),t.multiple?n("button",{staticClass:"close",attrs:{dis
/***/ }),
-/***/ "./node_modules/vue/dist/vue.common.js":
+/***/ "./node_modules/vue/dist/vue.common.dev.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
- * Vue.js v2.5.17
- * (c) 2014-2018 Evan You
+ * Vue.js v2.6.7
+ * (c) 2014-2019 Evan You
* Released under the MIT License.
*/
@@ -545,8 +545,8 @@ o[t.label]=e,o)),t._v(" "),t.multiple?n("button",{staticClass:"close",attrs:{dis
var emptyObject = Object.freeze({});
-// these helpers produces better vm code in JS engines due to their
-// explicitness and function inlining
+// These helpers produce better VM code in JS engines due to their
+// explicitness and function inlining.
function isUndef (v) {
return v === undefined || v === null
}
@@ -564,7 +564,7 @@ function isFalse (v) {
}
/**
- * Check if value is primitive
+ * Check if value is primitive.
*/
function isPrimitive (value) {
return (
@@ -586,7 +586,7 @@ function isObject (obj) {
}
/**
- * Get the raw type string of a value e.g. [object Object]
+ * Get the raw type string of a value, e.g., [object Object].
*/
var _toString = Object.prototype.toString;
@@ -614,19 +614,27 @@ function isValidArrayIndex (val) {
return n >= 0 && Math.floor(n) === n && isFinite(val)
}
+function isPromise (val) {
+ return (
+ isDef(val) &&
+ typeof val.then === 'function' &&
+ typeof val.catch === 'function'
+ )
+}
+
/**
* Convert a value to a string that is actually rendered.
*/
function toString (val) {
return val == null
? ''
- : typeof val === 'object'
+ : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
? JSON.stringify(val, null, 2)
: String(val)
}
/**
- * Convert a input value to a number for persistence.
+ * Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
function toNumber (val) {
@@ -658,12 +666,12 @@ function makeMap (
var isBuiltInTag = makeMap('slot,component', true);
/**
- * Check if a attribute is a reserved attribute.
+ * Check if an attribute is a reserved attribute.
*/
var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
/**
- * Remove an item from an array
+ * Remove an item from an array.
*/
function remove (arr, item) {
if (arr.length) {
@@ -675,7 +683,7 @@ function remove (arr, item) {
}
/**
- * Check whether the object has the property.
+ * Check whether an object has the property.
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
@@ -717,11 +725,11 @@ var hyphenate = cached(function (str) {
});
/**
- * Simple bind polyfill for environments that do not support it... e.g.
- * PhantomJS 1.x. Technically we don't need this anymore since native bind is
- * now more performant in most browsers, but removing it would be breaking for
- * code that was able to run in PhantomJS 1.x, so this must be kept for
- * backwards compatibility.
+ * Simple bind polyfill for environments that do not support it,
+ * e.g., PhantomJS 1.x. Technically, we don't need this anymore
+ * since native bind is now performant enough in most browsers.
+ * But removing it would mean breaking code that was able to run in
+ * PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/* istanbul ignore next */
@@ -783,10 +791,12 @@ function toObject (arr) {
return res
}
+/* eslint-disable no-unused-vars */
+
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
- * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
+ * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
function noop (a, b, c) {}
@@ -795,13 +805,15 @@ function noop (a, b, c) {}
*/
var no = function (a, b, c) { return false; };
+/* eslint-enable no-unused-vars */
+
/**
- * Return same value
+ * Return the same value.
*/
var identity = function (_) { return _; };
/**
- * Generate a static keys string from compiler modules.
+ * Generate a string containing static keys from compiler modules.
*/
function genStaticKeys (modules) {
return modules.reduce(function (keys, m) {
@@ -825,6 +837,8 @@ function looseEqual (a, b) {
return a.length === b.length && a.every(function (e, i) {
return looseEqual(e, b[i])
})
+ } else if (a instanceof Date && b instanceof Date) {
+ return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) {
var keysA = Object.keys(a);
var keysB = Object.keys(b);
@@ -846,6 +860,11 @@ function looseEqual (a, b) {
}
}
+/**
+ * Return the first index at which a loosely equal value can be
+ * found in the array (if value is a plain object, the array must
+ * contain an object of the same shape), or -1 if it is not present.
+ */
function looseIndexOf (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val)) { return i }
@@ -885,11 +904,14 @@ var LIFECYCLE_HOOKS = [
'destroyed',
'activated',
'deactivated',
- 'errorCaptured'
+ 'errorCaptured',
+ 'serverPrefetch'
];
/* */
+
+
var config = ({
/**
* Option merge strategies (used in core/util/options)
@@ -972,14 +994,27 @@ var config = ({
*/
mustUseProp: no,
+ /**
+ * Perform updates asynchronously. Intended to be used by Vue Test Utils
+ * This will significantly reduce performance if set to false.
+ */
+ async: true,
+
/**
* Exposed for legacy reasons
*/
_lifecycleHooks: LIFECYCLE_HOOKS
-})
+});
/* */
+/**
+ * unicode letters used for parsing html tags, component names and property paths.
+ * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
+ * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
+ */
+var unicodeLetters = 'a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD';
+
/**
* Check if a string starts with $ or _
*/
@@ -1003,7 +1038,7 @@ function def (obj, key, val, enumerable) {
/**
* Parse simple path.
*/
-var bailRE = /[^\w.$]/;
+var bailRE = new RegExp(("[^" + unicodeLetters + ".$_\\d]"));
function parsePath (path) {
if (bailRE.test(path)) {
return
@@ -1034,6 +1069,8 @@ var isEdge = UA && UA.indexOf('edge/') > 0;
var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
+var isPhantomJS = UA && /phantomjs/.test(UA);
+var isFF = UA && UA.match(/firefox\/(\d+)/);
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
@@ -1061,7 +1098,7 @@ var isServerRendering = function () {
if (!inBrowser && !inWeex && typeof global !== 'undefined') {
// detect presence of vue-server-renderer and avoid
// Webpack shimming the process
- _isServer = global['process'].env.VUE_ENV === 'server';
+ _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
} else {
_isServer = false;
}
@@ -1088,7 +1125,7 @@ if (typeof Set !== 'undefined' && isNative(Set)) {
_Set = Set;
} else {
// a non-standard Set polyfill that only works with primitive keys.
- _Set = (function () {
+ _Set = /*@__PURE__*/(function () {
function Set () {
this.set = Object.create(null);
}
@@ -1113,7 +1150,7 @@ var tip = noop;
var generateComponentTrace = (noop); // work around flow check
var formatComponentName = (noop);
-if (true) {
+{
var hasConsole = typeof console !== 'undefined';
var classifyRE = /(?:^|[-_])(\w)/g;
var classify = function (str) { return str
@@ -1146,7 +1183,7 @@ if (true) {
? vm.options
: vm._isVue
? vm.$options || vm.constructor.options
- : vm || {};
+ : vm;
var name = options.name || options._componentTag;
var file = options.__file;
if (!name && file) {
@@ -1202,7 +1239,6 @@ if (true) {
/* */
-
var uid = 0;
/**
@@ -1231,24 +1267,31 @@ Dep.prototype.depend = function depend () {
Dep.prototype.notify = function notify () {
// stabilize the subscriber list first
var subs = this.subs.slice();
+ if (!config.async) {
+ // subs aren't sorted in scheduler if not running async
+ // we need to sort them now to make sure they fire in correct
+ // order
+ subs.sort(function (a, b) { return a.id - b.id; });
+ }
for (var i = 0, l = subs.length; i < l; i++) {
subs[i].update();
}
};
-// the current target watcher being evaluated.
-// this is globally unique because there could be only one
-// watcher being evaluated at any time.
+// The current target watcher being evaluated.
+// This is globally unique because only one watcher
+// can be evaluated at a time.
Dep.target = null;
var targetStack = [];
-function pushTarget (_target) {
- if (Dep.target) { targetStack.push(Dep.target); }
- Dep.target = _target;
+function pushTarget (target) {
+ targetStack.push(target);
+ Dep.target = target;
}
function popTarget () {
- Dep.target = targetStack.pop();
+ targetStack.pop();
+ Dep.target = targetStack[targetStack.length - 1];
}
/* */
@@ -1319,7 +1362,10 @@ function cloneVNode (vnode) {
var cloned = new VNode(
vnode.tag,
vnode.data,
- vnode.children,
+ // #7975
+ // clone children array to avoid mutating original in case of cloning
+ // a child.
+ vnode.children && vnode.children.slice(),
vnode.text,
vnode.elm,
vnode.context,
@@ -1333,6 +1379,7 @@ function cloneVNode (vnode) {
cloned.fnContext = vnode.fnContext;
cloned.fnOptions = vnode.fnOptions;
cloned.fnScopeId = vnode.fnScopeId;
+ cloned.asyncMeta = vnode.asyncMeta;
cloned.isCloned = true;
return cloned
}
@@ -1410,10 +1457,11 @@ var Observer = function Observer (value) {
this.vmCount = 0;
def(value, '__ob__', this);
if (Array.isArray(value)) {
- var augment = hasProto
- ? protoAugment
- : copyAugment;
- augment(value, arrayMethods, arrayKeys);
+ if (hasProto) {
+ protoAugment(value, arrayMethods);
+ } else {
+ copyAugment(value, arrayMethods, arrayKeys);
+ }
this.observeArray(value);
} else {
this.walk(value);
@@ -1421,14 +1469,14 @@ var Observer = function Observer (value) {
};
/**
- * Walk through each property and convert them into
+ * Walk through all properties and convert them into
* getter/setters. This method should only be called when
* value type is Object.
*/
Observer.prototype.walk = function walk (obj) {
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
- defineReactive(obj, keys[i]);
+ defineReactive$$1(obj, keys[i]);
}
};
@@ -1444,17 +1492,17 @@ Observer.prototype.observeArray = function observeArray (items) {
// helpers
/**
- * Augment an target Object or Array by intercepting
+ * Augment a target Object or Array by intercepting
* the prototype chain using __proto__
*/
-function protoAugment (target, src, keys) {
+function protoAugment (target, src) {
/* eslint-disable no-proto */
target.__proto__ = src;
/* eslint-enable no-proto */
}
/**
- * Augment an target Object or Array by defining
+ * Augment a target Object or Array by defining
* hidden properties.
*/
/* istanbul ignore next */
@@ -1495,7 +1543,7 @@ function observe (value, asRootData) {
/**
* Define a reactive property on an Object.
*/
-function defineReactive (
+function defineReactive$$1 (
obj,
key,
val,
@@ -1511,10 +1559,10 @@ function defineReactive (
// cater for pre-defined getter/setters
var getter = property && property.get;
- if (!getter && arguments.length === 2) {
+ var setter = property && property.set;
+ if ((!getter || setter) && arguments.length === 2) {
val = obj[key];
}
- var setter = property && property.set;
var childOb = !shallow && observe(val);
Object.defineProperty(obj, key, {
@@ -1540,9 +1588,11 @@ function defineReactive (
return
}
/* eslint-enable no-self-compare */
- if ("development" !== 'production' && customSetter) {
+ if (customSetter) {
customSetter();
}
+ // #7981: for accessor properties without setter
+ if (getter && !setter) { return }
if (setter) {
setter.call(obj, newVal);
} else {
@@ -1560,8 +1610,7 @@ function defineReactive (
* already exist.
*/
function set (target, key, val) {
- if ("development" !== 'production' &&
- (isUndef(target) || isPrimitive(target))
+ if (isUndef(target) || isPrimitive(target)
) {
warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
}
@@ -1576,7 +1625,7 @@ function set (target, key, val) {
}
var ob = (target).__ob__;
if (target._isVue || (ob && ob.vmCount)) {
- "development" !== 'production' && warn(
+ warn(
'Avoid adding reactive properties to a Vue instance or its root $data ' +
'at runtime - declare it upfront in the data option.'
);
@@ -1586,7 +1635,7 @@ function set (target, key, val) {
target[key] = val;
return val
}
- defineReactive(ob.value, key, val);
+ defineReactive$$1(ob.value, key, val);
ob.dep.notify();
return val
}
@@ -1595,8 +1644,7 @@ function set (target, key, val) {
* Delete a property and trigger change if necessary.
*/
function del (target, key) {
- if ("development" !== 'production' &&
- (isUndef(target) || isPrimitive(target))
+ if (isUndef(target) || isPrimitive(target)
) {
warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
}
@@ -1606,7 +1654,7 @@ function del (target, key) {
}
var ob = (target).__ob__;
if (target._isVue || (ob && ob.vmCount)) {
- "development" !== 'production' && warn(
+ warn(
'Avoid deleting properties on a Vue instance or its root $data ' +
'- just set it to null.'
);
@@ -1648,7 +1696,7 @@ var strats = config.optionMergeStrategies;
/**
* Options with restrictions
*/
-if (true) {
+{
strats.el = strats.propsData = function (parent, child, vm, key) {
if (!vm) {
warn(
@@ -1666,14 +1714,24 @@ if (true) {
function mergeData (to, from) {
if (!from) { return to }
var key, toVal, fromVal;
- var keys = Object.keys(from);
+
+ var keys = hasSymbol
+ ? Reflect.ownKeys(from)
+ : Object.keys(from);
+
for (var i = 0; i < keys.length; i++) {
key = keys[i];
+ // in case the object is already observed...
+ if (key === '__ob__') { continue }
toVal = to[key];
fromVal = from[key];
if (!hasOwn(to, key)) {
set(to, key, fromVal);
- } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
+ } else if (
+ toVal !== fromVal &&
+ isPlainObject(toVal) &&
+ isPlainObject(fromVal)
+ ) {
mergeData(toVal, fromVal);
}
}
@@ -1732,7 +1790,7 @@ strats.data = function (
) {
if (!vm) {
if (childVal && typeof childVal !== 'function') {
- "development" !== 'production' && warn(
+ warn(
'The "data" option should be a function ' +
'that returns a per-instance value in component ' +
'definitions.',
@@ -1754,13 +1812,26 @@ function mergeHook (
parentVal,
childVal
) {
- return childVal
+ var res = childVal
? parentVal
? parentVal.concat(childVal)
: Array.isArray(childVal)
? childVal
: [childVal]
- : parentVal
+ : parentVal;
+ return res
+ ? dedupeHooks(res)
+ : res
+}
+
+function dedupeHooks (hooks) {
+ var res = [];
+ for (var i = 0; i < hooks.length; i++) {
+ if (res.indexOf(hooks[i]) === -1) {
+ res.push(hooks[i]);
+ }
+ }
+ return res
}
LIFECYCLE_HOOKS.forEach(function (hook) {
@@ -1782,7 +1853,7 @@ function mergeAssets (
) {
var res = Object.create(parentVal || null);
if (childVal) {
- "development" !== 'production' && assertObjectType(key, childVal, vm);
+ assertObjectType(key, childVal, vm);
return extend(res, childVal)
} else {
return res
@@ -1810,7 +1881,7 @@ strats.watch = function (
if (childVal === nativeWatch) { childVal = undefined; }
/* istanbul ignore if */
if (!childVal) { return Object.create(parentVal || null) }
- if (true) {
+ {
assertObjectType(key, childVal, vm);
}
if (!parentVal) { return childVal }
@@ -1871,11 +1942,10 @@ function checkComponents (options) {
}
function validateComponentName (name) {
- if (!/^[a-zA-Z][\w-]*$/.test(name)) {
+ if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + unicodeLetters + "]*$")).test(name)) {
warn(
'Invalid component name: "' + name + '". Component names ' +
- 'can only contain alphanumeric characters and the hyphen, ' +
- 'and must start with a letter.'
+ 'should conform to valid custom element name in html5 specification.'
);
}
if (isBuiltInTag(name) || config.isReservedTag(name)) {
@@ -1902,7 +1972,7 @@ function normalizeProps (options, vm) {
if (typeof val === 'string') {
name = camelize(val);
res[name] = { type: null };
- } else if (true) {
+ } else {
warn('props must be strings when using array syntax.');
}
}
@@ -1914,7 +1984,7 @@ function normalizeProps (options, vm) {
? val
: { type: val };
}
- } else if (true) {
+ } else {
warn(
"Invalid value for option \"props\": expected an Array or an Object, " +
"but got " + (toRawType(props)) + ".",
@@ -1942,7 +2012,7 @@ function normalizeInject (options, vm) {
? extend({ from: key }, val)
: { from: val };
}
- } else if (true) {
+ } else {
warn(
"Invalid value for option \"inject\": expected an Array or an Object, " +
"but got " + (toRawType(inject)) + ".",
@@ -1958,9 +2028,9 @@ function normalizeDirectives (options) {
var dirs = options.directives;
if (dirs) {
for (var key in dirs) {
- var def = dirs[key];
- if (typeof def === 'function') {
- dirs[key] = { bind: def, update: def };
+ var def$$1 = dirs[key];
+ if (typeof def$$1 === 'function') {
+ dirs[key] = { bind: def$$1, update: def$$1 };
}
}
}
@@ -1985,7 +2055,7 @@ function mergeOptions (
child,
vm
) {
- if (true) {
+ {
checkComponents(child);
}
@@ -1996,15 +2066,22 @@ function mergeOptions (
normalizeProps(child, vm);
normalizeInject(child, vm);
normalizeDirectives(child);
- var extendsFrom = child.extends;
- if (extendsFrom) {
- parent = mergeOptions(parent, extendsFrom, vm);
- }
- if (child.mixins) {
- for (var i = 0, l = child.mixins.length; i < l; i++) {
- parent = mergeOptions(parent, child.mixins[i], vm);
+
+ // Apply extends and mixins on the child options,
+ // but only if it is a raw options object that isn't
+ // the result of another mergeOptions call.
+ // Only merged options has the _base property.
+ if (!child._base) {
+ if (child.extends) {
+ parent = mergeOptions(parent, child.extends, vm);
+ }
+ if (child.mixins) {
+ for (var i = 0, l = child.mixins.length; i < l; i++) {
+ parent = mergeOptions(parent, child.mixins[i], vm);
+ }
}
}
+
var options = {};
var key;
for (key in parent) {
@@ -2046,7 +2123,7 @@ function resolveAsset (
if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
// fallback to prototype chain
var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
- if ("development" !== 'production' && warnMissing && !res) {
+ if (warnMissing && !res) {
warn(
'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
options
@@ -2057,6 +2134,8 @@ function resolveAsset (
/* */
+
+
function validateProp (
key,
propOptions,
@@ -2090,9 +2169,7 @@ function validateProp (
observe(value);
toggleObserving(prevShouldObserve);
}
- if (
- true
- ) {
+ {
assertProp(prop, key, value, vm, absent);
}
return value
@@ -2108,7 +2185,7 @@ function getPropDefaultValue (vm, prop, key) {
}
var def = prop.default;
// warn against non-factory defaults for Object & Array
- if ("development" !== 'production' && isObject(def)) {
+ if (isObject(def)) {
warn(
'Invalid default value for prop "' + key + '": ' +
'Props with type Object/Array must use a factory function ' +
@@ -2164,11 +2241,10 @@ function assertProp (
valid = assertedType.valid;
}
}
+
if (!valid) {
warn(
- "Invalid prop: type check failed for prop \"" + name + "\"." +
- " Expected " + (expectedTypes.map(capitalize).join(', ')) +
- ", got " + (toRawType(value)) + ".",
+ getInvalidTypeMessage(name, value, expectedTypes),
vm
);
return
@@ -2235,26 +2311,97 @@ function getTypeIndex (type, expectedTypes) {
return -1
}
+function getInvalidTypeMessage (name, value, expectedTypes) {
+ var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
+ " Expected " + (expectedTypes.map(capitalize).join(', '));
+ var expectedType = expectedTypes[0];
+ var receivedType = toRawType(value);
+ var expectedValue = styleValue(value, expectedType);
+ var receivedValue = styleValue(value, receivedType);
+ // check if we need to specify expected value
+ if (expectedTypes.length === 1 &&
+ isExplicable(expectedType) &&
+ !isBoolean(expectedType, receivedType)) {
+ message += " with value " + expectedValue;
+ }
+ message += ", got " + receivedType + " ";
+ // check if we need to specify received value
+ if (isExplicable(receivedType)) {
+ message += "with value " + receivedValue + ".";
+ }
+ return message
+}
+
+function styleValue (value, type) {
+ if (type === 'String') {
+ return ("\"" + value + "\"")
+ } else if (type === 'Number') {
+ return ("" + (Number(value)))
+ } else {
+ return ("" + value)
+ }
+}
+
+function isExplicable (value) {
+ var explicitTypes = ['string', 'number', 'boolean'];
+ return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
+}
+
+function isBoolean () {
+ var args = [], len = arguments.length;
+ while ( len-- ) args[ len ] = arguments[ len ];
+
+ return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
+}
+
/* */
function handleError (err, vm, info) {
- if (vm) {
- var cur = vm;
- while ((cur = cur.$parent)) {
- var hooks = cur.$options.errorCaptured;
- if (hooks) {
- for (var i = 0; i < hooks.length; i++) {
- try {
- var capture = hooks[i].call(cur, err, vm, info) === false;
- if (capture) { return }
- } catch (e) {
- globalHandleError(e, cur, 'errorCaptured hook');
+ // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
+ // See: https://github.com/vuejs/vuex/issues/1505
+ pushTarget();
+ try {
+ if (vm) {
+ var cur = vm;
+ while ((cur = cur.$parent)) {
+ var hooks = cur.$options.errorCaptured;
+ if (hooks) {
+ for (var i = 0; i < hooks.length; i++) {
+ try {
+ var capture = hooks[i].call(cur, err, vm, info) === false;
+ if (capture) { return }
+ } catch (e) {
+ globalHandleError(e, cur, 'errorCaptured hook');
+ }
}
}
}
}
+ globalHandleError(err, vm, info);
+ } finally {
+ popTarget();
}
- globalHandleError(err, vm, info);
+}
+
+function invokeWithErrorHandling (
+ handler,
+ context,
+ args,
+ vm,
+ info
+) {
+ var res;
+ try {
+ res = args ? handler.apply(context, args) : handler.call(context);
+ if (res && !res._isVue && isPromise(res)) {
+ // issue #9511
+ // reassign to res to avoid catch triggering multiple times when nested calls
+ res = res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
+ }
+ } catch (e) {
+ handleError(e, vm, info);
+ }
+ return res
}
function globalHandleError (err, vm, info) {
@@ -2262,14 +2409,18 @@ function globalHandleError (err, vm, info) {
try {
return config.errorHandler.call(null, err, vm, info)
} catch (e) {
- logError(e, null, 'config.errorHandler');
+ // if the user intentionally throws the original error in the handler,
+ // do not log it twice
+ if (e !== err) {
+ logError(e, null, 'config.errorHandler');
+ }
}
}
logError(err, vm, info);
}
function logError (err, vm, info) {
- if (true) {
+ {
warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
}
/* istanbul ignore else */
@@ -2281,7 +2432,8 @@ function logError (err, vm, info) {
}
/* */
-/* globals MessageChannel */
+
+var isUsingMicroTask = false;
var callbacks = [];
var pending = false;
@@ -2295,74 +2447,69 @@ function flushCallbacks () {
}
}
-// Here we have async deferring wrappers using both microtasks and (macro) tasks.
-// In < 2.4 we used microtasks everywhere, but there are some scenarios where
-// microtasks have too high a priority and fire in between supposedly
-// sequential events (e.g. #4521, #6690) or even between bubbling of the same
-// event (#6566). However, using (macro) tasks everywhere also has subtle problems
-// when state is changed right before repaint (e.g. #6813, out-in transitions).
-// Here we use microtask by default, but expose a way to force (macro) task when
-// needed (e.g. in event handlers attached by v-on).
-var microTimerFunc;
-var macroTimerFunc;
-var useMacroTask = false;
+// Here we have async deferring wrappers using microtasks.
+// In 2.5 we used (macro) tasks (in combination with microtasks).
+// However, it has subtle problems when state is changed right before repaint
+// (e.g. #6813, out-in transitions).
+// Also, using (macro) tasks in event handler would cause some weird behaviors
+// that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
+// So we now use microtasks everywhere, again.
+// A major drawback of this tradeoff is that there are some scenarios
+// where microtasks have too high a priority and fire in between supposedly
+// sequential events (e.g. #4521, #6690, which have workarounds)
+// or even between bubbling of the same event (#6566).
+var timerFunc;
-// Determine (macro) task defer implementation.
-// Technically setImmediate should be the ideal choice, but it's only available
-// in IE. The only polyfill that consistently queues the callback after all DOM
-// events triggered in the same loop is by using MessageChannel.
-/* istanbul ignore if */
-if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
- macroTimerFunc = function () {
- setImmediate(flushCallbacks);
- };
-} else if (typeof MessageChannel !== 'undefined' && (
- isNative(MessageChannel) ||
- // PhantomJS
- MessageChannel.toString() === '[object MessageChannelConstructor]'
-)) {
- var channel = new MessageChannel();
- var port = channel.port2;
- channel.port1.onmessage = flushCallbacks;
- macroTimerFunc = function () {
- port.postMessage(1);
- };
-} else {
- /* istanbul ignore next */
- macroTimerFunc = function () {
- setTimeout(flushCallbacks, 0);
- };
-}
-
-// Determine microtask defer implementation.
+// The nextTick behavior leverages the microtask queue, which can be accessed
+// via either native Promise.then or MutationObserver.
+// MutationObserver has wider support, however it is seriously bugged in
+// UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
+// completely stops working after triggering a few times... so, if native
+// Promise is available, we will use it:
/* istanbul ignore next, $flow-disable-line */
if (typeof Promise !== 'undefined' && isNative(Promise)) {
var p = Promise.resolve();
- microTimerFunc = function () {
+ timerFunc = function () {
p.then(flushCallbacks);
- // in problematic UIWebViews, Promise.then doesn't completely break, but
+ // In problematic UIWebViews, Promise.then doesn't completely break, but
// it can get stuck in a weird state where callbacks are pushed into the
// microtask queue but the queue isn't being flushed, until the browser
// needs to do some other work, e.g. handle a timer. Therefore we can
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
+ isUsingMicroTask = true;
+} else if (!isIE && typeof MutationObserver !== 'undefined' && (
+ isNative(MutationObserver) ||
+ // PhantomJS and iOS 7.x
+ MutationObserver.toString() === '[object MutationObserverConstructor]'
+)) {
+ // Use MutationObserver where native Promise is not available,
+ // e.g. PhantomJS, iOS7, Android 4.4
+ // (#6466 MutationObserver is unreliable in IE11)
+ var counter = 1;
+ var observer = new MutationObserver(flushCallbacks);
+ var textNode = document.createTextNode(String(counter));
+ observer.observe(textNode, {
+ characterData: true
+ });
+ timerFunc = function () {
+ counter = (counter + 1) % 2;
+ textNode.data = String(counter);
+ };
+ isUsingMicroTask = true;
+} else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
+ // Fallback to setImmediate.
+ // Techinically it leverages the (macro) task queue,
+ // but it is still a better choice than setTimeout.
+ timerFunc = function () {
+ setImmediate(flushCallbacks);
+ };
} else {
- // fallback to macro
- microTimerFunc = macroTimerFunc;
-}
-
-/**
- * Wrap a function so that if any code inside triggers state change,
- * the changes are queued using a (macro) task instead of a microtask.
- */
-function withMacroTask (fn) {
- return fn._withTask || (fn._withTask = function () {
- useMacroTask = true;
- var res = fn.apply(null, arguments);
- useMacroTask = false;
- return res
- })
+ // Fallback to setTimeout.
+ timerFunc = function () {
+ setTimeout(flushCallbacks, 0);
+ };
}
function nextTick (cb, ctx) {
@@ -2380,11 +2527,7 @@ function nextTick (cb, ctx) {
});
if (!pending) {
pending = true;
- if (useMacroTask) {
- macroTimerFunc();
- } else {
- microTimerFunc();
- }
+ timerFunc();
}
// $flow-disable-line
if (!cb && typeof Promise !== 'undefined') {
@@ -2399,7 +2542,7 @@ function nextTick (cb, ctx) {
var mark;
var measure;
-if (true) {
+{
var perf = inBrowser && window.performance;
/* istanbul ignore if */
if (
@@ -2414,7 +2557,7 @@ if (true) {
perf.measure(name, startTag, endTag);
perf.clearMarks(startTag);
perf.clearMarks(endTag);
- perf.clearMeasures(name);
+ // perf.clearMeasures(name)
};
}
}
@@ -2423,7 +2566,7 @@ if (true) {
var initProxy;
-if (true) {
+{
var allowedGlobals = makeMap(
'Infinity,undefined,NaN,isFinite,isNaN,' +
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
@@ -2442,6 +2585,16 @@ if (true) {
);
};
+ var warnReservedPrefix = function (target, key) {
+ warn(
+ "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
+ 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
+ 'prevent conflicts with Vue internals' +
+ 'See: https://vuejs.org/v2/api/#data',
+ target
+ );
+ };
+
var hasProxy =
typeof Proxy !== 'undefined' && isNative(Proxy);
@@ -2463,9 +2616,11 @@ if (true) {
var hasHandler = {
has: function has (target, key) {
var has = key in target;
- var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
+ var isAllowed = allowedGlobals(key) ||
+ (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
if (!has && !isAllowed) {
- warnNonPresent(target, key);
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
}
return has || !isAllowed
}
@@ -2474,7 +2629,8 @@ if (true) {
var getHandler = {
get: function get (target, key) {
if (typeof key === 'string' && !(key in target)) {
- warnNonPresent(target, key);
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
}
return target[key]
}
@@ -2548,7 +2704,7 @@ var normalizeEvent = cached(function (name) {
}
});
-function createFnInvoker (fns) {
+function createFnInvoker (fns, vm) {
function invoker () {
var arguments$1 = arguments;
@@ -2556,11 +2712,11 @@ function createFnInvoker (fns) {
if (Array.isArray(fns)) {
var cloned = fns.slice();
for (var i = 0; i < cloned.length; i++) {
- cloned[i].apply(null, arguments$1);
+ invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
}
} else {
// return handler return value for single handlers
- return fns.apply(null, arguments)
+ return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
}
}
invoker.fns = fns;
@@ -2572,24 +2728,27 @@ function updateListeners (
oldOn,
add,
remove$$1,
+ createOnceHandler,
vm
) {
- var name, def, cur, old, event;
+ var name, def$$1, cur, old, event;
for (name in on) {
- def = cur = on[name];
+ def$$1 = cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
- /* istanbul ignore if */
if (isUndef(cur)) {
- "development" !== 'production' && warn(
+ warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
vm
);
} else if (isUndef(old)) {
if (isUndef(cur.fns)) {
- cur = on[name] = createFnInvoker(cur);
+ cur = on[name] = createFnInvoker(cur, vm);
}
- add(event.name, cur, event.once, event.capture, event.passive, event.params);
+ if (isTrue(event.once)) {
+ cur = on[name] = createOnceHandler(event.name, cur, event.capture);
+ }
+ add(event.name, cur, event.capture, event.passive, event.params);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
@@ -2658,7 +2817,7 @@ function extractPropsFromVNodeData (
if (isDef(attrs) || isDef(props)) {
for (var key in propOptions) {
var altKey = hyphenate(key);
- if (true) {
+ {
var keyInLowerCase = key.toLowerCase();
if (
key !== keyInLowerCase &&
@@ -2795,290 +2954,70 @@ function normalizeArrayChildren (children, nestedIndex) {
/* */
-function ensureCtor (comp, base) {
- if (
- comp.__esModule ||
- (hasSymbol && comp[Symbol.toStringTag] === 'Module')
- ) {
- comp = comp.default;
+function initProvide (vm) {
+ var provide = vm.$options.provide;
+ if (provide) {
+ vm._provided = typeof provide === 'function'
+ ? provide.call(vm)
+ : provide;
}
- return isObject(comp)
- ? base.extend(comp)
- : comp
}
-function createAsyncPlaceholder (
- factory,
- data,
- context,
- children,
- tag
-) {
- var node = createEmptyVNode();
- node.asyncFactory = factory;
- node.asyncMeta = { data: data, context: context, children: children, tag: tag };
- return node
-}
-
-function resolveAsyncComponent (
- factory,
- baseCtor,
- context
-) {
- if (isTrue(factory.error) && isDef(factory.errorComp)) {
- return factory.errorComp
- }
-
- if (isDef(factory.resolved)) {
- return factory.resolved
- }
-
- if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
- return factory.loadingComp
- }
-
- if (isDef(factory.contexts)) {
- // already pending
- factory.contexts.push(context);
- } else {
- var contexts = factory.contexts = [context];
- var sync = true;
-
- var forceRender = function () {
- for (var i = 0, l = contexts.length; i < l; i++) {
- contexts[i].$forceUpdate();
- }
- };
-
- var resolve = once(function (res) {
- // cache resolved
- factory.resolved = ensureCtor(res, baseCtor);
- // invoke callbacks only if this is not a synchronous resolve
- // (async resolves are shimmed as synchronous during SSR)
- if (!sync) {
- forceRender();
+function initInjections (vm) {
+ var result = resolveInject(vm.$options.inject, vm);
+ if (result) {
+ toggleObserving(false);
+ Object.keys(result).forEach(function (key) {
+ /* istanbul ignore else */
+ {
+ defineReactive$$1(vm, key, result[key], function () {
+ warn(
+ "Avoid mutating an injected value directly since the changes will be " +
+ "overwritten whenever the provided component re-renders. " +
+ "injection being mutated: \"" + key + "\"",
+ vm
+ );
+ });
}
});
-
- var reject = once(function (reason) {
- "development" !== 'production' && warn(
- "Failed to resolve async component: " + (String(factory)) +
- (reason ? ("\nReason: " + reason) : '')
- );
- if (isDef(factory.errorComp)) {
- factory.error = true;
- forceRender();
- }
- });
-
- var res = factory(resolve, reject);
-
- if (isObject(res)) {
- if (typeof res.then === 'function') {
- // () => Promise
- if (isUndef(factory.resolved)) {
- res.then(resolve, reject);
- }
- } else if (isDef(res.component) && typeof res.component.then === 'function') {
- res.component.then(resolve, reject);
-
- if (isDef(res.error)) {
- factory.errorComp = ensureCtor(res.error, baseCtor);
- }
-
- if (isDef(res.loading)) {
- factory.loadingComp = ensureCtor(res.loading, baseCtor);
- if (res.delay === 0) {
- factory.loading = true;
- } else {
- setTimeout(function () {
- if (isUndef(factory.resolved) && isUndef(factory.error)) {
- factory.loading = true;
- forceRender();
- }
- }, res.delay || 200);
- }
- }
-
- if (isDef(res.timeout)) {
- setTimeout(function () {
- if (isUndef(factory.resolved)) {
- reject(
- true
- ? ("timeout (" + (res.timeout) + "ms)")
- : null
- );
- }
- }, res.timeout);
- }
- }
- }
-
- sync = false;
- // return in case resolved synchronously
- return factory.loading
- ? factory.loadingComp
- : factory.resolved
+ toggleObserving(true);
}
}
-/* */
+function resolveInject (inject, vm) {
+ if (inject) {
+ // inject is :any because flow is not smart enough to figure out cached
+ var result = Object.create(null);
+ var keys = hasSymbol
+ ? Reflect.ownKeys(inject)
+ : Object.keys(inject);
-function isAsyncPlaceholder (node) {
- return node.isComment && node.asyncFactory
-}
-
-/* */
-
-function getFirstComponentChild (children) {
- if (Array.isArray(children)) {
- for (var i = 0; i < children.length; i++) {
- var c = children[i];
- if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
- return c
- }
- }
- }
-}
-
-/* */
-
-/* */
-
-function initEvents (vm) {
- vm._events = Object.create(null);
- vm._hasHookEvent = false;
- // init parent attached events
- var listeners = vm.$options._parentListeners;
- if (listeners) {
- updateComponentListeners(vm, listeners);
- }
-}
-
-var target;
-
-function add (event, fn, once) {
- if (once) {
- target.$once(event, fn);
- } else {
- target.$on(event, fn);
- }
-}
-
-function remove$1 (event, fn) {
- target.$off(event, fn);
-}
-
-function updateComponentListeners (
- vm,
- listeners,
- oldListeners
-) {
- target = vm;
- updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
- target = undefined;
-}
-
-function eventsMixin (Vue) {
- var hookRE = /^hook:/;
- Vue.prototype.$on = function (event, fn) {
- var this$1 = this;
-
- var vm = this;
- if (Array.isArray(event)) {
- for (var i = 0, l = event.length; i < l; i++) {
- this$1.$on(event[i], fn);
- }
- } else {
- (vm._events[event] || (vm._events[event] = [])).push(fn);
- // optimize hook:event cost by using a boolean flag marked at registration
- // instead of a hash lookup
- if (hookRE.test(event)) {
- vm._hasHookEvent = true;
- }
- }
- return vm
- };
-
- Vue.prototype.$once = function (event, fn) {
- var vm = this;
- function on () {
- vm.$off(event, on);
- fn.apply(vm, arguments);
- }
- on.fn = fn;
- vm.$on(event, on);
- return vm
- };
-
- Vue.prototype.$off = function (event, fn) {
- var this$1 = this;
-
- var vm = this;
- // all
- if (!arguments.length) {
- vm._events = Object.create(null);
- return vm
- }
- // array of events
- if (Array.isArray(event)) {
- for (var i = 0, l = event.length; i < l; i++) {
- this$1.$off(event[i], fn);
- }
- return vm
- }
- // specific event
- var cbs = vm._events[event];
- if (!cbs) {
- return vm
- }
- if (!fn) {
- vm._events[event] = null;
- return vm
- }
- if (fn) {
- // specific handler
- var cb;
- var i$1 = cbs.length;
- while (i$1--) {
- cb = cbs[i$1];
- if (cb === fn || cb.fn === fn) {
- cbs.splice(i$1, 1);
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ // #6574 in case the inject object is observed...
+ if (key === '__ob__') { continue }
+ var provideKey = inject[key].from;
+ var source = vm;
+ while (source) {
+ if (source._provided && hasOwn(source._provided, provideKey)) {
+ result[key] = source._provided[provideKey];
break
}
+ source = source.$parent;
}
- }
- return vm
- };
-
- Vue.prototype.$emit = function (event) {
- var vm = this;
- if (true) {
- var lowerCaseEvent = event.toLowerCase();
- if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
- tip(
- "Event \"" + lowerCaseEvent + "\" is emitted in component " +
- (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
- "Note that HTML attributes are case-insensitive and you cannot use " +
- "v-on to listen to camelCase events when using in-DOM templates. " +
- "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
- );
- }
- }
- var cbs = vm._events[event];
- if (cbs) {
- cbs = cbs.length > 1 ? toArray(cbs) : cbs;
- var args = toArray(arguments, 1);
- for (var i = 0, l = cbs.length; i < l; i++) {
- try {
- cbs[i].apply(vm, args);
- } catch (e) {
- handleError(e, vm, ("event handler for \"" + event + "\""));
+ if (!source) {
+ if ('default' in inject[key]) {
+ var provideDefault = inject[key].default;
+ result[key] = typeof provideDefault === 'function'
+ ? provideDefault.call(vm)
+ : provideDefault;
+ } else {
+ warn(("Injection \"" + key + "\" not found"), vm);
}
}
}
- return vm
- };
+ return result
+ }
}
/* */
@@ -3092,10 +3031,10 @@ function resolveSlots (
children,
context
) {
- var slots = {};
- if (!children) {
- return slots
+ if (!children || !children.length) {
+ return {}
}
+ var slots = {};
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
@@ -3132,1097 +3071,80 @@ function isWhitespace (node) {
return (node.isComment && !node.asyncFactory) || node.text === ' '
}
-function resolveScopedSlots (
- fns, // see flow/vnode
- res
+/* */
+
+function normalizeScopedSlots (
+ slots,
+ normalSlots,
+ prevSlots
) {
- res = res || {};
- for (var i = 0; i < fns.length; i++) {
- if (Array.isArray(fns[i])) {
- resolveScopedSlots(fns[i], res);
- } else {
- res[fns[i].key] = fns[i].fn;
+ var res;
+ var isStable = slots ? !!slots.$stable : true;
+ var key = slots && slots.$key;
+ if (!slots) {
+ res = {};
+ } else if (slots._normalized) {
+ // fast path 1: child component re-render only, parent did not change
+ return slots._normalized
+ } else if (
+ isStable &&
+ prevSlots &&
+ prevSlots !== emptyObject &&
+ key === prevSlots.$key &&
+ Object.keys(normalSlots).length === 0
+ ) {
+ // fast path 2: stable scoped slots w/ no normal slots to proxy,
+ // only need to normalize once
+ return prevSlots
+ } else {
+ res = {};
+ for (var key$1 in slots) {
+ if (slots[key$1] && key$1[0] !== '$') {
+ res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
+ }
}
}
+ // expose normal slots on scopedSlots
+ for (var key$2 in normalSlots) {
+ if (!(key$2 in res)) {
+ res[key$2] = proxyNormalSlot(normalSlots, key$2);
+ }
+ }
+ // avoriaz seems to mock a non-extensible $scopedSlots object
+ // and when that is passed down this would cause an error
+ if (slots && Object.isExtensible(slots)) {
+ (slots)._normalized = res;
+ }
+ def(res, '$stable', isStable);
+ def(res, '$key', key);
return res
}
-/* */
-
-var activeInstance = null;
-var isUpdatingChildComponent = false;
-
-function initLifecycle (vm) {
- var options = vm.$options;
-
- // locate first non-abstract parent
- var parent = options.parent;
- if (parent && !options.abstract) {
- while (parent.$options.abstract && parent.$parent) {
- parent = parent.$parent;
- }
- parent.$children.push(vm);
- }
-
- vm.$parent = parent;
- vm.$root = parent ? parent.$root : vm;
-
- vm.$children = [];
- vm.$refs = {};
-
- vm._watcher = null;
- vm._inactive = null;
- vm._directInactive = false;
- vm._isMounted = false;
- vm._isDestroyed = false;
- vm._isBeingDestroyed = false;
-}
-
-function lifecycleMixin (Vue) {
- Vue.prototype._update = function (vnode, hydrating) {
- var vm = this;
- if (vm._isMounted) {
- callHook(vm, 'beforeUpdate');
- }
- var prevEl = vm.$el;
- var prevVnode = vm._vnode;
- var prevActiveInstance = activeInstance;
- activeInstance = vm;
- vm._vnode = vnode;
- // Vue.prototype.__patch__ is injected in entry points
- // based on the rendering backend used.
- if (!prevVnode) {
- // initial render
- vm.$el = vm.__patch__(
- vm.$el, vnode, hydrating, false /* removeOnly */,
- vm.$options._parentElm,
- vm.$options._refElm
- );
- // no need for the ref nodes after initial patch
- // this prevents keeping a detached DOM tree in memory (#5851)
- vm.$options._parentElm = vm.$options._refElm = null;
- } else {
- // updates
- vm.$el = vm.__patch__(prevVnode, vnode);
- }
- activeInstance = prevActiveInstance;
- // update __vue__ reference
- if (prevEl) {
- prevEl.__vue__ = null;
- }
- if (vm.$el) {
- vm.$el.__vue__ = vm;
- }
- // if parent is an HOC, update its $el as well
- if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
- vm.$parent.$el = vm.$el;
- }
- // updated hook is called by the scheduler to ensure that children are
- // updated in a parent's updated hook.
+function normalizeScopedSlot(normalSlots, key, fn) {
+ var normalized = function () {
+ var res = arguments.length ? fn.apply(null, arguments) : fn({});
+ res = res && typeof res === 'object' && !Array.isArray(res)
+ ? [res] // single vnode
+ : normalizeChildren(res);
+ return res && res.length === 0
+ ? undefined
+ : res
};
-
- Vue.prototype.$forceUpdate = function () {
- var vm = this;
- if (vm._watcher) {
- vm._watcher.update();
- }
- };
-
- Vue.prototype.$destroy = function () {
- var vm = this;
- if (vm._isBeingDestroyed) {
- return
- }
- callHook(vm, 'beforeDestroy');
- vm._isBeingDestroyed = true;
- // remove self from parent
- var parent = vm.$parent;
- if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
- remove(parent.$children, vm);
- }
- // teardown watchers
- if (vm._watcher) {
- vm._watcher.teardown();
- }
- var i = vm._watchers.length;
- while (i--) {
- vm._watchers[i].teardown();
- }
- // remove reference from data ob
- // frozen object may not have observer.
- if (vm._data.__ob__) {
- vm._data.__ob__.vmCount--;
- }
- // call the last hook...
- vm._isDestroyed = true;
- // invoke destroy hooks on current rendered tree
- vm.__patch__(vm._vnode, null);
- // fire destroyed hook
- callHook(vm, 'destroyed');
- // turn off all instance listeners.
- vm.$off();
- // remove __vue__ reference
- if (vm.$el) {
- vm.$el.__vue__ = null;
- }
- // release circular reference (#6759)
- if (vm.$vnode) {
- vm.$vnode.parent = null;
- }
- };
-}
-
-function mountComponent (
- vm,
- el,
- hydrating
-) {
- vm.$el = el;
- if (!vm.$options.render) {
- vm.$options.render = createEmptyVNode;
- if (true) {
- /* istanbul ignore if */
- if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
- vm.$options.el || el) {
- warn(
- 'You are using the runtime-only build of Vue where the template ' +
- 'compiler is not available. Either pre-compile the templates into ' +
- 'render functions, or use the compiler-included build.',
- vm
- );
- } else {
- warn(
- 'Failed to mount component: template or render function not defined.',
- vm
- );
- }
- }
- }
- callHook(vm, 'beforeMount');
-
- var updateComponent;
- /* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
- updateComponent = function () {
- var name = vm._name;
- var id = vm._uid;
- var startTag = "vue-perf-start:" + id;
- var endTag = "vue-perf-end:" + id;
-
- mark(startTag);
- var vnode = vm._render();
- mark(endTag);
- measure(("vue " + name + " render"), startTag, endTag);
-
- mark(startTag);
- vm._update(vnode, hydrating);
- mark(endTag);
- measure(("vue " + name + " patch"), startTag, endTag);
- };
- } else {
- updateComponent = function () {
- vm._update(vm._render(), hydrating);
- };
- }
-
- // we set this to vm._watcher inside the watcher's constructor
- // since the watcher's initial patch may call $forceUpdate (e.g. inside child
- // component's mounted hook), which relies on vm._watcher being already defined
- new Watcher(vm, updateComponent, noop, null, true /* isRenderWatcher */);
- hydrating = false;
-
- // manually mounted instance, call mounted on self
- // mounted is called for render-created child components in its inserted hook
- if (vm.$vnode == null) {
- vm._isMounted = true;
- callHook(vm, 'mounted');
- }
- return vm
-}
-
-function updateChildComponent (
- vm,
- propsData,
- listeners,
- parentVnode,
- renderChildren
-) {
- if (true) {
- isUpdatingChildComponent = true;
- }
-
- // determine whether component has slot children
- // we need to do this before overwriting $options._renderChildren
- var hasChildren = !!(
- renderChildren || // has new static slots
- vm.$options._renderChildren || // has old static slots
- parentVnode.data.scopedSlots || // has new scoped slots
- vm.$scopedSlots !== emptyObject // has old scoped slots
- );
-
- vm.$options._parentVnode = parentVnode;
- vm.$vnode = parentVnode; // update vm's placeholder node without re-render
-
- if (vm._vnode) { // update child tree's parent
- vm._vnode.parent = parentVnode;
- }
- vm.$options._renderChildren = renderChildren;
-
- // update $attrs and $listeners hash
- // these are also reactive so they may trigger child update if the child
- // used them during render
- vm.$attrs = parentVnode.data.attrs || emptyObject;
- vm.$listeners = listeners || emptyObject;
-
- // update props
- if (propsData && vm.$options.props) {
- toggleObserving(false);
- var props = vm._props;
- var propKeys = vm.$options._propKeys || [];
- for (var i = 0; i < propKeys.length; i++) {
- var key = propKeys[i];
- var propOptions = vm.$options.props; // wtf flow?
- props[key] = validateProp(key, propOptions, propsData, vm);
- }
- toggleObserving(true);
- // keep a copy of raw propsData
- vm.$options.propsData = propsData;
- }
-
- // update listeners
- listeners = listeners || emptyObject;
- var oldListeners = vm.$options._parentListeners;
- vm.$options._parentListeners = listeners;
- updateComponentListeners(vm, listeners, oldListeners);
-
- // resolve slots + force update if has children
- if (hasChildren) {
- vm.$slots = resolveSlots(renderChildren, parentVnode.context);
- vm.$forceUpdate();
- }
-
- if (true) {
- isUpdatingChildComponent = false;
- }
-}
-
-function isInInactiveTree (vm) {
- while (vm && (vm = vm.$parent)) {
- if (vm._inactive) { return true }
- }
- return false
-}
-
-function activateChildComponent (vm, direct) {
- if (direct) {
- vm._directInactive = false;
- if (isInInactiveTree(vm)) {
- return
- }
- } else if (vm._directInactive) {
- return
- }
- if (vm._inactive || vm._inactive === null) {
- vm._inactive = false;
- for (var i = 0; i < vm.$children.length; i++) {
- activateChildComponent(vm.$children[i]);
- }
- callHook(vm, 'activated');
- }
-}
-
-function deactivateChildComponent (vm, direct) {
- if (direct) {
- vm._directInactive = true;
- if (isInInactiveTree(vm)) {
- return
- }
- }
- if (!vm._inactive) {
- vm._inactive = true;
- for (var i = 0; i < vm.$children.length; i++) {
- deactivateChildComponent(vm.$children[i]);
- }
- callHook(vm, 'deactivated');
- }
-}
-
-function callHook (vm, hook) {
- // #7573 disable dep collection when invoking lifecycle hooks
- pushTarget();
- var handlers = vm.$options[hook];
- if (handlers) {
- for (var i = 0, j = handlers.length; i < j; i++) {
- try {
- handlers[i].call(vm);
- } catch (e) {
- handleError(e, vm, (hook + " hook"));
- }
- }
- }
- if (vm._hasHookEvent) {
- vm.$emit('hook:' + hook);
- }
- popTarget();
-}
-
-/* */
-
-
-var MAX_UPDATE_COUNT = 100;
-
-var queue = [];
-var activatedChildren = [];
-var has = {};
-var circular = {};
-var waiting = false;
-var flushing = false;
-var index = 0;
-
-/**
- * Reset the scheduler's state.
- */
-function resetSchedulerState () {
- index = queue.length = activatedChildren.length = 0;
- has = {};
- if (true) {
- circular = {};
- }
- waiting = flushing = false;
-}
-
-/**
- * Flush both queues and run the watchers.
- */
-function flushSchedulerQueue () {
- flushing = true;
- var watcher, id;
-
- // Sort queue before flush.
- // This ensures that:
- // 1. Components are updated from parent to child. (because parent is always
- // created before the child)
- // 2. A component's user watchers are run before its render watcher (because
- // user watchers are created before the render watcher)
- // 3. If a component is destroyed during a parent component's watcher run,
- // its watchers can be skipped.
- queue.sort(function (a, b) { return a.id - b.id; });
-
- // do not cache length because more watchers might be pushed
- // as we run existing watchers
- for (index = 0; index < queue.length; index++) {
- watcher = queue[index];
- id = watcher.id;
- has[id] = null;
- watcher.run();
- // in dev build, check and stop circular updates.
- if ("development" !== 'production' && has[id] != null) {
- circular[id] = (circular[id] || 0) + 1;
- if (circular[id] > MAX_UPDATE_COUNT) {
- warn(
- 'You may have an infinite update loop ' + (
- watcher.user
- ? ("in watcher with expression \"" + (watcher.expression) + "\"")
- : "in a component render function."
- ),
- watcher.vm
- );
- break
- }
- }
- }
-
- // keep copies of post queues before resetting state
- var activatedQueue = activatedChildren.slice();
- var updatedQueue = queue.slice();
-
- resetSchedulerState();
-
- // call component updated and activated hooks
- callActivatedHooks(activatedQueue);
- callUpdatedHooks(updatedQueue);
-
- // devtool hook
- /* istanbul ignore if */
- if (devtools && config.devtools) {
- devtools.emit('flush');
- }
-}
-
-function callUpdatedHooks (queue) {
- var i = queue.length;
- while (i--) {
- var watcher = queue[i];
- var vm = watcher.vm;
- if (vm._watcher === watcher && vm._isMounted) {
- callHook(vm, 'updated');
- }
- }
-}
-
-/**
- * Queue a kept-alive component that was activated during patch.
- * The queue will be processed after the entire tree has been patched.
- */
-function queueActivatedComponent (vm) {
- // setting _inactive to false here so that a render function can
- // rely on checking whether it's in an inactive tree (e.g. router-view)
- vm._inactive = false;
- activatedChildren.push(vm);
-}
-
-function callActivatedHooks (queue) {
- for (var i = 0; i < queue.length; i++) {
- queue[i]._inactive = true;
- activateChildComponent(queue[i], true /* true */);
- }
-}
-
-/**
- * Push a watcher into the watcher queue.
- * Jobs with duplicate IDs will be skipped unless it's
- * pushed when the queue is being flushed.
- */
-function queueWatcher (watcher) {
- var id = watcher.id;
- if (has[id] == null) {
- has[id] = true;
- if (!flushing) {
- queue.push(watcher);
- } else {
- // if already flushing, splice the watcher based on its id
- // if already past its id, it will be run next immediately.
- var i = queue.length - 1;
- while (i > index && queue[i].id > watcher.id) {
- i--;
- }
- queue.splice(i + 1, 0, watcher);
- }
- // queue the flush
- if (!waiting) {
- waiting = true;
- nextTick(flushSchedulerQueue);
- }
- }
-}
-
-/* */
-
-var uid$1 = 0;
-
-/**
- * A watcher parses an expression, collects dependencies,
- * and fires callback when the expression value changes.
- * This is used for both the $watch() api and directives.
- */
-var Watcher = function Watcher (
- vm,
- expOrFn,
- cb,
- options,
- isRenderWatcher
-) {
- this.vm = vm;
- if (isRenderWatcher) {
- vm._watcher = this;
- }
- vm._watchers.push(this);
- // options
- if (options) {
- this.deep = !!options.deep;
- this.user = !!options.user;
- this.lazy = !!options.lazy;
- this.sync = !!options.sync;
- } else {
- this.deep = this.user = this.lazy = this.sync = false;
- }
- this.cb = cb;
- this.id = ++uid$1; // uid for batching
- this.active = true;
- this.dirty = this.lazy; // for lazy watchers
- this.deps = [];
- this.newDeps = [];
- this.depIds = new _Set();
- this.newDepIds = new _Set();
- this.expression = true
- ? expOrFn.toString()
- : '';
- // parse expression for getter
- if (typeof expOrFn === 'function') {
- this.getter = expOrFn;
- } else {
- this.getter = parsePath(expOrFn);
- if (!this.getter) {
- this.getter = function () {};
- "development" !== 'production' && warn(
- "Failed watching path: \"" + expOrFn + "\" " +
- 'Watcher only accepts simple dot-delimited paths. ' +
- 'For full control, use a function instead.',
- vm
- );
- }
- }
- this.value = this.lazy
- ? undefined
- : this.get();
-};
-
-/**
- * Evaluate the getter, and re-collect dependencies.
- */
-Watcher.prototype.get = function get () {
- pushTarget(this);
- var value;
- var vm = this.vm;
- try {
- value = this.getter.call(vm, vm);
- } catch (e) {
- if (this.user) {
- handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
- } else {
- throw e
- }
- } finally {
- // "touch" every property so they are all tracked as
- // dependencies for deep watching
- if (this.deep) {
- traverse(value);
- }
- popTarget();
- this.cleanupDeps();
- }
- return value
-};
-
-/**
- * Add a dependency to this directive.
- */
-Watcher.prototype.addDep = function addDep (dep) {
- var id = dep.id;
- if (!this.newDepIds.has(id)) {
- this.newDepIds.add(id);
- this.newDeps.push(dep);
- if (!this.depIds.has(id)) {
- dep.addSub(this);
- }
- }
-};
-
-/**
- * Clean up for dependency collection.
- */
-Watcher.prototype.cleanupDeps = function cleanupDeps () {
- var this$1 = this;
-
- var i = this.deps.length;
- while (i--) {
- var dep = this$1.deps[i];
- if (!this$1.newDepIds.has(dep.id)) {
- dep.removeSub(this$1);
- }
- }
- var tmp = this.depIds;
- this.depIds = this.newDepIds;
- this.newDepIds = tmp;
- this.newDepIds.clear();
- tmp = this.deps;
- this.deps = this.newDeps;
- this.newDeps = tmp;
- this.newDeps.length = 0;
-};
-
-/**
- * Subscriber interface.
- * Will be called when a dependency changes.
- */
-Watcher.prototype.update = function update () {
- /* istanbul ignore else */
- if (this.lazy) {
- this.dirty = true;
- } else if (this.sync) {
- this.run();
- } else {
- queueWatcher(this);
- }
-};
-
-/**
- * Scheduler job interface.
- * Will be called by the scheduler.
- */
-Watcher.prototype.run = function run () {
- if (this.active) {
- var value = this.get();
- if (
- value !== this.value ||
- // Deep watchers and watchers on Object/Arrays should fire even
- // when the value is the same, because the value may
- // have mutated.
- isObject(value) ||
- this.deep
- ) {
- // set new value
- var oldValue = this.value;
- this.value = value;
- if (this.user) {
- try {
- this.cb.call(this.vm, value, oldValue);
- } catch (e) {
- handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
- }
- } else {
- this.cb.call(this.vm, value, oldValue);
- }
- }
- }
-};
-
-/**
- * Evaluate the value of the watcher.
- * This only gets called for lazy watchers.
- */
-Watcher.prototype.evaluate = function evaluate () {
- this.value = this.get();
- this.dirty = false;
-};
-
-/**
- * Depend on all deps collected by this watcher.
- */
-Watcher.prototype.depend = function depend () {
- var this$1 = this;
-
- var i = this.deps.length;
- while (i--) {
- this$1.deps[i].depend();
- }
-};
-
-/**
- * Remove self from all dependencies' subscriber list.
- */
-Watcher.prototype.teardown = function teardown () {
- var this$1 = this;
-
- if (this.active) {
- // remove self from vm's watcher list
- // this is a somewhat expensive operation so we skip it
- // if the vm is being destroyed.
- if (!this.vm._isBeingDestroyed) {
- remove(this.vm._watchers, this);
- }
- var i = this.deps.length;
- while (i--) {
- this$1.deps[i].removeSub(this$1);
- }
- this.active = false;
- }
-};
-
-/* */
-
-var sharedPropertyDefinition = {
- enumerable: true,
- configurable: true,
- get: noop,
- set: noop
-};
-
-function proxy (target, sourceKey, key) {
- sharedPropertyDefinition.get = function proxyGetter () {
- return this[sourceKey][key]
- };
- sharedPropertyDefinition.set = function proxySetter (val) {
- this[sourceKey][key] = val;
- };
- Object.defineProperty(target, key, sharedPropertyDefinition);
-}
-
-function initState (vm) {
- vm._watchers = [];
- var opts = vm.$options;
- if (opts.props) { initProps(vm, opts.props); }
- if (opts.methods) { initMethods(vm, opts.methods); }
- if (opts.data) {
- initData(vm);
- } else {
- observe(vm._data = {}, true /* asRootData */);
- }
- if (opts.computed) { initComputed(vm, opts.computed); }
- if (opts.watch && opts.watch !== nativeWatch) {
- initWatch(vm, opts.watch);
- }
-}
-
-function initProps (vm, propsOptions) {
- var propsData = vm.$options.propsData || {};
- var props = vm._props = {};
- // cache prop keys so that future props updates can iterate using Array
- // instead of dynamic object key enumeration.
- var keys = vm.$options._propKeys = [];
- var isRoot = !vm.$parent;
- // root instance props should be converted
- if (!isRoot) {
- toggleObserving(false);
- }
- var loop = function ( key ) {
- keys.push(key);
- var value = validateProp(key, propsOptions, propsData, vm);
- /* istanbul ignore else */
- if (true) {
- var hyphenatedKey = hyphenate(key);
- if (isReservedAttribute(hyphenatedKey) ||
- config.isReservedAttr(hyphenatedKey)) {
- warn(
- ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
- vm
- );
- }
- defineReactive(props, key, value, function () {
- if (vm.$parent && !isUpdatingChildComponent) {
- warn(
- "Avoid mutating a prop directly since the value will be " +
- "overwritten whenever the parent component re-renders. " +
- "Instead, use a data or computed property based on the prop's " +
- "value. Prop being mutated: \"" + key + "\"",
- vm
- );
- }
- });
- } else {
- defineReactive(props, key, value);
- }
- // static props are already proxied on the component's prototype
- // during Vue.extend(). We only need to proxy props defined at
- // instantiation here.
- if (!(key in vm)) {
- proxy(vm, "_props", key);
- }
- };
-
- for (var key in propsOptions) loop( key );
- toggleObserving(true);
-}
-
-function initData (vm) {
- var data = vm.$options.data;
- data = vm._data = typeof data === 'function'
- ? getData(data, vm)
- : data || {};
- if (!isPlainObject(data)) {
- data = {};
- "development" !== 'production' && warn(
- 'data functions should return an object:\n' +
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
- vm
- );
- }
- // proxy data on instance
- var keys = Object.keys(data);
- var props = vm.$options.props;
- var methods = vm.$options.methods;
- var i = keys.length;
- while (i--) {
- var key = keys[i];
- if (true) {
- if (methods && hasOwn(methods, key)) {
- warn(
- ("Method \"" + key + "\" has already been defined as a data property."),
- vm
- );
- }
- }
- if (props && hasOwn(props, key)) {
- "development" !== 'production' && warn(
- "The data property \"" + key + "\" is already declared as a prop. " +
- "Use prop default value instead.",
- vm
- );
- } else if (!isReserved(key)) {
- proxy(vm, "_data", key);
- }
- }
- // observe data
- observe(data, true /* asRootData */);
-}
-
-function getData (data, vm) {
- // #7573 disable dep collection when invoking data getters
- pushTarget();
- try {
- return data.call(vm, vm)
- } catch (e) {
- handleError(e, vm, "data()");
- return {}
- } finally {
- popTarget();
- }
-}
-
-var computedWatcherOptions = { lazy: true };
-
-function initComputed (vm, computed) {
- // $flow-disable-line
- var watchers = vm._computedWatchers = Object.create(null);
- // computed properties are just getters during SSR
- var isSSR = isServerRendering();
-
- for (var key in computed) {
- var userDef = computed[key];
- var getter = typeof userDef === 'function' ? userDef : userDef.get;
- if ("development" !== 'production' && getter == null) {
- warn(
- ("Getter is missing for computed property \"" + key + "\"."),
- vm
- );
- }
-
- if (!isSSR) {
- // create internal watcher for the computed property.
- watchers[key] = new Watcher(
- vm,
- getter || noop,
- noop,
- computedWatcherOptions
- );
- }
-
- // component-defined computed properties are already defined on the
- // component prototype. We only need to define computed properties defined
- // at instantiation here.
- if (!(key in vm)) {
- defineComputed(vm, key, userDef);
- } else if (true) {
- if (key in vm.$data) {
- warn(("The computed property \"" + key + "\" is already defined in data."), vm);
- } else if (vm.$options.props && key in vm.$options.props) {
- warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
- }
- }
- }
-}
-
-function defineComputed (
- target,
- key,
- userDef
-) {
- var shouldCache = !isServerRendering();
- if (typeof userDef === 'function') {
- sharedPropertyDefinition.get = shouldCache
- ? createComputedGetter(key)
- : userDef;
- sharedPropertyDefinition.set = noop;
- } else {
- sharedPropertyDefinition.get = userDef.get
- ? shouldCache && userDef.cache !== false
- ? createComputedGetter(key)
- : userDef.get
- : noop;
- sharedPropertyDefinition.set = userDef.set
- ? userDef.set
- : noop;
- }
- if ("development" !== 'production' &&
- sharedPropertyDefinition.set === noop) {
- sharedPropertyDefinition.set = function () {
- warn(
- ("Computed property \"" + key + "\" was assigned to but it has no setter."),
- this
- );
- };
- }
- Object.defineProperty(target, key, sharedPropertyDefinition);
-}
-
-function createComputedGetter (key) {
- return function computedGetter () {
- var watcher = this._computedWatchers && this._computedWatchers[key];
- if (watcher) {
- if (watcher.dirty) {
- watcher.evaluate();
- }
- if (Dep.target) {
- watcher.depend();
- }
- return watcher.value
- }
- }
-}
-
-function initMethods (vm, methods) {
- var props = vm.$options.props;
- for (var key in methods) {
- if (true) {
- if (methods[key] == null) {
- warn(
- "Method \"" + key + "\" has an undefined value in the component definition. " +
- "Did you reference the function correctly?",
- vm
- );
- }
- if (props && hasOwn(props, key)) {
- warn(
- ("Method \"" + key + "\" has already been defined as a prop."),
- vm
- );
- }
- if ((key in vm) && isReserved(key)) {
- warn(
- "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
- "Avoid defining component methods that start with _ or $."
- );
- }
- }
- vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
- }
-}
-
-function initWatch (vm, watch) {
- for (var key in watch) {
- var handler = watch[key];
- if (Array.isArray(handler)) {
- for (var i = 0; i < handler.length; i++) {
- createWatcher(vm, key, handler[i]);
- }
- } else {
- createWatcher(vm, key, handler);
- }
- }
-}
-
-function createWatcher (
- vm,
- expOrFn,
- handler,
- options
-) {
- if (isPlainObject(handler)) {
- options = handler;
- handler = handler.handler;
- }
- if (typeof handler === 'string') {
- handler = vm[handler];
- }
- return vm.$watch(expOrFn, handler, options)
-}
-
-function stateMixin (Vue) {
- // flow somehow has problems with directly declared definition object
- // when using Object.defineProperty, so we have to procedurally build up
- // the object here.
- var dataDef = {};
- dataDef.get = function () { return this._data };
- var propsDef = {};
- propsDef.get = function () { return this._props };
- if (true) {
- dataDef.set = function (newData) {
- warn(
- 'Avoid replacing instance root $data. ' +
- 'Use nested data properties instead.',
- this
- );
- };
- propsDef.set = function () {
- warn("$props is readonly.", this);
- };
- }
- Object.defineProperty(Vue.prototype, '$data', dataDef);
- Object.defineProperty(Vue.prototype, '$props', propsDef);
-
- Vue.prototype.$set = set;
- Vue.prototype.$delete = del;
-
- Vue.prototype.$watch = function (
- expOrFn,
- cb,
- options
- ) {
- var vm = this;
- if (isPlainObject(cb)) {
- return createWatcher(vm, expOrFn, cb, options)
- }
- options = options || {};
- options.user = true;
- var watcher = new Watcher(vm, expOrFn, cb, options);
- if (options.immediate) {
- cb.call(vm, watcher.value);
- }
- return function unwatchFn () {
- watcher.teardown();
- }
- };
-}
-
-/* */
-
-function initProvide (vm) {
- var provide = vm.$options.provide;
- if (provide) {
- vm._provided = typeof provide === 'function'
- ? provide.call(vm)
- : provide;
- }
-}
-
-function initInjections (vm) {
- var result = resolveInject(vm.$options.inject, vm);
- if (result) {
- toggleObserving(false);
- Object.keys(result).forEach(function (key) {
- /* istanbul ignore else */
- if (true) {
- defineReactive(vm, key, result[key], function () {
- warn(
- "Avoid mutating an injected value directly since the changes will be " +
- "overwritten whenever the provided component re-renders. " +
- "injection being mutated: \"" + key + "\"",
- vm
- );
- });
- } else {
- defineReactive(vm, key, result[key]);
- }
+ // this is a slot using the new v-slot syntax without scope. although it is
+ // compiled as a scoped slot, render fn users would expect it to be present
+ // on this.$slots because the usage is semantically a normal slot.
+ if (fn.proxy) {
+ Object.defineProperty(normalSlots, key, {
+ get: normalized,
+ enumerable: true,
+ configurable: true
});
- toggleObserving(true);
}
+ return normalized
}
-function resolveInject (inject, vm) {
- if (inject) {
- // inject is :any because flow is not smart enough to figure out cached
- var result = Object.create(null);
- var keys = hasSymbol
- ? Reflect.ownKeys(inject).filter(function (key) {
- /* istanbul ignore next */
- return Object.getOwnPropertyDescriptor(inject, key).enumerable
- })
- : Object.keys(inject);
-
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- var provideKey = inject[key].from;
- var source = vm;
- while (source) {
- if (source._provided && hasOwn(source._provided, provideKey)) {
- result[key] = source._provided[provideKey];
- break
- }
- source = source.$parent;
- }
- if (!source) {
- if ('default' in inject[key]) {
- var provideDefault = inject[key].default;
- result[key] = typeof provideDefault === 'function'
- ? provideDefault.call(vm)
- : provideDefault;
- } else if (true) {
- warn(("Injection \"" + key + "\" not found"), vm);
- }
- }
- }
- return result
- }
+function proxyNormalSlot(slots, key) {
+ return function () { return slots[key]; }
}
/* */
@@ -4246,16 +3168,27 @@ function renderList (
ret[i] = render(i + 1, i);
}
} else if (isObject(val)) {
- keys = Object.keys(val);
- ret = new Array(keys.length);
- for (i = 0, l = keys.length; i < l; i++) {
- key = keys[i];
- ret[i] = render(val[key], key, i);
+ if (hasSymbol && val[Symbol.iterator]) {
+ ret = [];
+ var iterator = val[Symbol.iterator]();
+ var result = iterator.next();
+ while (!result.done) {
+ ret.push(render(result.value, ret.length));
+ result = iterator.next();
+ }
+ } else {
+ keys = Object.keys(val);
+ ret = new Array(keys.length);
+ for (i = 0, l = keys.length; i < l; i++) {
+ key = keys[i];
+ ret[i] = render(val[key], key, i);
+ }
}
}
- if (isDef(ret)) {
- (ret)._isVList = true;
+ if (!isDef(ret)) {
+ ret = [];
}
+ (ret)._isVList = true;
return ret
}
@@ -4275,7 +3208,7 @@ function renderSlot (
if (scopedSlotFn) { // scoped slot
props = props || {};
if (bindObject) {
- if ("development" !== 'production' && !isObject(bindObject)) {
+ if (!isObject(bindObject)) {
warn(
'slot v-bind without argument expects an Object',
this
@@ -4285,19 +3218,7 @@ function renderSlot (
}
nodes = scopedSlotFn(props) || fallback;
} else {
- var slotNodes = this.$slots[name];
- // warn duplicate slot usage
- if (slotNodes) {
- if ("development" !== 'production' && slotNodes._rendered) {
- warn(
- "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
- "- this will likely cause render errors.",
- this
- );
- }
- slotNodes._rendered = true;
- }
- nodes = slotNodes || fallback;
+ nodes = this.$slots[name] || fallback;
}
var target = props && props.slot;
@@ -4363,7 +3284,7 @@ function bindObjectProps (
) {
if (value) {
if (!isObject(value)) {
- "development" !== 'production' && warn(
+ warn(
'v-bind without argument expects an Object or Array value',
this
);
@@ -4385,12 +3306,13 @@ function bindObjectProps (
? data.domProps || (data.domProps = {})
: data.attrs || (data.attrs = {});
}
- if (!(key in hash)) {
+ var camelizedKey = camelize(key);
+ if (!(key in hash) && !(camelizedKey in hash)) {
hash[key] = value[key];
if (isSync) {
var on = data.on || (data.on = {});
- on[("update:" + key)] = function ($event) {
+ on[("update:" + camelizedKey)] = function ($event) {
value[key] = $event;
};
}
@@ -4469,7 +3391,7 @@ function markStaticNode (node, key, isOnce) {
function bindObjectListeners (data, value) {
if (value) {
if (!isPlainObject(value)) {
- "development" !== 'production' && warn(
+ warn(
'v-on without argument expects an Object value',
this
);
@@ -4487,6 +3409,59 @@ function bindObjectListeners (data, value) {
/* */
+function resolveScopedSlots (
+ fns, // see flow/vnode
+ res,
+ // the following are added in 2.6
+ hasDynamicKeys,
+ contentHashKey
+) {
+ res = res || { $stable: !hasDynamicKeys };
+ for (var i = 0; i < fns.length; i++) {
+ var slot = fns[i];
+ if (Array.isArray(slot)) {
+ resolveScopedSlots(slot, res, hasDynamicKeys);
+ } else if (slot) {
+ // marker for reverse proxying v-slot without scope on this.$slots
+ if (slot.proxy) {
+ slot.fn.proxy = true;
+ }
+ res[slot.key] = slot.fn;
+ }
+ }
+ if (contentHashKey) {
+ (res).$key = contentHashKey;
+ }
+ return res
+}
+
+/* */
+
+function bindDynamicKeys (baseObj, values) {
+ for (var i = 0; i < values.length; i += 2) {
+ var key = values[i];
+ if (typeof key === 'string' && key) {
+ baseObj[values[i]] = values[i + 1];
+ } else if (key !== '' && key !== null) {
+ // null is a speical value for explicitly removing a binding
+ warn(
+ ("Invalid value for dynamic directive argument (expected string or null): " + key),
+ this
+ );
+ }
+ }
+ return baseObj
+}
+
+// helper to dynamically append modifier runtime markers to event names.
+// ensure only append when value is already string, otherwise it will be cast
+// to string and cause the type check to miss.
+function prependModifier (value, symbol) {
+ return typeof value === 'string' ? symbol + value : value
+}
+
+/* */
+
function installRenderHelpers (target) {
target._o = markOnce;
target._n = toNumber;
@@ -4503,6 +3478,8 @@ function installRenderHelpers (target) {
target._e = createEmptyVNode;
target._u = resolveScopedSlots;
target._g = bindObjectListeners;
+ target._d = bindDynamicKeys;
+ target._p = prependModifier;
}
/* */
@@ -4514,6 +3491,8 @@ function FunctionalRenderContext (
parent,
Ctor
) {
+ var this$1 = this;
+
var options = Ctor.options;
// ensure the createElement function in functional components
// gets a unique context - this is necessary for correct named slot check
@@ -4539,7 +3518,22 @@ function FunctionalRenderContext (
this.parent = parent;
this.listeners = data.on || emptyObject;
this.injections = resolveInject(options.inject, parent);
- this.slots = function () { return resolveSlots(children, parent); };
+ this.slots = function () {
+ if (!this$1.$slots) {
+ normalizeScopedSlots(
+ data.scopedSlots,
+ this$1.$slots = resolveSlots(children, parent)
+ );
+ }
+ return this$1.$slots
+ };
+
+ Object.defineProperty(this, 'scopedSlots', ({
+ enumerable: true,
+ get: function get () {
+ return normalizeScopedSlots(data.scopedSlots, this.slots())
+ }
+ }));
// support for compiled functional template
if (isCompiled) {
@@ -4547,7 +3541,7 @@ function FunctionalRenderContext (
this.$options = options;
// pre-resolve slots for renderSlot()
this.$slots = this.slots();
- this.$scopedSlots = data.scopedSlots || emptyObject;
+ this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
}
if (options._scopeId) {
@@ -4596,24 +3590,27 @@ function createFunctionalComponent (
var vnode = options.render.call(null, renderContext._c, renderContext);
if (vnode instanceof VNode) {
- return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options)
+ return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
} else if (Array.isArray(vnode)) {
var vnodes = normalizeChildren(vnode) || [];
var res = new Array(vnodes.length);
for (var i = 0; i < vnodes.length; i++) {
- res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options);
+ res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
}
return res
}
}
-function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) {
+function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
// #7817 clone node before setting fnContext, otherwise if the node is reused
// (e.g. it was from a cached normal slot) the fnContext causes named slots
// that should not be matched to match.
var clone = cloneVNode(vnode);
clone.fnContext = contextVm;
clone.fnOptions = options;
+ {
+ (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
+ }
if (data.slot) {
(clone.data || (clone.data = {})).slot = data.slot;
}
@@ -4628,33 +3625,15 @@ function mergeProps (to, from) {
/* */
-
-
-
-// Register the component hook to weex native render engine.
-// The hook will be triggered by native, not javascript.
-
-
-// Updates the state of the component to weex native render engine.
-
/* */
-// https://github.com/Hanks10100/weex-native-directive/tree/master/component
-
-// listening on native callback
-
/* */
/* */
// inline hooks to be invoked on component VNodes during patch
var componentVNodeHooks = {
- init: function init (
- vnode,
- hydrating,
- parentElm,
- refElm
- ) {
+ init: function init (vnode, hydrating) {
if (
vnode.componentInstance &&
!vnode.componentInstance._isDestroyed &&
@@ -4666,9 +3645,7 @@ var componentVNodeHooks = {
} else {
var child = vnode.componentInstance = createComponentInstanceForVnode(
vnode,
- activeInstance,
- parentElm,
- refElm
+ activeInstance
);
child.$mount(hydrating ? vnode.elm : undefined, hydrating);
}
@@ -4742,7 +3719,7 @@ function createComponent (
// if at this stage it's not a constructor or an async component factory,
// reject.
if (typeof Ctor !== 'function') {
- if (true) {
+ {
warn(("Invalid Component definition: " + (String(Ctor))), context);
}
return
@@ -4752,7 +3729,7 @@ function createComponent (
var asyncFactory;
if (isUndef(Ctor.cid)) {
asyncFactory = Ctor;
- Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
+ Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
if (Ctor === undefined) {
// return a placeholder node for async component, which is rendered
// as a comment node but preserves all the raw information for the node.
@@ -4817,25 +3794,17 @@ function createComponent (
asyncFactory
);
- // Weex specific: invoke recycle-list optimized @render function for
- // extracting cell-slot template.
- // https://github.com/Hanks10100/weex-native-directive/tree/master/component
- /* istanbul ignore if */
return vnode
}
function createComponentInstanceForVnode (
vnode, // we know it's MountedComponentVNode but flow doesn't
- parent, // activeInstance in lifecycle state
- parentElm,
- refElm
+ parent // activeInstance in lifecycle state
) {
var options = {
_isComponent: true,
- parent: parent,
_parentVnode: vnode,
- _parentElm: parentElm || null,
- _refElm: refElm || null
+ parent: parent
};
// check inline-template render functions
var inlineTemplate = vnode.data.inlineTemplate;
@@ -4850,20 +3819,43 @@ function installComponentHooks (data) {
var hooks = data.hook || (data.hook = {});
for (var i = 0; i < hooksToMerge.length; i++) {
var key = hooksToMerge[i];
- hooks[key] = componentVNodeHooks[key];
+ var existing = hooks[key];
+ var toMerge = componentVNodeHooks[key];
+ if (existing !== toMerge && !(existing && existing._merged)) {
+ hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
+ }
}
}
+function mergeHook$1 (f1, f2) {
+ var merged = function (a, b) {
+ // flow complains about extra args which is why we use any
+ f1(a, b);
+ f2(a, b);
+ };
+ merged._merged = true;
+ return merged
+}
+
// transform component v-model info (value and callback) into
// prop and event handler respectively.
function transformModel (options, data) {
var prop = (options.model && options.model.prop) || 'value';
- var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
+ var event = (options.model && options.model.event) || 'input'
+ ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
var on = data.on || (data.on = {});
- if (isDef(on[event])) {
- on[event] = [data.model.callback].concat(on[event]);
+ var existing = on[event];
+ var callback = data.model.callback;
+ if (isDef(existing)) {
+ if (
+ Array.isArray(existing)
+ ? existing.indexOf(callback) === -1
+ : existing !== callback
+ ) {
+ on[event] = [callback].concat(existing);
+ }
} else {
- on[event] = data.model.callback;
+ on[event] = callback;
}
}
@@ -4901,7 +3893,7 @@ function _createElement (
normalizationType
) {
if (isDef(data) && isDef((data).__ob__)) {
- "development" !== 'production' && warn(
+ warn(
"Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
'Always create fresh vnode data objects in each render!',
context
@@ -4917,8 +3909,7 @@ function _createElement (
return createEmptyVNode()
}
// warn against non-primitive key
- if ("development" !== 'production' &&
- isDef(data) && isDef(data.key) && !isPrimitive(data.key)
+ if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
) {
{
warn(
@@ -4951,7 +3942,7 @@ function _createElement (
config.parsePlatformTagName(tag), data, children,
undefined, undefined, context
);
- } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
+ } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
// component
vnode = createComponent(Ctor, data, context, children, tag);
} else {
@@ -5032,19 +4023,18 @@ function initRender (vm) {
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
- if (true) {
- defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
+ {
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
- defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () {
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
- } else {
- defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
- defineReactive(vm, '$listeners', options._parentListeners || emptyObject, null, true);
}
}
+var currentRenderingInstance = null;
+
function renderMixin (Vue) {
// install runtime convenience helpers
installRenderHelpers(Vue.prototype);
@@ -5059,16 +4049,12 @@ function renderMixin (Vue) {
var render = ref.render;
var _parentVnode = ref._parentVnode;
- // reset _rendered flag on slots for duplicate slot check
- if (true) {
- for (var key in vm.$slots) {
- // $flow-disable-line
- vm.$slots[key]._rendered = false;
- }
- }
-
if (_parentVnode) {
- vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject;
+ vm.$scopedSlots = normalizeScopedSlots(
+ _parentVnode.data.scopedSlots,
+ vm.$slots,
+ vm.$scopedSlots
+ );
}
// set parent vnode. this allows render functions to have access
@@ -5077,30 +4063,36 @@ function renderMixin (Vue) {
// render self
var vnode;
try {
+ // There's no need to maintain a stack becaues all render fns are called
+ // separately from one another. Nested component's render fns are called
+ // when parent component is patched.
+ currentRenderingInstance = vm;
vnode = render.call(vm._renderProxy, vm.$createElement);
} catch (e) {
handleError(e, vm, "render");
// return error render result,
// or previous vnode to prevent render error causing blank component
/* istanbul ignore else */
- if (true) {
- if (vm.$options.renderError) {
- try {
- vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
- } catch (e) {
- handleError(e, vm, "renderError");
- vnode = vm._vnode;
- }
- } else {
+ if (vm.$options.renderError) {
+ try {
+ vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
+ } catch (e) {
+ handleError(e, vm, "renderError");
vnode = vm._vnode;
}
} else {
vnode = vm._vnode;
}
+ } finally {
+ currentRenderingInstance = null;
+ }
+ // if the returned array contains only a single node, allow it
+ if (Array.isArray(vnode) && vnode.length === 1) {
+ vnode = vnode[0];
}
// return empty vnode in case the render function errored out
if (!(vnode instanceof VNode)) {
- if ("development" !== 'production' && Array.isArray(vnode)) {
+ if (Array.isArray(vnode)) {
warn(
'Multiple root nodes returned from render function. Render function ' +
'should return a single root node.',
@@ -5117,6 +4109,1345 @@ function renderMixin (Vue) {
/* */
+function ensureCtor (comp, base) {
+ if (
+ comp.__esModule ||
+ (hasSymbol && comp[Symbol.toStringTag] === 'Module')
+ ) {
+ comp = comp.default;
+ }
+ return isObject(comp)
+ ? base.extend(comp)
+ : comp
+}
+
+function createAsyncPlaceholder (
+ factory,
+ data,
+ context,
+ children,
+ tag
+) {
+ var node = createEmptyVNode();
+ node.asyncFactory = factory;
+ node.asyncMeta = { data: data, context: context, children: children, tag: tag };
+ return node
+}
+
+function resolveAsyncComponent (
+ factory,
+ baseCtor
+) {
+ if (isTrue(factory.error) && isDef(factory.errorComp)) {
+ return factory.errorComp
+ }
+
+ if (isDef(factory.resolved)) {
+ return factory.resolved
+ }
+
+ if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
+ return factory.loadingComp
+ }
+
+ var owner = currentRenderingInstance;
+ if (isDef(factory.owners)) {
+ // already pending
+ factory.owners.push(owner);
+ } else {
+ var owners = factory.owners = [owner];
+ var sync = true;
+
+ var forceRender = function (renderCompleted) {
+ for (var i = 0, l = owners.length; i < l; i++) {
+ (owners[i]).$forceUpdate();
+ }
+
+ if (renderCompleted) {
+ owners.length = 0;
+ }
+ };
+
+ var resolve = once(function (res) {
+ // cache resolved
+ factory.resolved = ensureCtor(res, baseCtor);
+ // invoke callbacks only if this is not a synchronous resolve
+ // (async resolves are shimmed as synchronous during SSR)
+ if (!sync) {
+ forceRender(true);
+ } else {
+ owners.length = 0;
+ }
+ });
+
+ var reject = once(function (reason) {
+ warn(
+ "Failed to resolve async component: " + (String(factory)) +
+ (reason ? ("\nReason: " + reason) : '')
+ );
+ if (isDef(factory.errorComp)) {
+ factory.error = true;
+ forceRender(true);
+ }
+ });
+
+ var res = factory(resolve, reject);
+
+ if (isObject(res)) {
+ if (isPromise(res)) {
+ // () => Promise
+ if (isUndef(factory.resolved)) {
+ res.then(resolve, reject);
+ }
+ } else if (isPromise(res.component)) {
+ res.component.then(resolve, reject);
+
+ if (isDef(res.error)) {
+ factory.errorComp = ensureCtor(res.error, baseCtor);
+ }
+
+ if (isDef(res.loading)) {
+ factory.loadingComp = ensureCtor(res.loading, baseCtor);
+ if (res.delay === 0) {
+ factory.loading = true;
+ } else {
+ setTimeout(function () {
+ if (isUndef(factory.resolved) && isUndef(factory.error)) {
+ factory.loading = true;
+ forceRender(false);
+ }
+ }, res.delay || 200);
+ }
+ }
+
+ if (isDef(res.timeout)) {
+ setTimeout(function () {
+ if (isUndef(factory.resolved)) {
+ reject(
+ "timeout (" + (res.timeout) + "ms)"
+ );
+ }
+ }, res.timeout);
+ }
+ }
+ }
+
+ sync = false;
+ // return in case resolved synchronously
+ return factory.loading
+ ? factory.loadingComp
+ : factory.resolved
+ }
+}
+
+/* */
+
+function isAsyncPlaceholder (node) {
+ return node.isComment && node.asyncFactory
+}
+
+/* */
+
+function getFirstComponentChild (children) {
+ if (Array.isArray(children)) {
+ for (var i = 0; i < children.length; i++) {
+ var c = children[i];
+ if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
+ return c
+ }
+ }
+ }
+}
+
+/* */
+
+/* */
+
+function initEvents (vm) {
+ vm._events = Object.create(null);
+ vm._hasHookEvent = false;
+ // init parent attached events
+ var listeners = vm.$options._parentListeners;
+ if (listeners) {
+ updateComponentListeners(vm, listeners);
+ }
+}
+
+var target;
+
+function add (event, fn) {
+ target.$on(event, fn);
+}
+
+function remove$1 (event, fn) {
+ target.$off(event, fn);
+}
+
+function createOnceHandler (event, fn) {
+ var _target = target;
+ return function onceHandler () {
+ var res = fn.apply(null, arguments);
+ if (res !== null) {
+ _target.$off(event, onceHandler);
+ }
+ }
+}
+
+function updateComponentListeners (
+ vm,
+ listeners,
+ oldListeners
+) {
+ target = vm;
+ updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
+ target = undefined;
+}
+
+function eventsMixin (Vue) {
+ var hookRE = /^hook:/;
+ Vue.prototype.$on = function (event, fn) {
+ var vm = this;
+ if (Array.isArray(event)) {
+ for (var i = 0, l = event.length; i < l; i++) {
+ vm.$on(event[i], fn);
+ }
+ } else {
+ (vm._events[event] || (vm._events[event] = [])).push(fn);
+ // optimize hook:event cost by using a boolean flag marked at registration
+ // instead of a hash lookup
+ if (hookRE.test(event)) {
+ vm._hasHookEvent = true;
+ }
+ }
+ return vm
+ };
+
+ Vue.prototype.$once = function (event, fn) {
+ var vm = this;
+ function on () {
+ vm.$off(event, on);
+ fn.apply(vm, arguments);
+ }
+ on.fn = fn;
+ vm.$on(event, on);
+ return vm
+ };
+
+ Vue.prototype.$off = function (event, fn) {
+ var vm = this;
+ // all
+ if (!arguments.length) {
+ vm._events = Object.create(null);
+ return vm
+ }
+ // array of events
+ if (Array.isArray(event)) {
+ for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
+ vm.$off(event[i$1], fn);
+ }
+ return vm
+ }
+ // specific event
+ var cbs = vm._events[event];
+ if (!cbs) {
+ return vm
+ }
+ if (!fn) {
+ vm._events[event] = null;
+ return vm
+ }
+ // specific handler
+ var cb;
+ var i = cbs.length;
+ while (i--) {
+ cb = cbs[i];
+ if (cb === fn || cb.fn === fn) {
+ cbs.splice(i, 1);
+ break
+ }
+ }
+ return vm
+ };
+
+ Vue.prototype.$emit = function (event) {
+ var vm = this;
+ {
+ var lowerCaseEvent = event.toLowerCase();
+ if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
+ tip(
+ "Event \"" + lowerCaseEvent + "\" is emitted in component " +
+ (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
+ "Note that HTML attributes are case-insensitive and you cannot use " +
+ "v-on to listen to camelCase events when using in-DOM templates. " +
+ "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
+ );
+ }
+ }
+ var cbs = vm._events[event];
+ if (cbs) {
+ cbs = cbs.length > 1 ? toArray(cbs) : cbs;
+ var args = toArray(arguments, 1);
+ var info = "event handler for \"" + event + "\"";
+ for (var i = 0, l = cbs.length; i < l; i++) {
+ invokeWithErrorHandling(cbs[i], vm, args, vm, info);
+ }
+ }
+ return vm
+ };
+}
+
+/* */
+
+var activeInstance = null;
+var isUpdatingChildComponent = false;
+
+function setActiveInstance(vm) {
+ var prevActiveInstance = activeInstance;
+ activeInstance = vm;
+ return function () {
+ activeInstance = prevActiveInstance;
+ }
+}
+
+function initLifecycle (vm) {
+ var options = vm.$options;
+
+ // locate first non-abstract parent
+ var parent = options.parent;
+ if (parent && !options.abstract) {
+ while (parent.$options.abstract && parent.$parent) {
+ parent = parent.$parent;
+ }
+ parent.$children.push(vm);
+ }
+
+ vm.$parent = parent;
+ vm.$root = parent ? parent.$root : vm;
+
+ vm.$children = [];
+ vm.$refs = {};
+
+ vm._watcher = null;
+ vm._inactive = null;
+ vm._directInactive = false;
+ vm._isMounted = false;
+ vm._isDestroyed = false;
+ vm._isBeingDestroyed = false;
+}
+
+function lifecycleMixin (Vue) {
+ Vue.prototype._update = function (vnode, hydrating) {
+ var vm = this;
+ var prevEl = vm.$el;
+ var prevVnode = vm._vnode;
+ var restoreActiveInstance = setActiveInstance(vm);
+ vm._vnode = vnode;
+ // Vue.prototype.__patch__ is injected in entry points
+ // based on the rendering backend used.
+ if (!prevVnode) {
+ // initial render
+ vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
+ } else {
+ // updates
+ vm.$el = vm.__patch__(prevVnode, vnode);
+ }
+ restoreActiveInstance();
+ // update __vue__ reference
+ if (prevEl) {
+ prevEl.__vue__ = null;
+ }
+ if (vm.$el) {
+ vm.$el.__vue__ = vm;
+ }
+ // if parent is an HOC, update its $el as well
+ if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
+ vm.$parent.$el = vm.$el;
+ }
+ // updated hook is called by the scheduler to ensure that children are
+ // updated in a parent's updated hook.
+ };
+
+ Vue.prototype.$forceUpdate = function () {
+ var vm = this;
+ if (vm._watcher) {
+ vm._watcher.update();
+ }
+ };
+
+ Vue.prototype.$destroy = function () {
+ var vm = this;
+ if (vm._isBeingDestroyed) {
+ return
+ }
+ callHook(vm, 'beforeDestroy');
+ vm._isBeingDestroyed = true;
+ // remove self from parent
+ var parent = vm.$parent;
+ if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
+ remove(parent.$children, vm);
+ }
+ // teardown watchers
+ if (vm._watcher) {
+ vm._watcher.teardown();
+ }
+ var i = vm._watchers.length;
+ while (i--) {
+ vm._watchers[i].teardown();
+ }
+ // remove reference from data ob
+ // frozen object may not have observer.
+ if (vm._data.__ob__) {
+ vm._data.__ob__.vmCount--;
+ }
+ // call the last hook...
+ vm._isDestroyed = true;
+ // invoke destroy hooks on current rendered tree
+ vm.__patch__(vm._vnode, null);
+ // fire destroyed hook
+ callHook(vm, 'destroyed');
+ // turn off all instance listeners.
+ vm.$off();
+ // remove __vue__ reference
+ if (vm.$el) {
+ vm.$el.__vue__ = null;
+ }
+ // release circular reference (#6759)
+ if (vm.$vnode) {
+ vm.$vnode.parent = null;
+ }
+ };
+}
+
+function mountComponent (
+ vm,
+ el,
+ hydrating
+) {
+ vm.$el = el;
+ if (!vm.$options.render) {
+ vm.$options.render = createEmptyVNode;
+ {
+ /* istanbul ignore if */
+ if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
+ vm.$options.el || el) {
+ warn(
+ 'You are using the runtime-only build of Vue where the template ' +
+ 'compiler is not available. Either pre-compile the templates into ' +
+ 'render functions, or use the compiler-included build.',
+ vm
+ );
+ } else {
+ warn(
+ 'Failed to mount component: template or render function not defined.',
+ vm
+ );
+ }
+ }
+ }
+ callHook(vm, 'beforeMount');
+
+ var updateComponent;
+ /* istanbul ignore if */
+ if (config.performance && mark) {
+ updateComponent = function () {
+ var name = vm._name;
+ var id = vm._uid;
+ var startTag = "vue-perf-start:" + id;
+ var endTag = "vue-perf-end:" + id;
+
+ mark(startTag);
+ var vnode = vm._render();
+ mark(endTag);
+ measure(("vue " + name + " render"), startTag, endTag);
+
+ mark(startTag);
+ vm._update(vnode, hydrating);
+ mark(endTag);
+ measure(("vue " + name + " patch"), startTag, endTag);
+ };
+ } else {
+ updateComponent = function () {
+ vm._update(vm._render(), hydrating);
+ };
+ }
+
+ // we set this to vm._watcher inside the watcher's constructor
+ // since the watcher's initial patch may call $forceUpdate (e.g. inside child
+ // component's mounted hook), which relies on vm._watcher being already defined
+ new Watcher(vm, updateComponent, noop, {
+ before: function before () {
+ if (vm._isMounted && !vm._isDestroyed) {
+ callHook(vm, 'beforeUpdate');
+ }
+ }
+ }, true /* isRenderWatcher */);
+ hydrating = false;
+
+ // manually mounted instance, call mounted on self
+ // mounted is called for render-created child components in its inserted hook
+ if (vm.$vnode == null) {
+ vm._isMounted = true;
+ callHook(vm, 'mounted');
+ }
+ return vm
+}
+
+function updateChildComponent (
+ vm,
+ propsData,
+ listeners,
+ parentVnode,
+ renderChildren
+) {
+ {
+ isUpdatingChildComponent = true;
+ }
+
+ // determine whether component has slot children
+ // we need to do this before overwriting $options._renderChildren.
+
+ // check if there are dynamic scopedSlots (hand-written or compiled but with
+ // dynamic slot names). Static scoped slots compiled from template has the
+ // "$stable" marker.
+ var newScopedSlots = parentVnode.data.scopedSlots;
+ var oldScopedSlots = vm.$scopedSlots;
+ var hasDynamicScopedSlot = !!(
+ (newScopedSlots && !newScopedSlots.$stable) ||
+ (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
+ (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
+ );
+
+ // Any static slot children from the parent may have changed during parent's
+ // update. Dynamic scoped slots may also have changed. In such cases, a forced
+ // update is necessary to ensure correctness.
+ var needsForceUpdate = !!(
+ renderChildren || // has new static slots
+ vm.$options._renderChildren || // has old static slots
+ hasDynamicScopedSlot
+ );
+
+ vm.$options._parentVnode = parentVnode;
+ vm.$vnode = parentVnode; // update vm's placeholder node without re-render
+
+ if (vm._vnode) { // update child tree's parent
+ vm._vnode.parent = parentVnode;
+ }
+ vm.$options._renderChildren = renderChildren;
+
+ // update $attrs and $listeners hash
+ // these are also reactive so they may trigger child update if the child
+ // used them during render
+ vm.$attrs = parentVnode.data.attrs || emptyObject;
+ vm.$listeners = listeners || emptyObject;
+
+ // update props
+ if (propsData && vm.$options.props) {
+ toggleObserving(false);
+ var props = vm._props;
+ var propKeys = vm.$options._propKeys || [];
+ for (var i = 0; i < propKeys.length; i++) {
+ var key = propKeys[i];
+ var propOptions = vm.$options.props; // wtf flow?
+ props[key] = validateProp(key, propOptions, propsData, vm);
+ }
+ toggleObserving(true);
+ // keep a copy of raw propsData
+ vm.$options.propsData = propsData;
+ }
+
+ // update listeners
+ listeners = listeners || emptyObject;
+ var oldListeners = vm.$options._parentListeners;
+ vm.$options._parentListeners = listeners;
+ updateComponentListeners(vm, listeners, oldListeners);
+
+ // resolve slots + force update if has children
+ if (needsForceUpdate) {
+ vm.$slots = resolveSlots(renderChildren, parentVnode.context);
+ vm.$forceUpdate();
+ }
+
+ {
+ isUpdatingChildComponent = false;
+ }
+}
+
+function isInInactiveTree (vm) {
+ while (vm && (vm = vm.$parent)) {
+ if (vm._inactive) { return true }
+ }
+ return false
+}
+
+function activateChildComponent (vm, direct) {
+ if (direct) {
+ vm._directInactive = false;
+ if (isInInactiveTree(vm)) {
+ return
+ }
+ } else if (vm._directInactive) {
+ return
+ }
+ if (vm._inactive || vm._inactive === null) {
+ vm._inactive = false;
+ for (var i = 0; i < vm.$children.length; i++) {
+ activateChildComponent(vm.$children[i]);
+ }
+ callHook(vm, 'activated');
+ }
+}
+
+function deactivateChildComponent (vm, direct) {
+ if (direct) {
+ vm._directInactive = true;
+ if (isInInactiveTree(vm)) {
+ return
+ }
+ }
+ if (!vm._inactive) {
+ vm._inactive = true;
+ for (var i = 0; i < vm.$children.length; i++) {
+ deactivateChildComponent(vm.$children[i]);
+ }
+ callHook(vm, 'deactivated');
+ }
+}
+
+function callHook (vm, hook) {
+ // #7573 disable dep collection when invoking lifecycle hooks
+ pushTarget();
+ var handlers = vm.$options[hook];
+ var info = hook + " hook";
+ if (handlers) {
+ for (var i = 0, j = handlers.length; i < j; i++) {
+ invokeWithErrorHandling(handlers[i], vm, null, vm, info);
+ }
+ }
+ if (vm._hasHookEvent) {
+ vm.$emit('hook:' + hook);
+ }
+ popTarget();
+}
+
+/* */
+
+var MAX_UPDATE_COUNT = 100;
+
+var queue = [];
+var activatedChildren = [];
+var has = {};
+var circular = {};
+var waiting = false;
+var flushing = false;
+var index = 0;
+
+/**
+ * Reset the scheduler's state.
+ */
+function resetSchedulerState () {
+ index = queue.length = activatedChildren.length = 0;
+ has = {};
+ {
+ circular = {};
+ }
+ waiting = flushing = false;
+}
+
+// Async edge case #6566 requires saving the timestamp when event listeners are
+// attached. However, calling performance.now() has a perf overhead especially
+// if the page has thousands of event listeners. Instead, we take a timestamp
+// every time the scheduler flushes and use that for all event listeners
+// attached during that flush.
+var currentFlushTimestamp = 0;
+
+// Async edge case fix requires storing an event listener's attach timestamp.
+var getNow = Date.now;
+
+// Determine what event timestamp the browser is using. Annoyingly, the
+// timestamp can either be hi-res (relative to page load) or low-res
+// (relative to UNIX epoch), so in order to compare time we have to use the
+// same timestamp type when saving the flush timestamp.
+if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
+ // if the low-res timestamp which is bigger than the event timestamp
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
+ // and we need to use the hi-res version for event listeners as well.
+ getNow = function () { return performance.now(); };
+}
+
+/**
+ * Flush both queues and run the watchers.
+ */
+function flushSchedulerQueue () {
+ currentFlushTimestamp = getNow();
+ flushing = true;
+ var watcher, id;
+
+ // Sort queue before flush.
+ // This ensures that:
+ // 1. Components are updated from parent to child. (because parent is always
+ // created before the child)
+ // 2. A component's user watchers are run before its render watcher (because
+ // user watchers are created before the render watcher)
+ // 3. If a component is destroyed during a parent component's watcher run,
+ // its watchers can be skipped.
+ queue.sort(function (a, b) { return a.id - b.id; });
+
+ // do not cache length because more watchers might be pushed
+ // as we run existing watchers
+ for (index = 0; index < queue.length; index++) {
+ watcher = queue[index];
+ if (watcher.before) {
+ watcher.before();
+ }
+ id = watcher.id;
+ has[id] = null;
+ watcher.run();
+ // in dev build, check and stop circular updates.
+ if (has[id] != null) {
+ circular[id] = (circular[id] || 0) + 1;
+ if (circular[id] > MAX_UPDATE_COUNT) {
+ warn(
+ 'You may have an infinite update loop ' + (
+ watcher.user
+ ? ("in watcher with expression \"" + (watcher.expression) + "\"")
+ : "in a component render function."
+ ),
+ watcher.vm
+ );
+ break
+ }
+ }
+ }
+
+ // keep copies of post queues before resetting state
+ var activatedQueue = activatedChildren.slice();
+ var updatedQueue = queue.slice();
+
+ resetSchedulerState();
+
+ // call component updated and activated hooks
+ callActivatedHooks(activatedQueue);
+ callUpdatedHooks(updatedQueue);
+
+ // devtool hook
+ /* istanbul ignore if */
+ if (devtools && config.devtools) {
+ devtools.emit('flush');
+ }
+}
+
+function callUpdatedHooks (queue) {
+ var i = queue.length;
+ while (i--) {
+ var watcher = queue[i];
+ var vm = watcher.vm;
+ if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
+ callHook(vm, 'updated');
+ }
+ }
+}
+
+/**
+ * Queue a kept-alive component that was activated during patch.
+ * The queue will be processed after the entire tree has been patched.
+ */
+function queueActivatedComponent (vm) {
+ // setting _inactive to false here so that a render function can
+ // rely on checking whether it's in an inactive tree (e.g. router-view)
+ vm._inactive = false;
+ activatedChildren.push(vm);
+}
+
+function callActivatedHooks (queue) {
+ for (var i = 0; i < queue.length; i++) {
+ queue[i]._inactive = true;
+ activateChildComponent(queue[i], true /* true */);
+ }
+}
+
+/**
+ * Push a watcher into the watcher queue.
+ * Jobs with duplicate IDs will be skipped unless it's
+ * pushed when the queue is being flushed.
+ */
+function queueWatcher (watcher) {
+ var id = watcher.id;
+ if (has[id] == null) {
+ has[id] = true;
+ if (!flushing) {
+ queue.push(watcher);
+ } else {
+ // if already flushing, splice the watcher based on its id
+ // if already past its id, it will be run next immediately.
+ var i = queue.length - 1;
+ while (i > index && queue[i].id > watcher.id) {
+ i--;
+ }
+ queue.splice(i + 1, 0, watcher);
+ }
+ // queue the flush
+ if (!waiting) {
+ waiting = true;
+
+ if (!config.async) {
+ flushSchedulerQueue();
+ return
+ }
+ nextTick(flushSchedulerQueue);
+ }
+ }
+}
+
+/* */
+
+
+
+var uid$2 = 0;
+
+/**
+ * A watcher parses an expression, collects dependencies,
+ * and fires callback when the expression value changes.
+ * This is used for both the $watch() api and directives.
+ */
+var Watcher = function Watcher (
+ vm,
+ expOrFn,
+ cb,
+ options,
+ isRenderWatcher
+) {
+ this.vm = vm;
+ if (isRenderWatcher) {
+ vm._watcher = this;
+ }
+ vm._watchers.push(this);
+ // options
+ if (options) {
+ this.deep = !!options.deep;
+ this.user = !!options.user;
+ this.lazy = !!options.lazy;
+ this.sync = !!options.sync;
+ this.before = options.before;
+ } else {
+ this.deep = this.user = this.lazy = this.sync = false;
+ }
+ this.cb = cb;
+ this.id = ++uid$2; // uid for batching
+ this.active = true;
+ this.dirty = this.lazy; // for lazy watchers
+ this.deps = [];
+ this.newDeps = [];
+ this.depIds = new _Set();
+ this.newDepIds = new _Set();
+ this.expression = expOrFn.toString();
+ // parse expression for getter
+ if (typeof expOrFn === 'function') {
+ this.getter = expOrFn;
+ } else {
+ this.getter = parsePath(expOrFn);
+ if (!this.getter) {
+ this.getter = noop;
+ warn(
+ "Failed watching path: \"" + expOrFn + "\" " +
+ 'Watcher only accepts simple dot-delimited paths. ' +
+ 'For full control, use a function instead.',
+ vm
+ );
+ }
+ }
+ this.value = this.lazy
+ ? undefined
+ : this.get();
+};
+
+/**
+ * Evaluate the getter, and re-collect dependencies.
+ */
+Watcher.prototype.get = function get () {
+ pushTarget(this);
+ var value;
+ var vm = this.vm;
+ try {
+ value = this.getter.call(vm, vm);
+ } catch (e) {
+ if (this.user) {
+ handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
+ } else {
+ throw e
+ }
+ } finally {
+ // "touch" every property so they are all tracked as
+ // dependencies for deep watching
+ if (this.deep) {
+ traverse(value);
+ }
+ popTarget();
+ this.cleanupDeps();
+ }
+ return value
+};
+
+/**
+ * Add a dependency to this directive.
+ */
+Watcher.prototype.addDep = function addDep (dep) {
+ var id = dep.id;
+ if (!this.newDepIds.has(id)) {
+ this.newDepIds.add(id);
+ this.newDeps.push(dep);
+ if (!this.depIds.has(id)) {
+ dep.addSub(this);
+ }
+ }
+};
+
+/**
+ * Clean up for dependency collection.
+ */
+Watcher.prototype.cleanupDeps = function cleanupDeps () {
+ var i = this.deps.length;
+ while (i--) {
+ var dep = this.deps[i];
+ if (!this.newDepIds.has(dep.id)) {
+ dep.removeSub(this);
+ }
+ }
+ var tmp = this.depIds;
+ this.depIds = this.newDepIds;
+ this.newDepIds = tmp;
+ this.newDepIds.clear();
+ tmp = this.deps;
+ this.deps = this.newDeps;
+ this.newDeps = tmp;
+ this.newDeps.length = 0;
+};
+
+/**
+ * Subscriber interface.
+ * Will be called when a dependency changes.
+ */
+Watcher.prototype.update = function update () {
+ /* istanbul ignore else */
+ if (this.lazy) {
+ this.dirty = true;
+ } else if (this.sync) {
+ this.run();
+ } else {
+ queueWatcher(this);
+ }
+};
+
+/**
+ * Scheduler job interface.
+ * Will be called by the scheduler.
+ */
+Watcher.prototype.run = function run () {
+ if (this.active) {
+ var value = this.get();
+ if (
+ value !== this.value ||
+ // Deep watchers and watchers on Object/Arrays should fire even
+ // when the value is the same, because the value may
+ // have mutated.
+ isObject(value) ||
+ this.deep
+ ) {
+ // set new value
+ var oldValue = this.value;
+ this.value = value;
+ if (this.user) {
+ try {
+ this.cb.call(this.vm, value, oldValue);
+ } catch (e) {
+ handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ }
+ } else {
+ this.cb.call(this.vm, value, oldValue);
+ }
+ }
+ }
+};
+
+/**
+ * Evaluate the value of the watcher.
+ * This only gets called for lazy watchers.
+ */
+Watcher.prototype.evaluate = function evaluate () {
+ this.value = this.get();
+ this.dirty = false;
+};
+
+/**
+ * Depend on all deps collected by this watcher.
+ */
+Watcher.prototype.depend = function depend () {
+ var i = this.deps.length;
+ while (i--) {
+ this.deps[i].depend();
+ }
+};
+
+/**
+ * Remove self from all dependencies' subscriber list.
+ */
+Watcher.prototype.teardown = function teardown () {
+ if (this.active) {
+ // remove self from vm's watcher list
+ // this is a somewhat expensive operation so we skip it
+ // if the vm is being destroyed.
+ if (!this.vm._isBeingDestroyed) {
+ remove(this.vm._watchers, this);
+ }
+ var i = this.deps.length;
+ while (i--) {
+ this.deps[i].removeSub(this);
+ }
+ this.active = false;
+ }
+};
+
+/* */
+
+var sharedPropertyDefinition = {
+ enumerable: true,
+ configurable: true,
+ get: noop,
+ set: noop
+};
+
+function proxy (target, sourceKey, key) {
+ sharedPropertyDefinition.get = function proxyGetter () {
+ return this[sourceKey][key]
+ };
+ sharedPropertyDefinition.set = function proxySetter (val) {
+ this[sourceKey][key] = val;
+ };
+ Object.defineProperty(target, key, sharedPropertyDefinition);
+}
+
+function initState (vm) {
+ vm._watchers = [];
+ var opts = vm.$options;
+ if (opts.props) { initProps(vm, opts.props); }
+ if (opts.methods) { initMethods(vm, opts.methods); }
+ if (opts.data) {
+ initData(vm);
+ } else {
+ observe(vm._data = {}, true /* asRootData */);
+ }
+ if (opts.computed) { initComputed(vm, opts.computed); }
+ if (opts.watch && opts.watch !== nativeWatch) {
+ initWatch(vm, opts.watch);
+ }
+}
+
+function initProps (vm, propsOptions) {
+ var propsData = vm.$options.propsData || {};
+ var props = vm._props = {};
+ // cache prop keys so that future props updates can iterate using Array
+ // instead of dynamic object key enumeration.
+ var keys = vm.$options._propKeys = [];
+ var isRoot = !vm.$parent;
+ // root instance props should be converted
+ if (!isRoot) {
+ toggleObserving(false);
+ }
+ var loop = function ( key ) {
+ keys.push(key);
+ var value = validateProp(key, propsOptions, propsData, vm);
+ /* istanbul ignore else */
+ {
+ var hyphenatedKey = hyphenate(key);
+ if (isReservedAttribute(hyphenatedKey) ||
+ config.isReservedAttr(hyphenatedKey)) {
+ warn(
+ ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
+ vm
+ );
+ }
+ defineReactive$$1(props, key, value, function () {
+ if (!isRoot && !isUpdatingChildComponent) {
+ warn(
+ "Avoid mutating a prop directly since the value will be " +
+ "overwritten whenever the parent component re-renders. " +
+ "Instead, use a data or computed property based on the prop's " +
+ "value. Prop being mutated: \"" + key + "\"",
+ vm
+ );
+ }
+ });
+ }
+ // static props are already proxied on the component's prototype
+ // during Vue.extend(). We only need to proxy props defined at
+ // instantiation here.
+ if (!(key in vm)) {
+ proxy(vm, "_props", key);
+ }
+ };
+
+ for (var key in propsOptions) loop( key );
+ toggleObserving(true);
+}
+
+function initData (vm) {
+ var data = vm.$options.data;
+ data = vm._data = typeof data === 'function'
+ ? getData(data, vm)
+ : data || {};
+ if (!isPlainObject(data)) {
+ data = {};
+ warn(
+ 'data functions should return an object:\n' +
+ 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
+ vm
+ );
+ }
+ // proxy data on instance
+ var keys = Object.keys(data);
+ var props = vm.$options.props;
+ var methods = vm.$options.methods;
+ var i = keys.length;
+ while (i--) {
+ var key = keys[i];
+ {
+ if (methods && hasOwn(methods, key)) {
+ warn(
+ ("Method \"" + key + "\" has already been defined as a data property."),
+ vm
+ );
+ }
+ }
+ if (props && hasOwn(props, key)) {
+ warn(
+ "The data property \"" + key + "\" is already declared as a prop. " +
+ "Use prop default value instead.",
+ vm
+ );
+ } else if (!isReserved(key)) {
+ proxy(vm, "_data", key);
+ }
+ }
+ // observe data
+ observe(data, true /* asRootData */);
+}
+
+function getData (data, vm) {
+ // #7573 disable dep collection when invoking data getters
+ pushTarget();
+ try {
+ return data.call(vm, vm)
+ } catch (e) {
+ handleError(e, vm, "data()");
+ return {}
+ } finally {
+ popTarget();
+ }
+}
+
+var computedWatcherOptions = { lazy: true };
+
+function initComputed (vm, computed) {
+ // $flow-disable-line
+ var watchers = vm._computedWatchers = Object.create(null);
+ // computed properties are just getters during SSR
+ var isSSR = isServerRendering();
+
+ for (var key in computed) {
+ var userDef = computed[key];
+ var getter = typeof userDef === 'function' ? userDef : userDef.get;
+ if (getter == null) {
+ warn(
+ ("Getter is missing for computed property \"" + key + "\"."),
+ vm
+ );
+ }
+
+ if (!isSSR) {
+ // create internal watcher for the computed property.
+ watchers[key] = new Watcher(
+ vm,
+ getter || noop,
+ noop,
+ computedWatcherOptions
+ );
+ }
+
+ // component-defined computed properties are already defined on the
+ // component prototype. We only need to define computed properties defined
+ // at instantiation here.
+ if (!(key in vm)) {
+ defineComputed(vm, key, userDef);
+ } else {
+ if (key in vm.$data) {
+ warn(("The computed property \"" + key + "\" is already defined in data."), vm);
+ } else if (vm.$options.props && key in vm.$options.props) {
+ warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
+ }
+ }
+ }
+}
+
+function defineComputed (
+ target,
+ key,
+ userDef
+) {
+ var shouldCache = !isServerRendering();
+ if (typeof userDef === 'function') {
+ sharedPropertyDefinition.get = shouldCache
+ ? createComputedGetter(key)
+ : createGetterInvoker(userDef);
+ sharedPropertyDefinition.set = noop;
+ } else {
+ sharedPropertyDefinition.get = userDef.get
+ ? shouldCache && userDef.cache !== false
+ ? createComputedGetter(key)
+ : createGetterInvoker(userDef.get)
+ : noop;
+ sharedPropertyDefinition.set = userDef.set || noop;
+ }
+ if (sharedPropertyDefinition.set === noop) {
+ sharedPropertyDefinition.set = function () {
+ warn(
+ ("Computed property \"" + key + "\" was assigned to but it has no setter."),
+ this
+ );
+ };
+ }
+ Object.defineProperty(target, key, sharedPropertyDefinition);
+}
+
+function createComputedGetter (key) {
+ return function computedGetter () {
+ var watcher = this._computedWatchers && this._computedWatchers[key];
+ if (watcher) {
+ if (watcher.dirty) {
+ watcher.evaluate();
+ }
+ if (Dep.target) {
+ watcher.depend();
+ }
+ return watcher.value
+ }
+ }
+}
+
+function createGetterInvoker(fn) {
+ return function computedGetter () {
+ return fn.call(this, this)
+ }
+}
+
+function initMethods (vm, methods) {
+ var props = vm.$options.props;
+ for (var key in methods) {
+ {
+ if (typeof methods[key] !== 'function') {
+ warn(
+ "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
+ "Did you reference the function correctly?",
+ vm
+ );
+ }
+ if (props && hasOwn(props, key)) {
+ warn(
+ ("Method \"" + key + "\" has already been defined as a prop."),
+ vm
+ );
+ }
+ if ((key in vm) && isReserved(key)) {
+ warn(
+ "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
+ "Avoid defining component methods that start with _ or $."
+ );
+ }
+ }
+ vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
+ }
+}
+
+function initWatch (vm, watch) {
+ for (var key in watch) {
+ var handler = watch[key];
+ if (Array.isArray(handler)) {
+ for (var i = 0; i < handler.length; i++) {
+ createWatcher(vm, key, handler[i]);
+ }
+ } else {
+ createWatcher(vm, key, handler);
+ }
+ }
+}
+
+function createWatcher (
+ vm,
+ expOrFn,
+ handler,
+ options
+) {
+ if (isPlainObject(handler)) {
+ options = handler;
+ handler = handler.handler;
+ }
+ if (typeof handler === 'string') {
+ handler = vm[handler];
+ }
+ return vm.$watch(expOrFn, handler, options)
+}
+
+function stateMixin (Vue) {
+ // flow somehow has problems with directly declared definition object
+ // when using Object.defineProperty, so we have to procedurally build up
+ // the object here.
+ var dataDef = {};
+ dataDef.get = function () { return this._data };
+ var propsDef = {};
+ propsDef.get = function () { return this._props };
+ {
+ dataDef.set = function () {
+ warn(
+ 'Avoid replacing instance root $data. ' +
+ 'Use nested data properties instead.',
+ this
+ );
+ };
+ propsDef.set = function () {
+ warn("$props is readonly.", this);
+ };
+ }
+ Object.defineProperty(Vue.prototype, '$data', dataDef);
+ Object.defineProperty(Vue.prototype, '$props', propsDef);
+
+ Vue.prototype.$set = set;
+ Vue.prototype.$delete = del;
+
+ Vue.prototype.$watch = function (
+ expOrFn,
+ cb,
+ options
+ ) {
+ var vm = this;
+ if (isPlainObject(cb)) {
+ return createWatcher(vm, expOrFn, cb, options)
+ }
+ options = options || {};
+ options.user = true;
+ var watcher = new Watcher(vm, expOrFn, cb, options);
+ if (options.immediate) {
+ try {
+ cb.call(vm, watcher.value);
+ } catch (error) {
+ handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
+ }
+ }
+ return function unwatchFn () {
+ watcher.teardown();
+ }
+ };
+}
+
+/* */
+
var uid$3 = 0;
function initMixin (Vue) {
@@ -5127,7 +5458,7 @@ function initMixin (Vue) {
var startTag, endTag;
/* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
+ if (config.performance && mark) {
startTag = "vue-perf-start:" + (vm._uid);
endTag = "vue-perf-end:" + (vm._uid);
mark(startTag);
@@ -5149,10 +5480,8 @@ function initMixin (Vue) {
);
}
/* istanbul ignore else */
- if (true) {
+ {
initProxy(vm);
- } else {
- vm._renderProxy = vm;
}
// expose real self
vm._self = vm;
@@ -5166,7 +5495,7 @@ function initMixin (Vue) {
callHook(vm, 'created');
/* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
+ if (config.performance && mark) {
vm._name = formatComponentName(vm, false);
mark(endTag);
measure(("vue " + (vm._name) + " init"), startTag, endTag);
@@ -5184,8 +5513,6 @@ function initInternalComponent (vm, options) {
var parentVnode = options._parentVnode;
opts.parent = options.parent;
opts._parentVnode = parentVnode;
- opts._parentElm = options._parentElm;
- opts._refElm = options._refElm;
var vnodeComponentOptions = parentVnode.componentOptions;
opts.propsData = vnodeComponentOptions.propsData;
@@ -5226,39 +5553,18 @@ function resolveConstructorOptions (Ctor) {
function resolveModifiedOptions (Ctor) {
var modified;
var latest = Ctor.options;
- var extended = Ctor.extendOptions;
var sealed = Ctor.sealedOptions;
for (var key in latest) {
if (latest[key] !== sealed[key]) {
if (!modified) { modified = {}; }
- modified[key] = dedupe(latest[key], extended[key], sealed[key]);
+ modified[key] = latest[key];
}
}
return modified
}
-function dedupe (latest, extended, sealed) {
- // compare latest and sealed to ensure lifecycle hooks won't be duplicated
- // between merges
- if (Array.isArray(latest)) {
- var res = [];
- sealed = Array.isArray(sealed) ? sealed : [sealed];
- extended = Array.isArray(extended) ? extended : [extended];
- for (var i = 0; i < latest.length; i++) {
- // push original options and not sealed options to exclude duplicated options
- if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
- res.push(latest[i]);
- }
- }
- return res
- } else {
- return latest
- }
-}
-
function Vue (options) {
- if ("development" !== 'production' &&
- !(this instanceof Vue)
+ if (!(this instanceof Vue)
) {
warn('Vue is a constructor and should be called with the `new` keyword');
}
@@ -5326,7 +5632,7 @@ function initExtend (Vue) {
}
var name = extendOptions.name || Super.options.name;
- if ("development" !== 'production' && name) {
+ if (name) {
validateComponentName(name);
}
@@ -5409,7 +5715,7 @@ function initAssetRegisters (Vue) {
return this.options[type + 's'][id]
} else {
/* istanbul ignore if */
- if ("development" !== 'production' && type === 'component') {
+ if (type === 'component') {
validateComponentName(id);
}
if (type === 'component' && isPlainObject(definition)) {
@@ -5428,6 +5734,8 @@ function initAssetRegisters (Vue) {
/* */
+
+
function getComponentName (opts) {
return opts && (opts.Ctor.options.name || opts.tag)
}
@@ -5491,10 +5799,8 @@ var KeepAlive = {
},
destroyed: function destroyed () {
- var this$1 = this;
-
- for (var key in this$1.cache) {
- pruneCacheEntry(this$1.cache, key, this$1.keys);
+ for (var key in this.cache) {
+ pruneCacheEntry(this.cache, key, this.keys);
}
},
@@ -5554,11 +5860,11 @@ var KeepAlive = {
}
return vnode || (slot && slot[0])
}
-}
+};
var builtInComponents = {
KeepAlive: KeepAlive
-}
+};
/* */
@@ -5566,7 +5872,7 @@ function initGlobalAPI (Vue) {
// config
var configDef = {};
configDef.get = function () { return config; };
- if (true) {
+ {
configDef.set = function () {
warn(
'Do not replace the Vue.config object, set individual fields instead.'
@@ -5582,13 +5888,19 @@ function initGlobalAPI (Vue) {
warn: warn,
extend: extend,
mergeOptions: mergeOptions,
- defineReactive: defineReactive
+ defineReactive: defineReactive$$1
};
Vue.set = set;
Vue.delete = del;
Vue.nextTick = nextTick;
+ // 2.6 explicit observable API
+ Vue.observable = function (obj) {
+ observe(obj);
+ return obj
+ };
+
Vue.options = Object.create(null);
ASSET_TYPES.forEach(function (type) {
Vue.options[type + 's'] = Object.create(null);
@@ -5624,7 +5936,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
value: FunctionalRenderContext
});
-Vue.version = '2.5.17';
+Vue.version = '2.6.7';
/* */
@@ -5645,6 +5957,17 @@ var mustUseProp = function (tag, type, attr) {
var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
+var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
+
+var convertEnumeratedValue = function (key, value) {
+ return isFalsyAttrValue(value) || value === 'false'
+ ? 'false'
+ // allow arbitrary string value for contenteditable
+ : key === 'contenteditable' && isValidContentEditableValue(value)
+ ? value
+ : 'true'
+};
+
var isBooleanAttr = makeMap(
'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
@@ -5833,7 +6156,7 @@ function query (el) {
if (typeof el === 'string') {
var selected = document.querySelector(el);
if (!selected) {
- "development" !== 'production' && warn(
+ warn(
'Cannot find element: ' + el
);
return document.createElement('div')
@@ -5902,20 +6225,19 @@ function setStyleScope (node, scopeId) {
node.setAttribute(scopeId, '');
}
-
-var nodeOps = Object.freeze({
- createElement: createElement$1,
- createElementNS: createElementNS,
- createTextNode: createTextNode,
- createComment: createComment,
- insertBefore: insertBefore,
- removeChild: removeChild,
- appendChild: appendChild,
- parentNode: parentNode,
- nextSibling: nextSibling,
- tagName: tagName,
- setTextContent: setTextContent,
- setStyleScope: setStyleScope
+var nodeOps = /*#__PURE__*/Object.freeze({
+ createElement: createElement$1,
+ createElementNS: createElementNS,
+ createTextNode: createTextNode,
+ createComment: createComment,
+ insertBefore: insertBefore,
+ removeChild: removeChild,
+ appendChild: appendChild,
+ parentNode: parentNode,
+ nextSibling: nextSibling,
+ tagName: tagName,
+ setTextContent: setTextContent,
+ setStyleScope: setStyleScope
});
/* */
@@ -5933,7 +6255,7 @@ var ref = {
destroy: function destroy (vnode) {
registerRef(vnode, true);
}
-}
+};
function registerRef (vnode, isRemoval) {
var key = vnode.data.ref;
@@ -6034,13 +6356,13 @@ function createPatchFunction (backend) {
}
function createRmCb (childElm, listeners) {
- function remove () {
- if (--remove.listeners === 0) {
+ function remove$$1 () {
+ if (--remove$$1.listeners === 0) {
removeNode(childElm);
}
}
- remove.listeners = listeners;
- return remove
+ remove$$1.listeners = listeners;
+ return remove$$1
}
function removeNode (el) {
@@ -6096,7 +6418,7 @@ function createPatchFunction (backend) {
var children = vnode.children;
var tag = vnode.tag;
if (isDef(tag)) {
- if (true) {
+ {
if (data && data.pre) {
creatingElmInVPre++;
}
@@ -6124,7 +6446,7 @@ function createPatchFunction (backend) {
insert(parentElm, vnode.elm, refElm);
}
- if ("development" !== 'production' && data && data.pre) {
+ if (data && data.pre) {
creatingElmInVPre--;
}
} else if (isTrue(vnode.isComment)) {
@@ -6141,7 +6463,7 @@ function createPatchFunction (backend) {
if (isDef(i)) {
var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
if (isDef(i = i.hook) && isDef(i = i.init)) {
- i(vnode, false /* hydrating */, parentElm, refElm);
+ i(vnode, false /* hydrating */);
}
// after calling the init hook, if the vnode is a child component
// it should've created a child instance and mounted it. the child
@@ -6149,6 +6471,7 @@ function createPatchFunction (backend) {
// in that case we can just return the element and be done.
if (isDef(vnode.componentInstance)) {
initComponent(vnode, insertedVnodeQueue);
+ insert(parentElm, vnode.elm, refElm);
if (isTrue(isReactivated)) {
reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
}
@@ -6200,7 +6523,7 @@ function createPatchFunction (backend) {
function insert (parent, elm, ref$$1) {
if (isDef(parent)) {
if (isDef(ref$$1)) {
- if (ref$$1.parentNode === parent) {
+ if (nodeOps.parentNode(ref$$1) === parent) {
nodeOps.insertBefore(parent, elm, ref$$1);
}
} else {
@@ -6211,7 +6534,7 @@ function createPatchFunction (backend) {
function createChildren (vnode, children, insertedVnodeQueue) {
if (Array.isArray(children)) {
- if (true) {
+ {
checkDuplicateKeys(children);
}
for (var i = 0; i < children.length; ++i) {
@@ -6345,7 +6668,7 @@ function createPatchFunction (backend) {
// during leaving transitions
var canMove = !removeOnly;
- if (true) {
+ {
checkDuplicateKeys(newCh);
}
@@ -6355,20 +6678,20 @@ function createPatchFunction (backend) {
} else if (isUndef(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode)) {
- patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode)) {
- patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
- patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
- patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
@@ -6382,7 +6705,7 @@ function createPatchFunction (backend) {
} else {
vnodeToMove = oldCh[idxInOld];
if (sameVnode(vnodeToMove, newStartVnode)) {
- patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue);
+ patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
} else {
@@ -6426,11 +6749,23 @@ function createPatchFunction (backend) {
}
}
- function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
+ function patchVnode (
+ oldVnode,
+ vnode,
+ insertedVnodeQueue,
+ ownerArray,
+ index,
+ removeOnly
+ ) {
if (oldVnode === vnode) {
return
}
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
+ // clone reused vnode
+ vnode = ownerArray[index] = cloneVNode(vnode);
+ }
+
var elm = vnode.elm = oldVnode.elm;
if (isTrue(oldVnode.isAsyncPlaceholder)) {
@@ -6471,6 +6806,9 @@ function createPatchFunction (backend) {
if (isDef(oldCh) && isDef(ch)) {
if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
} else if (isDef(ch)) {
+ {
+ checkDuplicateKeys(ch);
+ }
if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
} else if (isDef(oldCh)) {
@@ -6519,7 +6857,7 @@ function createPatchFunction (backend) {
return true
}
// assert node match
- if (true) {
+ {
if (!assertNodeMatch(elm, vnode, inVPre)) {
return false
}
@@ -6542,8 +6880,7 @@ function createPatchFunction (backend) {
if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
if (i !== elm.innerHTML) {
/* istanbul ignore if */
- if ("development" !== 'production' &&
- typeof console !== 'undefined' &&
+ if (typeof console !== 'undefined' &&
!hydrationBailed
) {
hydrationBailed = true;
@@ -6568,8 +6905,7 @@ function createPatchFunction (backend) {
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
- if ("development" !== 'production' &&
- typeof console !== 'undefined' &&
+ if (typeof console !== 'undefined' &&
!hydrationBailed
) {
hydrationBailed = true;
@@ -6612,7 +6948,7 @@ function createPatchFunction (backend) {
}
}
- return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
+ return function patch (oldVnode, vnode, hydrating, removeOnly) {
if (isUndef(vnode)) {
if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
return
@@ -6624,12 +6960,12 @@ function createPatchFunction (backend) {
if (isUndef(oldVnode)) {
// empty mount (likely as component), create new root element
isInitialPatch = true;
- createElm(vnode, insertedVnodeQueue, parentElm, refElm);
+ createElm(vnode, insertedVnodeQueue);
} else {
var isRealElement = isDef(oldVnode.nodeType);
if (!isRealElement && sameVnode(oldVnode, vnode)) {
// patch existing root node
- patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
} else {
if (isRealElement) {
// mounting to a real element
@@ -6643,7 +6979,7 @@ function createPatchFunction (backend) {
if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
invokeInsertHook(vnode, insertedVnodeQueue, true);
return oldVnode
- } else if (true) {
+ } else {
warn(
'The client-side rendered virtual DOM tree is not matching ' +
'server-rendered content. This is likely caused by incorrect ' +
@@ -6660,7 +6996,7 @@ function createPatchFunction (backend) {
// replacing existing element
var oldElm = oldVnode.elm;
- var parentElm$1 = nodeOps.parentNode(oldElm);
+ var parentElm = nodeOps.parentNode(oldElm);
// create new node
createElm(
@@ -6669,7 +7005,7 @@ function createPatchFunction (backend) {
// extremely rare edge case: do not insert if old element is in a
// leaving transition. Only happens when combining transition +
// keep-alive + HOCs. (#4590)
- oldElm._leaveCb ? null : parentElm$1,
+ oldElm._leaveCb ? null : parentElm,
nodeOps.nextSibling(oldElm)
);
@@ -6704,8 +7040,8 @@ function createPatchFunction (backend) {
}
// destroy old node
- if (isDef(parentElm$1)) {
- removeVnodes(parentElm$1, [oldVnode], 0, 0);
+ if (isDef(parentElm)) {
+ removeVnodes(parentElm, [oldVnode], 0, 0);
} else if (isDef(oldVnode.tag)) {
invokeDestroyHook(oldVnode);
}
@@ -6725,7 +7061,7 @@ var directives = {
destroy: function unbindDirectives (vnode) {
updateDirectives(vnode, emptyNode);
}
-}
+};
function updateDirectives (oldVnode, vnode) {
if (oldVnode.data.directives || vnode.data.directives) {
@@ -6755,6 +7091,7 @@ function _update (oldVnode, vnode) {
} else {
// existing directive, update
dir.oldValue = oldDir.value;
+ dir.oldArg = oldDir.arg;
callHook$1(dir, 'update', vnode, oldVnode);
if (dir.def && dir.def.componentUpdated) {
dirsWithPostpatch.push(dir);
@@ -6836,7 +7173,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
var baseModules = [
ref,
directives
-]
+];
/* */
@@ -6898,7 +7235,7 @@ function setAttr (el, key, value) {
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
- el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
+ el.setAttribute(key, convertEnumeratedValue(key, value));
} else if (isXlink(key)) {
if (isFalsyAttrValue(value)) {
el.removeAttributeNS(xlinkNS, getXlinkProp(key));
@@ -6921,7 +7258,7 @@ function baseSetAttr (el, key, value) {
if (
isIE && !isIE9 &&
el.tagName === 'TEXTAREA' &&
- key === 'placeholder' && !el.__ieph
+ key === 'placeholder' && value !== '' && !el.__ieph
) {
var blocker = function (e) {
e.stopImmediatePropagation();
@@ -6938,7 +7275,7 @@ function baseSetAttr (el, key, value) {
var attrs = {
create: updateAttrs,
update: updateAttrs
-}
+};
/* */
@@ -6976,7 +7313,7 @@ function updateClass (oldVnode, vnode) {
var klass = {
create: updateClass,
update: updateClass
-}
+};
/* */
@@ -7078,9 +7415,13 @@ function wrapFilter (exp, filter) {
/* */
-function baseWarn (msg) {
+
+
+/* eslint-disable no-unused-vars */
+function baseWarn (msg, range) {
console.error(("[Vue compiler]: " + msg));
}
+/* eslint-enable no-unused-vars */
function pluckModuleFunction (
modules,
@@ -7091,20 +7432,23 @@ function pluckModuleFunction (
: []
}
-function addProp (el, name, value) {
- (el.props || (el.props = [])).push({ name: name, value: value });
+function addProp (el, name, value, range, dynamic) {
+ (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
el.plain = false;
}
-function addAttr (el, name, value) {
- (el.attrs || (el.attrs = [])).push({ name: name, value: value });
+function addAttr (el, name, value, range, dynamic) {
+ var attrs = dynamic
+ ? (el.dynamicAttrs || (el.dynamicAttrs = []))
+ : (el.attrs || (el.attrs = []));
+ attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
el.plain = false;
}
// add a raw attr (use this in preTransforms)
-function addRawAttr (el, name, value) {
+function addRawAttr (el, name, value, range) {
el.attrsMap[name] = value;
- el.attrsList.push({ name: name, value: value });
+ el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
}
function addDirective (
@@ -7113,60 +7457,84 @@ function addDirective (
rawName,
value,
arg,
- modifiers
+ isDynamicArg,
+ modifiers,
+ range
) {
- (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
+ (el.directives || (el.directives = [])).push(rangeSetItem({
+ name: name,
+ rawName: rawName,
+ value: value,
+ arg: arg,
+ isDynamicArg: isDynamicArg,
+ modifiers: modifiers
+ }, range));
el.plain = false;
}
+function prependModifierMarker (symbol, name, dynamic) {
+ return dynamic
+ ? ("_p(" + name + ",\"" + symbol + "\")")
+ : symbol + name // mark the event as captured
+}
+
function addHandler (
el,
name,
value,
modifiers,
important,
- warn
+ warn,
+ range,
+ dynamic
) {
modifiers = modifiers || emptyObject;
// warn prevent and passive modifier
/* istanbul ignore if */
if (
- "development" !== 'production' && warn &&
+ warn &&
modifiers.prevent && modifiers.passive
) {
warn(
'passive and prevent can\'t be used together. ' +
- 'Passive handler can\'t prevent default event.'
+ 'Passive handler can\'t prevent default event.',
+ range
);
}
- // check capture modifier
- if (modifiers.capture) {
- delete modifiers.capture;
- name = '!' + name; // mark the event as captured
- }
- if (modifiers.once) {
- delete modifiers.once;
- name = '~' + name; // mark the event as once
- }
- /* istanbul ignore if */
- if (modifiers.passive) {
- delete modifiers.passive;
- name = '&' + name; // mark the event as passive
- }
-
// 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 (name === 'click') {
- if (modifiers.right) {
+ if (modifiers.right) {
+ if (dynamic) {
+ name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
+ } else if (name === 'click') {
name = 'contextmenu';
delete modifiers.right;
- } else if (modifiers.middle) {
+ }
+ } else if (modifiers.middle) {
+ if (dynamic) {
+ name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
+ } else if (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);
+ }
+
var events;
if (modifiers.native) {
delete modifiers.native;
@@ -7175,9 +7543,7 @@ function addHandler (
events = el.events || (el.events = {});
}
- var newHandler = {
- value: value.trim()
- };
+ var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
if (modifiers !== emptyObject) {
newHandler.modifiers = modifiers;
}
@@ -7195,6 +7561,15 @@ function addHandler (
el.plain = false;
}
+function getRawBindingAttr (
+ el,
+ name
+) {
+ return el.rawAttrsMap[':' + name] ||
+ el.rawAttrsMap['v-bind:' + name] ||
+ el.rawAttrsMap[name]
+}
+
function getBindingAttr (
el,
name,
@@ -7238,6 +7613,35 @@ function getAndRemoveAttr (
return val
}
+function getAndRemoveAttrByRegex (
+ el,
+ name
+) {
+ var list = el.attrsList;
+ for (var i = 0, l = list.length; i < l; i++) {
+ var attr = list[i];
+ if (name.test(attr.name)) {
+ list.splice(i, 1);
+ return attr
+ }
+ }
+}
+
+function rangeSetItem (
+ item,
+ range
+) {
+ if (range) {
+ if (range.start != null) {
+ item.start = range.start;
+ }
+ if (range.end != null) {
+ item.end = range.end;
+ }
+ }
+ return item
+}
+
/* */
/**
@@ -7267,7 +7671,7 @@ function genComponentModel (
el.model = {
value: ("(" + value + ")"),
- expression: ("\"" + value + "\""),
+ expression: JSON.stringify(value),
callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
};
}
@@ -7302,12 +7706,7 @@ function genAssignmentCode (
*
*/
-var len;
-var str;
-var chr;
-var index$1;
-var expressionPos;
-var expressionEndPos;
+var len, str, chr, index$1, expressionPos, expressionEndPos;
@@ -7411,13 +7810,14 @@ function model (
var tag = el.tag;
var type = el.attrsMap.type;
- if (true) {
+ {
// 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."
+ "File inputs are read only. Use a v-on:change listener instead.",
+ el.rawAttrsMap['v-model']
);
}
}
@@ -7438,12 +7838,13 @@ function model (
genComponentModel(el, value, modifiers);
// component v-model doesn't need extra runtime
return false
- } else if (true) {
+ } 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.'
+ 'wrap a library dedicated for that purpose inside a custom component.',
+ el.rawAttrsMap['v-model']
);
}
@@ -7520,14 +7921,15 @@ function genDefaultModel (
// warn if v-bind:value conflicts with v-model
// except for inputs with v-bind:type
- if (true) {
+ {
var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
if (value$1 && !typeBinding) {
var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
warn$1(
binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
- 'because the latter already expands to a value binding internally'
+ 'because the latter already expands to a value binding internally',
+ el.rawAttrsMap[binding]
);
}
}
@@ -7588,7 +7990,7 @@ function normalizeEvents (on) {
var target$1;
-function createOnceHandler (handler, event, capture) {
+function createOnceHandler$1 (event, handler, capture) {
var _target = target$1; // save current target element in closure
return function onceHandler () {
var res = handler.apply(null, arguments);
@@ -7598,17 +8000,47 @@ function createOnceHandler (handler, event, capture) {
}
}
+// #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
+// implementation and does not fire microtasks in between event propagation, so
+// safe to exclude.
+var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
+
function add$1 (
- event,
+ name,
handler,
- once$$1,
capture,
passive
) {
- handler = withMacroTask(handler);
- if (once$$1) { handler = createOnceHandler(handler, event, capture); }
+ // async edge case #6566: inner click event triggers patch, event handler
+ // attached to outer element during patch, and triggered again. This
+ // happens because browsers fire microtask ticks between event propagation.
+ // the solution is simple: we save the timestamp when a handler is attached,
+ // and the handler would only fire if the event passed to it was fired
+ // AFTER it was attached.
+ if (useMicrotaskFix) {
+ var attachedTimestamp = currentFlushTimestamp;
+ var original = handler;
+ handler = original._wrapper = function (e) {
+ if (
+ // no bubbling, should always fire.
+ // this is just a safety net in case event.timeStamp is unreliable in
+ // certain weird environments...
+ e.target === e.currentTarget ||
+ // event is fired after handler attachment
+ e.timeStamp >= attachedTimestamp ||
+ // #9462 bail for iOS 9 bug: event.timeStamp is 0 after history.pushState
+ e.timeStamp === 0 ||
+ // #9448 bail if event is fired in another document in a multi-page
+ // electron/nw.js app, since event.timeStamp will be using a different
+ // starting reference
+ e.target.ownerDocument !== document
+ ) {
+ return original.apply(this, arguments)
+ }
+ };
+ }
target$1.addEventListener(
- event,
+ name,
handler,
supportsPassive
? { capture: capture, passive: passive }
@@ -7617,14 +8049,14 @@ function add$1 (
}
function remove$2 (
- event,
+ name,
handler,
capture,
_target
) {
(_target || target$1).removeEventListener(
- event,
- handler._withTask || handler,
+ name,
+ handler._wrapper || handler,
capture
);
}
@@ -7637,17 +8069,19 @@ function updateDOMListeners (oldVnode, vnode) {
var oldOn = oldVnode.data.on || {};
target$1 = vnode.elm;
normalizeEvents(on);
- updateListeners(on, oldOn, add$1, remove$2, vnode.context);
+ updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
target$1 = undefined;
}
var events = {
create: updateDOMListeners,
update: updateDOMListeners
-}
+};
/* */
+var svgContainer;
+
function updateDOMProps (oldVnode, vnode) {
if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
return
@@ -7681,7 +8115,7 @@ function updateDOMProps (oldVnode, vnode) {
}
}
- if (key === 'value') {
+ if (key === 'value' && elm.tagName !== 'PROGRESS') {
// store value as _value as well since
// non-string values will be stringified
elm._value = cur;
@@ -7690,8 +8124,29 @@ function updateDOMProps (oldVnode, vnode) {
if (shouldUpdateValue(elm, strCur)) {
elm.value = strCur;
}
- } else {
- elm[key] = cur;
+ } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
+ // IE doesn't support innerHTML for SVG elements
+ svgContainer = svgContainer || document.createElement('div');
+ svgContainer.innerHTML = "
";
+ var svg = svgContainer.firstChild;
+ while (elm.firstChild) {
+ elm.removeChild(elm.firstChild);
+ }
+ while (svg.firstChild) {
+ elm.appendChild(svg.firstChild);
+ }
+ } else if (
+ // skip the update if old and new VDOM state is the same.
+ // `value` is handled separately because the DOM value may be temporarily
+ // out of sync with VDOM state due to focus, composition and modifiers.
+ // This #4521 by skipping the unnecesarry `checked` update.
+ cur !== oldProps[key]
+ ) {
+ // some property updates can throw
+ // e.g. `value` on