build: build 2.4.3

This commit is contained in:
Evan You 2017-09-13 03:57:29 -04:00
parent c8564abd62
commit ef432c6e86
13 changed files with 1568 additions and 839 deletions

357
dist/vue.common.js vendored
View File

@ -1,5 +1,5 @@
/*!
* Vue.js v2.4.2
* Vue.js v2.4.3
* (c) 2014-2017 Evan You
* Released under the MIT License.
*/
@ -164,12 +164,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -588,7 +585,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -670,13 +667,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -976,9 +973,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1155,7 +1152,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1558,7 +1555,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1756,7 +1758,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
function cloneVNode (vnode) {
function cloneVNode (vnode, deep) {
var cloned = new VNode(
vnode.tag,
vnode.data,
@ -1772,14 +1774,17 @@ function cloneVNode (vnode) {
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.isCloned = true;
if (deep && vnode.children) {
cloned.children = cloneVNodes(vnode.children);
}
return cloned
}
function cloneVNodes (vnodes) {
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i]);
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
@ -1793,8 +1798,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -1820,6 +1827,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -1828,10 +1840,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -1841,12 +1856,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -2161,11 +2184,17 @@ function resolveAsyncComponent (
/* */
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)) {
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c
}
}
@ -2252,8 +2281,8 @@ function eventsMixin (Vue) {
}
// array of events
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
this$1.$off(event[i$1], fn);
for (var i = 0, l = event.length; i < l; i++) {
this$1.$off(event[i], fn);
}
return vm
}
@ -2266,14 +2295,16 @@ function eventsMixin (Vue) {
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
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);
break
}
}
}
return vm
@ -2325,10 +2356,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -2581,11 +2617,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -3172,7 +3208,7 @@ function initData (vm) {
if (process.env.NODE_ENV !== 'production') {
if (methods && hasOwn(methods, key)) {
warn(
("method \"" + key + "\" has already been defined as a data property."),
("Method \"" + key + "\" has already been defined as a data property."),
vm
);
}
@ -3205,6 +3241,8 @@ var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'computed');
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];
@ -3215,8 +3253,16 @@ function initComputed (vm, computed) {
vm
);
}
// create internal watcher for the computed property.
watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
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
@ -3233,13 +3279,20 @@ function initComputed (vm, computed) {
}
}
function defineComputed (target, key, userDef) {
function defineComputed (
target,
key,
userDef
) {
var shouldCache = !isServerRendering();
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = createComputedGetter(key);
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: userDef;
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? userDef.cache !== false
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: userDef.get
: noop;
@ -3278,22 +3331,28 @@ function initMethods (vm, methods) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'methods');
var props = vm.$options.props;
for (var key in methods) {
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
if (process.env.NODE_ENV !== 'production') {
if (methods[key] == null) {
warn(
"method \"" + key + "\" has an undefined value in the component definition. " +
"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."),
("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);
}
}
@ -3413,7 +3472,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -3448,7 +3510,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -3463,7 +3525,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -3787,7 +3849,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -4083,17 +4145,18 @@ function initRender (vm) {
// $attrs & $listeners are exposed for easier HOC creation.
// they need to be reactive so that HOCs using them are always updated
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, null, true);
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, null, true);
}
}
@ -4110,9 +4173,13 @@ function renderMixin (Vue) {
var _parentVnode = ref._parentVnode;
if (vm._isMounted) {
// clone slot nodes on re-renders
// if the parent didn't update, the slot nodes will be the ones from
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key]);
var slot = vm.$slots[key];
if (slot._rendered) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
}
}
@ -4657,7 +4724,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
}
});
Vue$3.version = '2.4.2';
Vue$3.version = '2.4.3';
/* */
@ -4666,7 +4733,7 @@ Vue$3.version = '2.4.2';
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -4855,6 +4922,8 @@ function isUnknownElement (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -5001,8 +5070,6 @@ function registerRef (vnode, isRemoval) {
*
* modified by Evan You (@yyx990803)
*
/*
* Not type-checking this because this file is perf-critical and the cost
* of making flow understand it is not worth it.
*/
@ -5028,14 +5095,12 @@ function sameVnode (a, b) {
)
}
// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') { return true }
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
}
function createKeyToOldIdx (children, beginIdx, endIdx) {
@ -5367,10 +5432,11 @@ function createPatchFunction (backend) {
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
idxInOld = isDef(newStartVnode.key)
? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
/* istanbul ignore if */
@ -5384,13 +5450,12 @@ function createPatchFunction (backend) {
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
// same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
@ -5401,6 +5466,13 @@ function createPatchFunction (backend) {
}
}
function findIdxInOld (node, oldCh, start, end) {
for (var i = start; i < end; i++) {
var c = oldCh[i];
if (isDef(c) && sameVnode(node, c)) { return i }
}
}
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
if (oldVnode === vnode) {
return
@ -5508,27 +5580,46 @@ function createPatchFunction (backend) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
// v-html and domProps: innerHTML
if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
if (i !== elm.innerHTML) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('server innerHTML: ', i);
console.warn('client innerHTML: ', elm.innerHTML);
}
return false
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
} else {
// iterate and compare children lists
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
}
return false
}
return false
}
}
}
@ -5619,14 +5710,28 @@ function createPatchFunction (backend) {
// component root element replaced.
// update parent placeholder node element, recursively
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
ancestor.elm = vnode.elm;
ancestor = ancestor.parent;
}
if (isPatchable(vnode)) {
for (var i = 0; i < cbs.create.length; ++i) {
cbs.create[i](emptyNode, vnode.parent);
for (var i = 0; i < cbs.destroy.length; ++i) {
cbs.destroy[i](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
// #6513
// invoke insert hooks that may have been merged by create hooks.
// e.g. for directives that uses the "inserted" hook.
var insert = ancestor.data.hook.insert;
if (insert.merged) {
// start at index 1 to avoid re-invoking component mounted hook
for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
insert.fns[i$2]();
}
}
}
ancestor = ancestor.parent;
}
}
@ -5810,7 +5915,12 @@ function setAttr (el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
el.setAttribute(key, key);
// technically allowfullscreen is a boolean attribute for <iframe>,
// but Flash expects a value of "true" when used on <embed> tag
value = key === 'allowfullscreen' && el.tagName === 'EMBED'
? 'true'
: key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
@ -6317,7 +6427,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat($$v))}" +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true
@ -6686,7 +6796,7 @@ function updateStyle (oldVnode, vnode) {
var style = normalizeStyleBinding(vnode.data.style) || {};
// store normalized style under a different key for next diff
// make sure to clone it if it's reactive, since the user likley wants
// make sure to clone it if it's reactive, since the user likely wants
// to mutate it.
vnode.data.normalizedStyle = isDef(style.__ob__)
? extend({}, style)
@ -7291,8 +7401,6 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
* properties to Elements.
*/
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* istanbul ignore if */
if (isIE9) {
// http://www.matts411.com/post/internet-explorer-9-oninput/
@ -7307,14 +7415,7 @@ if (isIE9) {
var model$1 = {
inserted: function inserted (el, binding, vnode) {
if (vnode.tag === 'select') {
var cb = function () {
setSelected(el, binding, vnode.context);
};
cb();
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(cb, 0);
}
setSelected(el, binding, vnode.context);
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
@ -7345,13 +7446,30 @@ var model$1 = {
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
trigger(el, 'change');
// trigger change event if
// no matching option found for at least one value
var needReset = el.multiple
? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, 'change');
}
}
}
}
};
function setSelected (el, binding, vm) {
actuallySetSelected(el, binding, vm);
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(function () {
actuallySetSelected(el, binding, vm);
}, 0);
}
}
function actuallySetSelected (el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
@ -7384,6 +7502,10 @@ function setSelected (el, binding, vm) {
}
}
function hasNoMatchingOption (value, options) {
return options.every(function (o) { return !looseEqual(o, value); })
}
function getValue (option) {
return '_value' in option
? option._value
@ -7546,10 +7668,6 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var Transition = {
name: 'transition',
props: transitionProps,
@ -8117,29 +8235,14 @@ var he = {
*/
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>/=]+)/;
var singleAttrAssign = /(?:=)/;
var singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
// attr value, single quotes
/'([^']*)'+/.source,
// attr value, no quotes
/([^\s"'=<>`]+)/.source
];
var attribute = new RegExp(
'^\\s*' + singleAttrIdentifier.source +
'(?:\\s*(' + singleAttrAssign.source + ')' +
'\\s*(?:' + singleAttrValues.join('|') + '))?'
);
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
// but for Vue templates we can enforce a simple charset
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
var startTagOpen = new RegExp('^<' + qnameCapture);
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/;
var conditionalComment = /^<!\[/;
@ -8839,6 +8942,8 @@ function processSlot (el) {
var slotTarget = getBindingAttr(el, 'slot');
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
// preserve slot as an attribute for native shadow DOM compat
addAttr(el, 'slot', slotTarget);
}
if (el.tag === 'template') {
el.slotScope = getAndRemoveAttr(el, 'scope');
@ -9375,7 +9480,7 @@ function genOnce (el, state) {
);
return genElement(el, state)
}
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
} else {
return genStatic(el, state)
}

357
dist/vue.esm.js vendored
View File

@ -1,5 +1,5 @@
/*!
* Vue.js v2.4.2
* Vue.js v2.4.3
* (c) 2014-2017 Evan You
* Released under the MIT License.
*/
@ -162,12 +162,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -586,7 +583,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -668,13 +665,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -974,9 +971,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1153,7 +1150,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1556,7 +1553,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1754,7 +1756,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
function cloneVNode (vnode) {
function cloneVNode (vnode, deep) {
var cloned = new VNode(
vnode.tag,
vnode.data,
@ -1770,14 +1772,17 @@ function cloneVNode (vnode) {
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.isCloned = true;
if (deep && vnode.children) {
cloned.children = cloneVNodes(vnode.children);
}
return cloned
}
function cloneVNodes (vnodes) {
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i]);
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
@ -1791,8 +1796,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -1818,6 +1825,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -1826,10 +1838,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -1839,12 +1854,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -2159,11 +2182,17 @@ function resolveAsyncComponent (
/* */
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)) {
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c
}
}
@ -2250,8 +2279,8 @@ function eventsMixin (Vue) {
}
// array of events
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
this$1.$off(event[i$1], fn);
for (var i = 0, l = event.length; i < l; i++) {
this$1.$off(event[i], fn);
}
return vm
}
@ -2264,14 +2293,16 @@ function eventsMixin (Vue) {
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
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);
break
}
}
}
return vm
@ -2323,10 +2354,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -2579,11 +2615,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -3170,7 +3206,7 @@ function initData (vm) {
if (process.env.NODE_ENV !== 'production') {
if (methods && hasOwn(methods, key)) {
warn(
("method \"" + key + "\" has already been defined as a data property."),
("Method \"" + key + "\" has already been defined as a data property."),
vm
);
}
@ -3203,6 +3239,8 @@ var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'computed');
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];
@ -3213,8 +3251,16 @@ function initComputed (vm, computed) {
vm
);
}
// create internal watcher for the computed property.
watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
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
@ -3231,13 +3277,20 @@ function initComputed (vm, computed) {
}
}
function defineComputed (target, key, userDef) {
function defineComputed (
target,
key,
userDef
) {
var shouldCache = !isServerRendering();
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = createComputedGetter(key);
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: userDef;
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? userDef.cache !== false
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: userDef.get
: noop;
@ -3276,22 +3329,28 @@ function initMethods (vm, methods) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'methods');
var props = vm.$options.props;
for (var key in methods) {
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
if (process.env.NODE_ENV !== 'production') {
if (methods[key] == null) {
warn(
"method \"" + key + "\" has an undefined value in the component definition. " +
"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."),
("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);
}
}
@ -3411,7 +3470,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -3446,7 +3508,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -3461,7 +3523,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -3785,7 +3847,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -4081,17 +4143,18 @@ function initRender (vm) {
// $attrs & $listeners are exposed for easier HOC creation.
// they need to be reactive so that HOCs using them are always updated
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, null, true);
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, null, true);
}
}
@ -4108,9 +4171,13 @@ function renderMixin (Vue) {
var _parentVnode = ref._parentVnode;
if (vm._isMounted) {
// clone slot nodes on re-renders
// if the parent didn't update, the slot nodes will be the ones from
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key]);
var slot = vm.$slots[key];
if (slot._rendered) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
}
}
@ -4655,7 +4722,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
}
});
Vue$3.version = '2.4.2';
Vue$3.version = '2.4.3';
/* */
@ -4664,7 +4731,7 @@ Vue$3.version = '2.4.2';
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -4853,6 +4920,8 @@ function isUnknownElement (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -4999,8 +5068,6 @@ function registerRef (vnode, isRemoval) {
*
* modified by Evan You (@yyx990803)
*
/*
* Not type-checking this because this file is perf-critical and the cost
* of making flow understand it is not worth it.
*/
@ -5026,14 +5093,12 @@ function sameVnode (a, b) {
)
}
// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') { return true }
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
}
function createKeyToOldIdx (children, beginIdx, endIdx) {
@ -5365,10 +5430,11 @@ function createPatchFunction (backend) {
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
idxInOld = isDef(newStartVnode.key)
? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
/* istanbul ignore if */
@ -5382,13 +5448,12 @@ function createPatchFunction (backend) {
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
// same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
@ -5399,6 +5464,13 @@ function createPatchFunction (backend) {
}
}
function findIdxInOld (node, oldCh, start, end) {
for (var i = start; i < end; i++) {
var c = oldCh[i];
if (isDef(c) && sameVnode(node, c)) { return i }
}
}
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
if (oldVnode === vnode) {
return
@ -5506,27 +5578,46 @@ function createPatchFunction (backend) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
// v-html and domProps: innerHTML
if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
if (i !== elm.innerHTML) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('server innerHTML: ', i);
console.warn('client innerHTML: ', elm.innerHTML);
}
return false
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
} else {
// iterate and compare children lists
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
}
return false
}
return false
}
}
}
@ -5617,14 +5708,28 @@ function createPatchFunction (backend) {
// component root element replaced.
// update parent placeholder node element, recursively
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
ancestor.elm = vnode.elm;
ancestor = ancestor.parent;
}
if (isPatchable(vnode)) {
for (var i = 0; i < cbs.create.length; ++i) {
cbs.create[i](emptyNode, vnode.parent);
for (var i = 0; i < cbs.destroy.length; ++i) {
cbs.destroy[i](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
// #6513
// invoke insert hooks that may have been merged by create hooks.
// e.g. for directives that uses the "inserted" hook.
var insert = ancestor.data.hook.insert;
if (insert.merged) {
// start at index 1 to avoid re-invoking component mounted hook
for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
insert.fns[i$2]();
}
}
}
ancestor = ancestor.parent;
}
}
@ -5808,7 +5913,12 @@ function setAttr (el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
el.setAttribute(key, key);
// technically allowfullscreen is a boolean attribute for <iframe>,
// but Flash expects a value of "true" when used on <embed> tag
value = key === 'allowfullscreen' && el.tagName === 'EMBED'
? 'true'
: key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
@ -6315,7 +6425,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat($$v))}" +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true
@ -6684,7 +6794,7 @@ function updateStyle (oldVnode, vnode) {
var style = normalizeStyleBinding(vnode.data.style) || {};
// store normalized style under a different key for next diff
// make sure to clone it if it's reactive, since the user likley wants
// make sure to clone it if it's reactive, since the user likely wants
// to mutate it.
vnode.data.normalizedStyle = isDef(style.__ob__)
? extend({}, style)
@ -7289,8 +7399,6 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
* properties to Elements.
*/
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* istanbul ignore if */
if (isIE9) {
// http://www.matts411.com/post/internet-explorer-9-oninput/
@ -7305,14 +7413,7 @@ if (isIE9) {
var model$1 = {
inserted: function inserted (el, binding, vnode) {
if (vnode.tag === 'select') {
var cb = function () {
setSelected(el, binding, vnode.context);
};
cb();
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(cb, 0);
}
setSelected(el, binding, vnode.context);
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
@ -7343,13 +7444,30 @@ var model$1 = {
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
trigger(el, 'change');
// trigger change event if
// no matching option found for at least one value
var needReset = el.multiple
? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, 'change');
}
}
}
}
};
function setSelected (el, binding, vm) {
actuallySetSelected(el, binding, vm);
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(function () {
actuallySetSelected(el, binding, vm);
}, 0);
}
}
function actuallySetSelected (el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
@ -7382,6 +7500,10 @@ function setSelected (el, binding, vm) {
}
}
function hasNoMatchingOption (value, options) {
return options.every(function (o) { return !looseEqual(o, value); })
}
function getValue (option) {
return '_value' in option
? option._value
@ -7544,10 +7666,6 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var Transition = {
name: 'transition',
props: transitionProps,
@ -8115,29 +8233,14 @@ var he = {
*/
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>/=]+)/;
var singleAttrAssign = /(?:=)/;
var singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
// attr value, single quotes
/'([^']*)'+/.source,
// attr value, no quotes
/([^\s"'=<>`]+)/.source
];
var attribute = new RegExp(
'^\\s*' + singleAttrIdentifier.source +
'(?:\\s*(' + singleAttrAssign.source + ')' +
'\\s*(?:' + singleAttrValues.join('|') + '))?'
);
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
// but for Vue templates we can enforce a simple charset
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
var startTagOpen = new RegExp('^<' + qnameCapture);
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/;
var conditionalComment = /^<!\[/;
@ -8837,6 +8940,8 @@ function processSlot (el) {
var slotTarget = getBindingAttr(el, 'slot');
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
// preserve slot as an attribute for native shadow DOM compat
addAttr(el, 'slot', slotTarget);
}
if (el.tag === 'template') {
el.slotScope = getAndRemoveAttr(el, 'scope');
@ -9373,7 +9478,7 @@ function genOnce (el, state) {
);
return genElement(el, state)
}
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
} else {
return genStatic(el, state)
}

355
dist/vue.js vendored
View File

@ -1,5 +1,5 @@
/*!
* Vue.js v2.4.2
* Vue.js v2.4.3
* (c) 2014-2017 Evan You
* Released under the MIT License.
*/
@ -83,7 +83,7 @@ function toString (val) {
}
/**
* Convert an input value to a number for persistence.
* Convert a input value to a number for persistence.
* If the conversion fails, return original string.
*/
function toNumber (val) {
@ -168,12 +168,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -592,7 +589,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -674,13 +671,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -980,9 +977,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1159,7 +1156,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1562,7 +1559,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1760,7 +1762,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
function cloneVNode (vnode) {
function cloneVNode (vnode, deep) {
var cloned = new VNode(
vnode.tag,
vnode.data,
@ -1776,14 +1778,17 @@ function cloneVNode (vnode) {
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.isCloned = true;
if (deep && vnode.children) {
cloned.children = cloneVNodes(vnode.children);
}
return cloned
}
function cloneVNodes (vnodes) {
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i]);
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
@ -1797,8 +1802,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -1824,6 +1831,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -1832,10 +1844,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
"development" !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -1845,12 +1860,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -2163,11 +2186,17 @@ function resolveAsyncComponent (
/* */
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)) {
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c
}
}
@ -2254,8 +2283,8 @@ function eventsMixin (Vue) {
}
// array of events
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
this$1.$off(event[i$1], fn);
for (var i = 0, l = event.length; i < l; i++) {
this$1.$off(event[i], fn);
}
return vm
}
@ -2268,14 +2297,16 @@ function eventsMixin (Vue) {
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
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);
break
}
}
}
return vm
@ -2327,10 +2358,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -2583,11 +2619,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -3170,7 +3206,7 @@ function initData (vm) {
{
if (methods && hasOwn(methods, key)) {
warn(
("method \"" + key + "\" has already been defined as a data property."),
("Method \"" + key + "\" has already been defined as a data property."),
vm
);
}
@ -3203,6 +3239,8 @@ var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
"development" !== 'production' && checkOptionType(vm, 'computed');
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];
@ -3213,8 +3251,16 @@ function initComputed (vm, computed) {
vm
);
}
// create internal watcher for the computed property.
watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
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
@ -3231,13 +3277,20 @@ function initComputed (vm, computed) {
}
}
function defineComputed (target, key, userDef) {
function defineComputed (
target,
key,
userDef
) {
var shouldCache = !isServerRendering();
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = createComputedGetter(key);
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: userDef;
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? userDef.cache !== false
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: userDef.get
: noop;
@ -3276,22 +3329,28 @@ function initMethods (vm, methods) {
"development" !== 'production' && checkOptionType(vm, 'methods');
var props = vm.$options.props;
for (var key in methods) {
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
{
if (methods[key] == null) {
warn(
"method \"" + key + "\" has an undefined value in the component definition. " +
"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."),
("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);
}
}
@ -3409,7 +3468,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -3444,7 +3506,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -3459,7 +3521,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -3783,7 +3845,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -4079,12 +4141,13 @@ function initRender (vm) {
// $attrs & $listeners are exposed for easier HOC creation.
// they need to be reactive so that HOCs using them are always updated
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
{
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
}
@ -4103,9 +4166,13 @@ function renderMixin (Vue) {
var _parentVnode = ref._parentVnode;
if (vm._isMounted) {
// clone slot nodes on re-renders
// if the parent didn't update, the slot nodes will be the ones from
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key]);
var slot = vm.$slots[key];
if (slot._rendered) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
}
}
@ -4646,7 +4713,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
}
});
Vue$3.version = '2.4.2';
Vue$3.version = '2.4.3';
/* */
@ -4655,7 +4722,7 @@ Vue$3.version = '2.4.2';
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -4844,6 +4911,8 @@ function isUnknownElement (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -4990,8 +5059,6 @@ function registerRef (vnode, isRemoval) {
*
* modified by Evan You (@yyx990803)
*
/*
* Not type-checking this because this file is perf-critical and the cost
* of making flow understand it is not worth it.
*/
@ -5017,14 +5084,12 @@ function sameVnode (a, b) {
)
}
// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') { return true }
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
}
function createKeyToOldIdx (children, beginIdx, endIdx) {
@ -5356,10 +5421,11 @@ function createPatchFunction (backend) {
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
idxInOld = isDef(newStartVnode.key)
? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
/* istanbul ignore if */
@ -5373,13 +5439,12 @@ function createPatchFunction (backend) {
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
// same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
@ -5390,6 +5455,13 @@ function createPatchFunction (backend) {
}
}
function findIdxInOld (node, oldCh, start, end) {
for (var i = start; i < end; i++) {
var c = oldCh[i];
if (isDef(c) && sameVnode(node, c)) { return i }
}
}
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
if (oldVnode === vnode) {
return
@ -5497,27 +5569,46 @@ function createPatchFunction (backend) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
// v-html and domProps: innerHTML
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' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('server innerHTML: ', i);
console.warn('client innerHTML: ', elm.innerHTML);
}
return false
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if ("development" !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
} else {
// iterate and compare children lists
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
if ("development" !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
}
return false
}
return false
}
}
}
@ -5608,14 +5699,28 @@ function createPatchFunction (backend) {
// component root element replaced.
// update parent placeholder node element, recursively
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
ancestor.elm = vnode.elm;
ancestor = ancestor.parent;
}
if (isPatchable(vnode)) {
for (var i = 0; i < cbs.create.length; ++i) {
cbs.create[i](emptyNode, vnode.parent);
for (var i = 0; i < cbs.destroy.length; ++i) {
cbs.destroy[i](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
// #6513
// invoke insert hooks that may have been merged by create hooks.
// e.g. for directives that uses the "inserted" hook.
var insert = ancestor.data.hook.insert;
if (insert.merged) {
// start at index 1 to avoid re-invoking component mounted hook
for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
insert.fns[i$2]();
}
}
}
ancestor = ancestor.parent;
}
}
@ -5799,7 +5904,12 @@ function setAttr (el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
el.setAttribute(key, key);
// technically allowfullscreen is a boolean attribute for <iframe>,
// but Flash expects a value of "true" when used on <embed> tag
value = key === 'allowfullscreen' && el.tagName === 'EMBED'
? 'true'
: key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
@ -6306,7 +6416,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat($$v))}" +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true
@ -6675,7 +6785,7 @@ function updateStyle (oldVnode, vnode) {
var style = normalizeStyleBinding(vnode.data.style) || {};
// store normalized style under a different key for next diff
// make sure to clone it if it's reactive, since the user likley wants
// make sure to clone it if it's reactive, since the user likely wants
// to mutate it.
vnode.data.normalizedStyle = isDef(style.__ob__)
? extend({}, style)
@ -7280,8 +7390,6 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
* properties to Elements.
*/
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* istanbul ignore if */
if (isIE9) {
// http://www.matts411.com/post/internet-explorer-9-oninput/
@ -7296,14 +7404,7 @@ if (isIE9) {
var model$1 = {
inserted: function inserted (el, binding, vnode) {
if (vnode.tag === 'select') {
var cb = function () {
setSelected(el, binding, vnode.context);
};
cb();
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(cb, 0);
}
setSelected(el, binding, vnode.context);
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
@ -7334,13 +7435,30 @@ var model$1 = {
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
trigger(el, 'change');
// trigger change event if
// no matching option found for at least one value
var needReset = el.multiple
? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, 'change');
}
}
}
}
};
function setSelected (el, binding, vm) {
actuallySetSelected(el, binding, vm);
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(function () {
actuallySetSelected(el, binding, vm);
}, 0);
}
}
function actuallySetSelected (el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
@ -7373,6 +7491,10 @@ function setSelected (el, binding, vm) {
}
}
function hasNoMatchingOption (value, options) {
return options.every(function (o) { return !looseEqual(o, value); })
}
function getValue (option) {
return '_value' in option
? option._value
@ -7535,10 +7657,6 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var Transition = {
name: 'transition',
props: transitionProps,
@ -8106,29 +8224,14 @@ var he = {
*/
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>/=]+)/;
var singleAttrAssign = /(?:=)/;
var singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
// attr value, single quotes
/'([^']*)'+/.source,
// attr value, no quotes
/([^\s"'=<>`]+)/.source
];
var attribute = new RegExp(
'^\\s*' + singleAttrIdentifier.source +
'(?:\\s*(' + singleAttrAssign.source + ')' +
'\\s*(?:' + singleAttrValues.join('|') + '))?'
);
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
// but for Vue templates we can enforce a simple charset
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
var startTagOpen = new RegExp('^<' + qnameCapture);
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/;
var conditionalComment = /^<!\[/;
@ -8828,6 +8931,8 @@ function processSlot (el) {
var slotTarget = getBindingAttr(el, 'slot');
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
// preserve slot as an attribute for native shadow DOM compat
addAttr(el, 'slot', slotTarget);
}
if (el.tag === 'template') {
el.slotScope = getAndRemoveAttr(el, 'scope');
@ -9364,7 +9469,7 @@ function genOnce (el, state) {
);
return genElement(el, state)
}
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
} else {
return genStatic(el, state)
}

4
dist/vue.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* Vue.js v2.4.2
* Vue.js v2.4.3
* (c) 2014-2017 Evan You
* Released under the MIT License.
*/
@ -164,12 +164,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -584,7 +581,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -666,13 +663,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -972,9 +969,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1151,7 +1148,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1554,7 +1551,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1752,7 +1754,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
function cloneVNode (vnode) {
function cloneVNode (vnode, deep) {
var cloned = new VNode(
vnode.tag,
vnode.data,
@ -1768,14 +1770,17 @@ function cloneVNode (vnode) {
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.isCloned = true;
if (deep && vnode.children) {
cloned.children = cloneVNodes(vnode.children);
}
return cloned
}
function cloneVNodes (vnodes) {
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i]);
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
@ -1789,8 +1794,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -1816,6 +1823,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -1824,10 +1836,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -1837,12 +1852,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -2157,11 +2180,17 @@ function resolveAsyncComponent (
/* */
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)) {
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c
}
}
@ -2248,8 +2277,8 @@ function eventsMixin (Vue) {
}
// array of events
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
this$1.$off(event[i$1], fn);
for (var i = 0, l = event.length; i < l; i++) {
this$1.$off(event[i], fn);
}
return vm
}
@ -2262,14 +2291,16 @@ function eventsMixin (Vue) {
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
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);
break
}
}
}
return vm
@ -2321,10 +2352,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -2577,11 +2613,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -3168,7 +3204,7 @@ function initData (vm) {
if (process.env.NODE_ENV !== 'production') {
if (methods && hasOwn(methods, key)) {
warn(
("method \"" + key + "\" has already been defined as a data property."),
("Method \"" + key + "\" has already been defined as a data property."),
vm
);
}
@ -3201,6 +3237,8 @@ var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'computed');
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];
@ -3211,8 +3249,16 @@ function initComputed (vm, computed) {
vm
);
}
// create internal watcher for the computed property.
watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
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
@ -3229,13 +3275,20 @@ function initComputed (vm, computed) {
}
}
function defineComputed (target, key, userDef) {
function defineComputed (
target,
key,
userDef
) {
var shouldCache = !isServerRendering();
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = createComputedGetter(key);
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: userDef;
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? userDef.cache !== false
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: userDef.get
: noop;
@ -3274,22 +3327,28 @@ function initMethods (vm, methods) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'methods');
var props = vm.$options.props;
for (var key in methods) {
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
if (process.env.NODE_ENV !== 'production') {
if (methods[key] == null) {
warn(
"method \"" + key + "\" has an undefined value in the component definition. " +
"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."),
("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);
}
}
@ -3409,7 +3468,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -3444,7 +3506,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -3459,7 +3521,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -3783,7 +3845,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -4079,17 +4141,18 @@ function initRender (vm) {
// $attrs & $listeners are exposed for easier HOC creation.
// they need to be reactive so that HOCs using them are always updated
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, null, true);
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, null, true);
}
}
@ -4106,9 +4169,13 @@ function renderMixin (Vue) {
var _parentVnode = ref._parentVnode;
if (vm._isMounted) {
// clone slot nodes on re-renders
// if the parent didn't update, the slot nodes will be the ones from
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key]);
var slot = vm.$slots[key];
if (slot._rendered) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
}
}
@ -4653,7 +4720,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
}
});
Vue$3.version = '2.4.2';
Vue$3.version = '2.4.3';
/* */
@ -4662,7 +4729,7 @@ Vue$3.version = '2.4.2';
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -4851,6 +4918,8 @@ function isUnknownElement (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -4997,8 +5066,6 @@ function registerRef (vnode, isRemoval) {
*
* modified by Evan You (@yyx990803)
*
/*
* Not type-checking this because this file is perf-critical and the cost
* of making flow understand it is not worth it.
*/
@ -5024,14 +5091,12 @@ function sameVnode (a, b) {
)
}
// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') { return true }
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
}
function createKeyToOldIdx (children, beginIdx, endIdx) {
@ -5363,10 +5428,11 @@ function createPatchFunction (backend) {
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
idxInOld = isDef(newStartVnode.key)
? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
/* istanbul ignore if */
@ -5380,13 +5446,12 @@ function createPatchFunction (backend) {
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
// same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
@ -5397,6 +5462,13 @@ function createPatchFunction (backend) {
}
}
function findIdxInOld (node, oldCh, start, end) {
for (var i = start; i < end; i++) {
var c = oldCh[i];
if (isDef(c) && sameVnode(node, c)) { return i }
}
}
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
if (oldVnode === vnode) {
return
@ -5504,27 +5576,46 @@ function createPatchFunction (backend) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
// v-html and domProps: innerHTML
if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
if (i !== elm.innerHTML) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('server innerHTML: ', i);
console.warn('client innerHTML: ', elm.innerHTML);
}
return false
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
} else {
// iterate and compare children lists
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
}
return false
}
return false
}
}
}
@ -5615,14 +5706,28 @@ function createPatchFunction (backend) {
// component root element replaced.
// update parent placeholder node element, recursively
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
ancestor.elm = vnode.elm;
ancestor = ancestor.parent;
}
if (isPatchable(vnode)) {
for (var i = 0; i < cbs.create.length; ++i) {
cbs.create[i](emptyNode, vnode.parent);
for (var i = 0; i < cbs.destroy.length; ++i) {
cbs.destroy[i](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
// #6513
// invoke insert hooks that may have been merged by create hooks.
// e.g. for directives that uses the "inserted" hook.
var insert = ancestor.data.hook.insert;
if (insert.merged) {
// start at index 1 to avoid re-invoking component mounted hook
for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
insert.fns[i$2]();
}
}
}
ancestor = ancestor.parent;
}
}
@ -5806,7 +5911,12 @@ function setAttr (el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
el.setAttribute(key, key);
// technically allowfullscreen is a boolean attribute for <iframe>,
// but Flash expects a value of "true" when used on <embed> tag
value = key === 'allowfullscreen' && el.tagName === 'EMBED'
? 'true'
: key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
@ -6220,7 +6330,7 @@ function updateStyle (oldVnode, vnode) {
var style = normalizeStyleBinding(vnode.data.style) || {};
// store normalized style under a different key for next diff
// make sure to clone it if it's reactive, since the user likley wants
// make sure to clone it if it's reactive, since the user likely wants
// to mutate it.
vnode.data.normalizedStyle = isDef(style.__ob__)
? extend({}, style)
@ -6825,8 +6935,6 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
* properties to Elements.
*/
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* istanbul ignore if */
if (isIE9) {
// http://www.matts411.com/post/internet-explorer-9-oninput/
@ -6841,14 +6949,7 @@ if (isIE9) {
var model$1 = {
inserted: function inserted (el, binding, vnode) {
if (vnode.tag === 'select') {
var cb = function () {
setSelected(el, binding, vnode.context);
};
cb();
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(cb, 0);
}
setSelected(el, binding, vnode.context);
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
@ -6879,13 +6980,30 @@ var model$1 = {
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
trigger(el, 'change');
// trigger change event if
// no matching option found for at least one value
var needReset = el.multiple
? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, 'change');
}
}
}
}
};
function setSelected (el, binding, vm) {
actuallySetSelected(el, binding, vm);
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(function () {
actuallySetSelected(el, binding, vm);
}, 0);
}
}
function actuallySetSelected (el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
@ -6918,6 +7036,10 @@ function setSelected (el, binding, vm) {
}
}
function hasNoMatchingOption (value, options) {
return options.every(function (o) { return !looseEqual(o, value); })
}
function getValue (option) {
return '_value' in option
? option._value
@ -7080,10 +7202,6 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var Transition = {
name: 'transition',
props: transitionProps,

View File

@ -1,5 +1,5 @@
/*!
* Vue.js v2.4.2
* Vue.js v2.4.3
* (c) 2014-2017 Evan You
* Released under the MIT License.
*/
@ -162,12 +162,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -582,7 +579,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -664,13 +661,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -970,9 +967,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1149,7 +1146,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1552,7 +1549,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1750,7 +1752,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
function cloneVNode (vnode) {
function cloneVNode (vnode, deep) {
var cloned = new VNode(
vnode.tag,
vnode.data,
@ -1766,14 +1768,17 @@ function cloneVNode (vnode) {
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.isCloned = true;
if (deep && vnode.children) {
cloned.children = cloneVNodes(vnode.children);
}
return cloned
}
function cloneVNodes (vnodes) {
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i]);
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
@ -1787,8 +1792,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -1814,6 +1821,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -1822,10 +1834,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -1835,12 +1850,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -2155,11 +2178,17 @@ function resolveAsyncComponent (
/* */
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)) {
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c
}
}
@ -2246,8 +2275,8 @@ function eventsMixin (Vue) {
}
// array of events
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
this$1.$off(event[i$1], fn);
for (var i = 0, l = event.length; i < l; i++) {
this$1.$off(event[i], fn);
}
return vm
}
@ -2260,14 +2289,16 @@ function eventsMixin (Vue) {
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
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);
break
}
}
}
return vm
@ -2319,10 +2350,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -2575,11 +2611,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -3166,7 +3202,7 @@ function initData (vm) {
if (process.env.NODE_ENV !== 'production') {
if (methods && hasOwn(methods, key)) {
warn(
("method \"" + key + "\" has already been defined as a data property."),
("Method \"" + key + "\" has already been defined as a data property."),
vm
);
}
@ -3199,6 +3235,8 @@ var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'computed');
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];
@ -3209,8 +3247,16 @@ function initComputed (vm, computed) {
vm
);
}
// create internal watcher for the computed property.
watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
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
@ -3227,13 +3273,20 @@ function initComputed (vm, computed) {
}
}
function defineComputed (target, key, userDef) {
function defineComputed (
target,
key,
userDef
) {
var shouldCache = !isServerRendering();
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = createComputedGetter(key);
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: userDef;
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? userDef.cache !== false
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: userDef.get
: noop;
@ -3272,22 +3325,28 @@ function initMethods (vm, methods) {
process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'methods');
var props = vm.$options.props;
for (var key in methods) {
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
if (process.env.NODE_ENV !== 'production') {
if (methods[key] == null) {
warn(
"method \"" + key + "\" has an undefined value in the component definition. " +
"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."),
("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);
}
}
@ -3407,7 +3466,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -3442,7 +3504,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -3457,7 +3519,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -3781,7 +3843,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -4077,17 +4139,18 @@ function initRender (vm) {
// $attrs & $listeners are exposed for easier HOC creation.
// they need to be reactive so that HOCs using them are always updated
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, null, true);
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, null, true);
}
}
@ -4104,9 +4167,13 @@ function renderMixin (Vue) {
var _parentVnode = ref._parentVnode;
if (vm._isMounted) {
// clone slot nodes on re-renders
// if the parent didn't update, the slot nodes will be the ones from
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key]);
var slot = vm.$slots[key];
if (slot._rendered) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
}
}
@ -4651,7 +4718,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
}
});
Vue$3.version = '2.4.2';
Vue$3.version = '2.4.3';
/* */
@ -4660,7 +4727,7 @@ Vue$3.version = '2.4.2';
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -4849,6 +4916,8 @@ function isUnknownElement (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -4995,8 +5064,6 @@ function registerRef (vnode, isRemoval) {
*
* modified by Evan You (@yyx990803)
*
/*
* Not type-checking this because this file is perf-critical and the cost
* of making flow understand it is not worth it.
*/
@ -5022,14 +5089,12 @@ function sameVnode (a, b) {
)
}
// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') { return true }
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
}
function createKeyToOldIdx (children, beginIdx, endIdx) {
@ -5361,10 +5426,11 @@ function createPatchFunction (backend) {
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
idxInOld = isDef(newStartVnode.key)
? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
/* istanbul ignore if */
@ -5378,13 +5444,12 @@ function createPatchFunction (backend) {
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
// same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
@ -5395,6 +5460,13 @@ function createPatchFunction (backend) {
}
}
function findIdxInOld (node, oldCh, start, end) {
for (var i = start; i < end; i++) {
var c = oldCh[i];
if (isDef(c) && sameVnode(node, c)) { return i }
}
}
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
if (oldVnode === vnode) {
return
@ -5502,27 +5574,46 @@ function createPatchFunction (backend) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
// v-html and domProps: innerHTML
if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
if (i !== elm.innerHTML) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('server innerHTML: ', i);
console.warn('client innerHTML: ', elm.innerHTML);
}
return false
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
} else {
// iterate and compare children lists
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
}
return false
}
return false
}
}
}
@ -5613,14 +5704,28 @@ function createPatchFunction (backend) {
// component root element replaced.
// update parent placeholder node element, recursively
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
ancestor.elm = vnode.elm;
ancestor = ancestor.parent;
}
if (isPatchable(vnode)) {
for (var i = 0; i < cbs.create.length; ++i) {
cbs.create[i](emptyNode, vnode.parent);
for (var i = 0; i < cbs.destroy.length; ++i) {
cbs.destroy[i](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
// #6513
// invoke insert hooks that may have been merged by create hooks.
// e.g. for directives that uses the "inserted" hook.
var insert = ancestor.data.hook.insert;
if (insert.merged) {
// start at index 1 to avoid re-invoking component mounted hook
for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
insert.fns[i$2]();
}
}
}
ancestor = ancestor.parent;
}
}
@ -5804,7 +5909,12 @@ function setAttr (el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
el.setAttribute(key, key);
// technically allowfullscreen is a boolean attribute for <iframe>,
// but Flash expects a value of "true" when used on <embed> tag
value = key === 'allowfullscreen' && el.tagName === 'EMBED'
? 'true'
: key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
@ -6218,7 +6328,7 @@ function updateStyle (oldVnode, vnode) {
var style = normalizeStyleBinding(vnode.data.style) || {};
// store normalized style under a different key for next diff
// make sure to clone it if it's reactive, since the user likley wants
// make sure to clone it if it's reactive, since the user likely wants
// to mutate it.
vnode.data.normalizedStyle = isDef(style.__ob__)
? extend({}, style)
@ -6823,8 +6933,6 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
* properties to Elements.
*/
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* istanbul ignore if */
if (isIE9) {
// http://www.matts411.com/post/internet-explorer-9-oninput/
@ -6839,14 +6947,7 @@ if (isIE9) {
var model$1 = {
inserted: function inserted (el, binding, vnode) {
if (vnode.tag === 'select') {
var cb = function () {
setSelected(el, binding, vnode.context);
};
cb();
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(cb, 0);
}
setSelected(el, binding, vnode.context);
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
@ -6877,13 +6978,30 @@ var model$1 = {
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
trigger(el, 'change');
// trigger change event if
// no matching option found for at least one value
var needReset = el.multiple
? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, 'change');
}
}
}
}
};
function setSelected (el, binding, vm) {
actuallySetSelected(el, binding, vm);
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(function () {
actuallySetSelected(el, binding, vm);
}, 0);
}
}
function actuallySetSelected (el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
@ -6916,6 +7034,10 @@ function setSelected (el, binding, vm) {
}
}
function hasNoMatchingOption (value, options) {
return options.every(function (o) { return !looseEqual(o, value); })
}
function getValue (option) {
return '_value' in option
? option._value
@ -7078,10 +7200,6 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var Transition = {
name: 'transition',
props: transitionProps,

324
dist/vue.runtime.js vendored
View File

@ -1,5 +1,5 @@
/*!
* Vue.js v2.4.2
* Vue.js v2.4.3
* (c) 2014-2017 Evan You
* Released under the MIT License.
*/
@ -168,12 +168,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -588,7 +585,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -670,13 +667,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -976,9 +973,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1155,7 +1152,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1558,7 +1555,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1756,7 +1758,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference.
function cloneVNode (vnode) {
function cloneVNode (vnode, deep) {
var cloned = new VNode(
vnode.tag,
vnode.data,
@ -1772,14 +1774,17 @@ function cloneVNode (vnode) {
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.isCloned = true;
if (deep && vnode.children) {
cloned.children = cloneVNodes(vnode.children);
}
return cloned
}
function cloneVNodes (vnodes) {
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i]);
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
@ -1793,8 +1798,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -1820,6 +1827,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -1828,10 +1840,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
"development" !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -1841,12 +1856,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -2159,11 +2182,17 @@ function resolveAsyncComponent (
/* */
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)) {
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c
}
}
@ -2250,8 +2279,8 @@ function eventsMixin (Vue) {
}
// array of events
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
this$1.$off(event[i$1], fn);
for (var i = 0, l = event.length; i < l; i++) {
this$1.$off(event[i], fn);
}
return vm
}
@ -2264,14 +2293,16 @@ function eventsMixin (Vue) {
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
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);
break
}
}
}
return vm
@ -2323,10 +2354,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -2579,11 +2615,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -3166,7 +3202,7 @@ function initData (vm) {
{
if (methods && hasOwn(methods, key)) {
warn(
("method \"" + key + "\" has already been defined as a data property."),
("Method \"" + key + "\" has already been defined as a data property."),
vm
);
}
@ -3199,6 +3235,8 @@ var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
"development" !== 'production' && checkOptionType(vm, 'computed');
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];
@ -3209,8 +3247,16 @@ function initComputed (vm, computed) {
vm
);
}
// create internal watcher for the computed property.
watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
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
@ -3227,13 +3273,20 @@ function initComputed (vm, computed) {
}
}
function defineComputed (target, key, userDef) {
function defineComputed (
target,
key,
userDef
) {
var shouldCache = !isServerRendering();
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = createComputedGetter(key);
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: userDef;
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? userDef.cache !== false
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: userDef.get
: noop;
@ -3272,22 +3325,28 @@ function initMethods (vm, methods) {
"development" !== 'production' && checkOptionType(vm, 'methods');
var props = vm.$options.props;
for (var key in methods) {
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
{
if (methods[key] == null) {
warn(
"method \"" + key + "\" has an undefined value in the component definition. " +
"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."),
("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);
}
}
@ -3405,7 +3464,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -3440,7 +3502,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -3455,7 +3517,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -3779,7 +3841,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -4075,12 +4137,13 @@ function initRender (vm) {
// $attrs & $listeners are exposed for easier HOC creation.
// they need to be reactive so that HOCs using them are always updated
var parentData = parentVnode && parentVnode.data;
/* istanbul ignore else */
{
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
defineReactive$$1(vm, '$listeners', vm.$options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
}
@ -4099,9 +4162,13 @@ function renderMixin (Vue) {
var _parentVnode = ref._parentVnode;
if (vm._isMounted) {
// clone slot nodes on re-renders
// if the parent didn't update, the slot nodes will be the ones from
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key]);
var slot = vm.$slots[key];
if (slot._rendered) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
}
}
@ -4642,7 +4709,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
}
});
Vue$3.version = '2.4.2';
Vue$3.version = '2.4.3';
/* */
@ -4651,7 +4718,7 @@ Vue$3.version = '2.4.2';
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -4840,6 +4907,8 @@ function isUnknownElement (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -4986,8 +5055,6 @@ function registerRef (vnode, isRemoval) {
*
* modified by Evan You (@yyx990803)
*
/*
* Not type-checking this because this file is perf-critical and the cost
* of making flow understand it is not worth it.
*/
@ -5013,14 +5080,12 @@ function sameVnode (a, b) {
)
}
// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') { return true }
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
}
function createKeyToOldIdx (children, beginIdx, endIdx) {
@ -5352,10 +5417,11 @@ function createPatchFunction (backend) {
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
idxInOld = isDef(newStartVnode.key)
? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
/* istanbul ignore if */
@ -5369,13 +5435,12 @@ function createPatchFunction (backend) {
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
// same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
@ -5386,6 +5451,13 @@ function createPatchFunction (backend) {
}
}
function findIdxInOld (node, oldCh, start, end) {
for (var i = start; i < end; i++) {
var c = oldCh[i];
if (isDef(c) && sameVnode(node, c)) { return i }
}
}
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
if (oldVnode === vnode) {
return
@ -5493,27 +5565,46 @@ function createPatchFunction (backend) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
// v-html and domProps: innerHTML
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' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('server innerHTML: ', i);
console.warn('client innerHTML: ', elm.innerHTML);
}
return false
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
if ("development" !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
} else {
// iterate and compare children lists
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
childrenMatch = false;
break
}
childNode = childNode.nextSibling;
}
// if childNode is not null, it means the actual childNodes list is
// longer than the virtual children list.
if (!childrenMatch || childNode) {
/* istanbul ignore if */
if ("development" !== 'production' &&
typeof console !== 'undefined' &&
!bailed
) {
bailed = true;
console.warn('Parent: ', elm);
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
}
return false
}
return false
}
}
}
@ -5604,14 +5695,28 @@ function createPatchFunction (backend) {
// component root element replaced.
// update parent placeholder node element, recursively
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
ancestor.elm = vnode.elm;
ancestor = ancestor.parent;
}
if (isPatchable(vnode)) {
for (var i = 0; i < cbs.create.length; ++i) {
cbs.create[i](emptyNode, vnode.parent);
for (var i = 0; i < cbs.destroy.length; ++i) {
cbs.destroy[i](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
// #6513
// invoke insert hooks that may have been merged by create hooks.
// e.g. for directives that uses the "inserted" hook.
var insert = ancestor.data.hook.insert;
if (insert.merged) {
// start at index 1 to avoid re-invoking component mounted hook
for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
insert.fns[i$2]();
}
}
}
ancestor = ancestor.parent;
}
}
@ -5795,7 +5900,12 @@ function setAttr (el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
el.setAttribute(key, key);
// technically allowfullscreen is a boolean attribute for <iframe>,
// but Flash expects a value of "true" when used on <embed> tag
value = key === 'allowfullscreen' && el.tagName === 'EMBED'
? 'true'
: key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
@ -6209,7 +6319,7 @@ function updateStyle (oldVnode, vnode) {
var style = normalizeStyleBinding(vnode.data.style) || {};
// store normalized style under a different key for next diff
// make sure to clone it if it's reactive, since the user likley wants
// make sure to clone it if it's reactive, since the user likely wants
// to mutate it.
vnode.data.normalizedStyle = isDef(style.__ob__)
? extend({}, style)
@ -6814,8 +6924,6 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
* properties to Elements.
*/
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* istanbul ignore if */
if (isIE9) {
// http://www.matts411.com/post/internet-explorer-9-oninput/
@ -6830,14 +6938,7 @@ if (isIE9) {
var model$1 = {
inserted: function inserted (el, binding, vnode) {
if (vnode.tag === 'select') {
var cb = function () {
setSelected(el, binding, vnode.context);
};
cb();
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(cb, 0);
}
setSelected(el, binding, vnode.context);
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
@ -6868,13 +6969,30 @@ var model$1 = {
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
trigger(el, 'change');
// trigger change event if
// no matching option found for at least one value
var needReset = el.multiple
? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, 'change');
}
}
}
}
};
function setSelected (el, binding, vm) {
actuallySetSelected(el, binding, vm);
/* istanbul ignore if */
if (isIE || isEdge) {
setTimeout(function () {
actuallySetSelected(el, binding, vm);
}, 0);
}
}
function actuallySetSelected (el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
@ -6907,6 +7025,10 @@ function setSelected (el, binding, vm) {
}
}
function hasNoMatchingOption (value, options) {
return options.every(function (o) { return !looseEqual(o, value); })
}
function getValue (option) {
return '_value' in option
? option._value
@ -7069,10 +7191,6 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var Transition = {
name: 'transition',
props: transitionProps,

File diff suppressed because one or more lines are too long

View File

@ -152,12 +152,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -284,8 +281,6 @@ function escape (s) {
return s.replace(/[<>"&]/g, escapeChar)
}
var cachedEscape = cached(escape);
function escapeChar (a) {
return ESC[a] || a
}
@ -297,7 +292,7 @@ function escapeChar (a) {
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -367,7 +362,7 @@ function renderAttr (key, value) {
} else if (isEnumeratedAttr(key)) {
return (" " + key + "=\"" + (isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true') + "\"")
} else if (!isFalsyAttrValue(value)) {
return (" " + key + "=\"" + (typeof value === 'string' ? cachedEscape(value) : value) + "\"")
return (" " + key + "=\"" + (escape(String(value))) + "\"")
}
return ''
}
@ -758,7 +753,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -840,13 +835,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -1146,9 +1141,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1304,7 +1299,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1707,7 +1702,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1871,6 +1871,10 @@ function getTagNamespace (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -1882,7 +1886,7 @@ function getTagNamespace (tag) {
function renderClass (node) {
var classList = genClassForVnode(node);
if (classList !== '') {
return (" class=\"" + (cachedEscape(classList)) + "\"")
return (" class=\"" + (escape(classList)) + "\"")
}
}
@ -1974,7 +1978,7 @@ function genStyle (style) {
function renderStyle (vnode) {
var styleText = genStyle(getStyle(vnode, false));
if (styleText !== '') {
return (" style=" + (JSON.stringify(cachedEscape(styleText))))
return (" style=" + (JSON.stringify(escape(styleText))))
}
}
@ -2718,7 +2722,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat($$v))}" +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true
@ -3195,29 +3199,14 @@ var he = createCommonjsModule(function (module, exports) {
*/
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>/=]+)/;
var singleAttrAssign = /(?:=)/;
var singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
// attr value, single quotes
/'([^']*)'+/.source,
// attr value, no quotes
/([^\s"'=<>`]+)/.source
];
var attribute = new RegExp(
'^\\s*' + singleAttrIdentifier.source +
'(?:\\s*(' + singleAttrAssign.source + ')' +
'\\s*(?:' + singleAttrValues.join('|') + '))?'
);
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
// but for Vue templates we can enforce a simple charset
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
var startTagOpen = new RegExp('^<' + qnameCapture);
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/;
var conditionalComment = /^<!\[/;
@ -3917,6 +3906,8 @@ function processSlot (el) {
var slotTarget = getBindingAttr(el, 'slot');
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
// preserve slot as an attribute for native shadow DOM compat
addAttr(el, 'slot', slotTarget);
}
if (el.tag === 'template') {
el.slotScope = getAndRemoveAttr(el, 'scope');
@ -4326,7 +4317,7 @@ function genOnce (el, state) {
);
return genElement(el, state)
}
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
} else {
return genStatic(el, state)
}
@ -5075,10 +5066,10 @@ function elementToOpenTagSegments (el, state) {
function childrenToSegments (el, state) {
var binding;
if ((binding = el.attrsMap['v-html'])) {
return [{ type: EXPRESSION, value: binding }]
return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
}
if ((binding = el.attrsMap['v-text'])) {
return [{ type: INTERPOLATION, value: binding }]
return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
}
return el.children
? nodesToSegments(el.children, state)
@ -5097,7 +5088,7 @@ function nodesToSegments (
} else if (c.type === 2) {
segments.push({ type: INTERPOLATION, value: c.expression });
} else if (c.type === 3) {
segments.push({ type: RAW, value: c.text });
segments.push({ type: RAW, value: escape(c.text) });
}
}
return segments
@ -5571,7 +5562,7 @@ function renderSSRClass (
dynamic
) {
var res = renderClass$1(staticClass, dynamic);
return res === '' ? res : (" class=\"" + (cachedEscape(res)) + "\"")
return res === '' ? res : (" class=\"" + (escape(res)) + "\"")
}
function renderSSRStyle (
@ -5584,7 +5575,7 @@ function renderSSRStyle (
if (dynamic) { extend(style, normalizeStyleBinding(dynamic)); }
if (extra) { extend(style, extra); }
var res = genStyle(style);
return res === '' ? res : (" style=" + (JSON.stringify(cachedEscape(res))))
return res === '' ? res : (" style=" + (JSON.stringify(escape(res))))
}
/* not type checking this file because flow doesn't play well with Proxy */
@ -5693,8 +5684,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -5720,6 +5713,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -5728,10 +5726,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
"development" !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -5741,12 +5742,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -5955,6 +5964,8 @@ function resolveAsyncComponent (
/* */
/* */
var target;
@ -5996,10 +6007,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -6062,11 +6078,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -6642,7 +6658,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -6746,7 +6762,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -6842,7 +6861,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -6857,7 +6876,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});

View File

@ -154,12 +154,9 @@ var capitalize = cached(function (str) {
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
@ -286,8 +283,6 @@ function escape (s) {
return s.replace(/[<>"&]/g, escapeChar)
}
var cachedEscape = cached(escape);
function escapeChar (a) {
return ESC[a] || a
}
@ -299,7 +294,7 @@ function escapeChar (a) {
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -369,7 +364,7 @@ function renderAttr (key, value) {
} else if (isEnumeratedAttr(key)) {
return (" " + key + "=\"" + (isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true') + "\"")
} else if (!isFalsyAttrValue(value)) {
return (" " + key + "=\"" + (typeof value === 'string' ? cachedEscape(value) : value) + "\"")
return (" " + key + "=\"" + (escape(String(value))) + "\"")
}
return ''
}
@ -760,7 +755,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -842,13 +837,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -1148,9 +1143,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1306,7 +1301,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1709,7 +1704,12 @@ function assertType (value, type) {
var valid;
var expectedType = getType(type);
if (simpleCheckRE.test(expectedType)) {
valid = typeof value === expectedType.toLowerCase();
var t = typeof value;
valid = t === expectedType.toLowerCase();
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof type;
}
} else if (expectedType === 'Object') {
valid = isPlainObject(value);
} else if (expectedType === 'Array') {
@ -1873,6 +1873,10 @@ function getTagNamespace (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -1884,7 +1888,7 @@ function getTagNamespace (tag) {
function renderClass (node) {
var classList = genClassForVnode(node);
if (classList !== '') {
return (" class=\"" + (cachedEscape(classList)) + "\"")
return (" class=\"" + (escape(classList)) + "\"")
}
}
@ -1976,7 +1980,7 @@ function genStyle (style) {
function renderStyle (vnode) {
var styleText = genStyle(getStyle(vnode, false));
if (styleText !== '') {
return (" style=" + (JSON.stringify(cachedEscape(styleText))))
return (" style=" + (JSON.stringify(escape(styleText))))
}
}
@ -2812,7 +2816,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat($$v))}" +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true
@ -2934,29 +2938,14 @@ var baseOptions = {
*/
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>/=]+)/;
var singleAttrAssign = /(?:=)/;
var singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
// attr value, single quotes
/'([^']*)'+/.source,
// attr value, no quotes
/([^\s"'=<>`]+)/.source
];
var attribute = new RegExp(
'^\\s*' + singleAttrIdentifier.source +
'(?:\\s*(' + singleAttrAssign.source + ')' +
'\\s*(?:' + singleAttrValues.join('|') + '))?'
);
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
// but for Vue templates we can enforce a simple charset
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
var startTagOpen = new RegExp('^<' + qnameCapture);
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/;
var conditionalComment = /^<!\[/;
@ -3656,6 +3645,8 @@ function processSlot (el) {
var slotTarget = getBindingAttr(el, 'slot');
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
// preserve slot as an attribute for native shadow DOM compat
addAttr(el, 'slot', slotTarget);
}
if (el.tag === 'template') {
el.slotScope = getAndRemoveAttr(el, 'scope');
@ -4065,7 +4056,7 @@ function genOnce (el, state) {
);
return genElement(el, state)
}
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
} else {
return genStatic(el, state)
}
@ -4814,10 +4805,10 @@ function elementToOpenTagSegments (el, state) {
function childrenToSegments (el, state) {
var binding;
if ((binding = el.attrsMap['v-html'])) {
return [{ type: EXPRESSION, value: binding }]
return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
}
if ((binding = el.attrsMap['v-text'])) {
return [{ type: INTERPOLATION, value: binding }]
return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
}
return el.children
? nodesToSegments(el.children, state)
@ -4836,7 +4827,7 @@ function nodesToSegments (
} else if (c.type === 2) {
segments.push({ type: INTERPOLATION, value: c.expression });
} else if (c.type === 3) {
segments.push({ type: RAW, value: c.text });
segments.push({ type: RAW, value: escape(c.text) });
}
}
return segments
@ -5310,7 +5301,7 @@ function renderSSRClass (
dynamic
) {
var res = renderClass$1(staticClass, dynamic);
return res === '' ? res : (" class=\"" + (cachedEscape(res)) + "\"")
return res === '' ? res : (" class=\"" + (escape(res)) + "\"")
}
function renderSSRStyle (
@ -5323,7 +5314,7 @@ function renderSSRStyle (
if (dynamic) { extend(style, normalizeStyleBinding(dynamic)); }
if (extra) { extend(style, extra); }
var res = genStyle(style);
return res === '' ? res : (" style=" + (JSON.stringify(cachedEscape(res))))
return res === '' ? res : (" style=" + (JSON.stringify(escape(res))))
}
/* not type checking this file because flow doesn't play well with Proxy */
@ -5432,8 +5423,10 @@ var normalizeEvent = cached(function (name) {
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
var plain = !(passive || once$$1 || capture);
return {
name: name,
plain: plain,
once: once$$1,
capture: capture,
passive: passive
@ -5459,6 +5452,11 @@ function createFnInvoker (fns) {
return invoker
}
// #6552
function prioritizePlainEvents (a, b) {
return a.plain ? -1 : b.plain ? 1 : 0
}
function updateListeners (
on,
oldOn,
@ -5467,10 +5465,13 @@ function updateListeners (
vm
) {
var name, cur, old, event;
var toAdd = [];
var hasModifier = false;
for (name in on) {
cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (!event.plain) { hasModifier = true; }
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@ -5480,12 +5481,20 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
add(event.name, cur, event.once, event.capture, event.passive);
event.handler = cur;
toAdd.push(event);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
}
}
if (toAdd.length) {
if (hasModifier) { toAdd.sort(prioritizePlainEvents); }
for (var i = 0; i < toAdd.length; i++) {
var event$1 = toAdd[i];
add(event$1.name, event$1.handler, event$1.once, event$1.capture, event$1.passive);
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
@ -5696,6 +5705,8 @@ function resolveAsyncComponent (
/* */
/* */
var target;
@ -5737,10 +5748,15 @@ function resolveSlots (
var defaultSlot = [];
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
var data = child.data;
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if ((child.context === context || child.functionalContext === context) &&
child.data && child.data.slot != null
data && data.slot != null
) {
var name = child.data.slot;
var slot = (slots[name] || (slots[name] = []));
@ -5803,11 +5819,11 @@ function updateChildComponent (
}
vm.$options._renderChildren = renderChildren;
// update $attrs and $listensers hash
// 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 && parentVnode.data.attrs;
vm.$listeners = listeners;
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject;
vm.$listeners = listeners || emptyObject;
// update props
if (propsData && vm.$options.props) {
@ -6385,7 +6401,7 @@ function _createElement (
var vnode, ns;
if (typeof tag === 'string') {
var Ctor;
ns = config.getTagNamespace(tag);
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
if (config.isReservedTag(tag)) {
// platform built-in elements
vnode = new VNode(
@ -6489,7 +6505,10 @@ function resolveInject (inject, vm) {
// inject is :any because flow is not smart enough to figure out cached
var result = Object.create(null);
var keys = hasSymbol
? Reflect.ownKeys(inject)
? 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++) {
@ -6585,7 +6604,7 @@ function createFunctionalComponent (
var propOptions = Ctor.options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props[key] = validateProp(key, propOptions, propsData || {});
props[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
@ -6600,7 +6619,7 @@ function createFunctionalComponent (
props: props,
children: children,
parent: context,
listeners: data.on || {},
listeners: data.on || emptyObject,
injections: resolveInject(Ctor.options.inject, context),
slots: function () { return resolveSlots(children, context); }
});
@ -7415,7 +7434,7 @@ var TemplateRenderer = function TemplateRenderer (options) {
if (options.clientManifest) {
var clientManifest = this.clientManifest = options.clientManifest;
this.publicPath = clientManifest.publicPath.replace(/\/$/, '');
// preload/prefetch drectives
// preload/prefetch directives
this.preloadFiles = clientManifest.initial;
this.prefetchFiles = clientManifest.async;
// initial async chunk mapping
@ -7599,7 +7618,7 @@ function getPreloadType (ext) {
} else if (/woff2?|ttf|otf|eot/.test(ext)) {
return 'font'
} else {
// not exhausting all possbilities here, but above covers common cases
// not exhausting all possibilities here, but above covers common cases
return ''
}
}
@ -7818,7 +7837,23 @@ function createBundleRunner (entry, files, basedir, runInNewContext) {
if (initialContext._styles) {
userContext._styles = deepClone(initialContext._styles);
}
resolve(runner(userContext));
// #6353 after the app is resolved, if the userContext doesn't have a
// styles property, it means the app doesn't have any lifecycle-injected
// styles, so vue-style-loader never defined the styles getter.
// just expose the same styles from the initialContext.
var exposeStylesAndResolve = function (app) {
if (!userContext.hasOwnProperty('styles')) {
userContext.styles = initialContext.styles;
}
resolve(app);
};
var res = runner(userContext);
if (typeof res.then === 'function') {
res.then(exposeStylesAndResolve);
} else {
exposeStylesAndResolve(res);
}
});
}
}

View File

@ -1,6 +1,6 @@
{
"name": "vue-server-renderer",
"version": "2.4.2",
"version": "2.4.3",
"description": "server renderer for Vue 2.0",
"main": "index.js",
"types": "types/index.d.ts",

View File

@ -236,29 +236,14 @@ var isNonPhrasingTag = makeMap(
*/
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>/=]+)/;
var singleAttrAssign = /(?:=)/;
var singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
// attr value, single quotes
/'([^']*)'+/.source,
// attr value, no quotes
/([^\s"'=<>`]+)/.source
];
var attribute = new RegExp(
'^\\s*' + singleAttrIdentifier.source +
'(?:\\s*(' + singleAttrAssign.source + ')' +
'\\s*(?:' + singleAttrValues.join('|') + '))?'
);
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
// but for Vue templates we can enforce a simple charset
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
var startTagOpen = new RegExp('^<' + qnameCapture);
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/;
var conditionalComment = /^<!\[/;
@ -917,7 +902,7 @@ var isAndroid = UA && UA.indexOf('android') > 0;
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
// Firefix has a "watch" function on Object.prototype...
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
var supportsPassive = false;
@ -999,13 +984,13 @@ var nextTick = (function () {
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else if (typeof MutationObserver !== 'undefined' && (
} 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 IE11, iOS7, Android 4.4
// e.g. PhantomJS, iOS7, Android 4.4
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(String(counter));
@ -1295,9 +1280,9 @@ function defineReactive$$1 (
dep.depend();
if (childOb) {
childOb.dep.depend();
}
if (Array.isArray(value)) {
dependArray(value);
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value
@ -1453,7 +1438,7 @@ function mergeDataOrFn (
: childVal;
var defaultData = typeof parentVal === 'function'
? parentVal.call(vm)
: undefined;
: parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
@ -1598,7 +1583,7 @@ var defaultStrat = function (parentVal, childVal) {
var isReservedAttr = makeMap('style,class');
// attributes that should be using props for binding
var acceptValue = makeMap('input,textarea,option,select');
var acceptValue = makeMap('input,textarea,option,select,progress');
var mustUseProp = function (tag, type, attr) {
return (
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
@ -1665,6 +1650,10 @@ function getTagNamespace (tag) {
}
}
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
/* */
/**
@ -2269,7 +2258,7 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat($$v))}" +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true
@ -2792,6 +2781,8 @@ function processSlot (el) {
var slotTarget = getBindingAttr(el, 'slot');
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
// preserve slot as an attribute for native shadow DOM compat
addAttr(el, 'slot', slotTarget);
}
if (el.tag === 'template') {
el.slotScope = getAndRemoveAttr(el, 'scope');
@ -3328,7 +3319,7 @@ function genOnce (el, state) {
);
return genElement(el, state)
}
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
} else {
return genStatic(el, state)
}
@ -3980,6 +3971,21 @@ var propsToAttrMap = {
httpEquiv: 'http-equiv'
};
var ESC = {
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'&': '&amp;'
};
function escape (s) {
return s.replace(/[<>"&]/g, escapeChar)
}
function escapeChar (a) {
return ESC[a] || a
}
/* */
var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
@ -4379,10 +4385,10 @@ function elementToOpenTagSegments (el, state) {
function childrenToSegments (el, state) {
var binding;
if ((binding = el.attrsMap['v-html'])) {
return [{ type: EXPRESSION, value: binding }]
return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
}
if ((binding = el.attrsMap['v-text'])) {
return [{ type: INTERPOLATION, value: binding }]
return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
}
return el.children
? nodesToSegments(el.children, state)
@ -4401,7 +4407,7 @@ function nodesToSegments (
} else if (c.type === 2) {
segments.push({ type: INTERPOLATION, value: c.expression });
} else if (c.type === 3) {
segments.push({ type: RAW, value: c.text });
segments.push({ type: RAW, value: escape(c.text) });
}
}
return segments

View File

@ -1,6 +1,6 @@
{
"name": "vue-template-compiler",
"version": "2.4.2",
"version": "2.4.3",
"description": "template compiler for Vue 2.0",
"main": "index.js",
"repository": {