mirror of https://github.com/vuejs/vue.git
[build] 2.1.7
This commit is contained in:
parent
01f533db1a
commit
c83458fb94
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -342,13 +342,15 @@ function genStaticKeys (modules) {
|
|||
* if they are plain objects, do they have the same shape?
|
||||
*/
|
||||
function looseEqual (a, b) {
|
||||
/* eslint-disable eqeqeq */
|
||||
return a == b || (
|
||||
isObject(a) && isObject(b)
|
||||
? JSON.stringify(a) === JSON.stringify(b)
|
||||
: false
|
||||
)
|
||||
/* eslint-enable eqeqeq */
|
||||
var isObjectA = isObject(a);
|
||||
var isObjectB = isObject(b);
|
||||
if (isObjectA && isObjectB) {
|
||||
return JSON.stringify(a) === JSON.stringify(b)
|
||||
} else if (!isObjectA && !isObjectB) {
|
||||
return String(a) === String(b)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function looseIndexOf (arr, val) {
|
||||
|
@ -384,7 +386,7 @@ var config = {
|
|||
/**
|
||||
* Ignore certain custom elements
|
||||
*/
|
||||
ignoredElements: null,
|
||||
ignoredElements: [],
|
||||
|
||||
/**
|
||||
* Custom user key aliases for v-on
|
||||
|
@ -1368,7 +1370,7 @@ function parse (
|
|||
process.env.NODE_ENV !== 'production' && warn$1(
|
||||
'Templates should only be responsible for mapping the state to the ' +
|
||||
'UI. Avoid placing tags with side-effects in your templates, such as ' +
|
||||
"<" + tag + ">."
|
||||
"<" + tag + ">" + ', as they will not be parsed.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1505,19 +1507,20 @@ function parse (
|
|||
currentParent.attrsMap.placeholder === text) {
|
||||
return
|
||||
}
|
||||
var children = currentParent.children;
|
||||
text = inPre || text.trim()
|
||||
? decodeHTMLCached(text)
|
||||
// only preserve whitespace if its not right after a starting tag
|
||||
: preserveWhitespace && currentParent.children.length ? ' ' : '';
|
||||
: preserveWhitespace && children.length ? ' ' : '';
|
||||
if (text) {
|
||||
var expression;
|
||||
if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
|
||||
currentParent.children.push({
|
||||
children.push({
|
||||
type: 2,
|
||||
expression: expression,
|
||||
text: text
|
||||
});
|
||||
} else {
|
||||
} else if (text !== ' ' || children[children.length - 1].text !== ' ') {
|
||||
currentParent.children.push({
|
||||
type: 3,
|
||||
text: text
|
||||
|
@ -1628,6 +1631,23 @@ function processIfConditions (el, parent) {
|
|||
}
|
||||
}
|
||||
|
||||
function findPrevElement (children) {
|
||||
var i = children.length;
|
||||
while (i--) {
|
||||
if (children[i].type === 1) {
|
||||
return children[i]
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
|
||||
warn$1(
|
||||
"text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
|
||||
"will be ignored."
|
||||
);
|
||||
}
|
||||
children.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addIfCondition (el, condition) {
|
||||
if (!el.ifConditions) {
|
||||
el.ifConditions = [];
|
||||
|
@ -1735,6 +1755,15 @@ function processAttrs (el) {
|
|||
}
|
||||
}
|
||||
addAttr(el, name, JSON.stringify(value));
|
||||
// #4530 also bind special attributes as props even if they are static
|
||||
// so that patches between dynamic/static are consistent
|
||||
if (platformMustUseProp(el.tag, name)) {
|
||||
if (name === 'value') {
|
||||
addProp(el, name, JSON.stringify(value));
|
||||
} else {
|
||||
addProp(el, name, 'true');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1770,13 +1799,6 @@ function makeAttrsMap (attrs) {
|
|||
return map
|
||||
}
|
||||
|
||||
function findPrevElement (children) {
|
||||
var i = children.length;
|
||||
while (i--) {
|
||||
if (children[i].tag) { return children[i] }
|
||||
}
|
||||
}
|
||||
|
||||
function isForbiddenTag (el) {
|
||||
return (
|
||||
el.tag === 'style' ||
|
||||
|
@ -2042,6 +2064,7 @@ var warn$2;
|
|||
var transforms$1;
|
||||
var dataGenFns;
|
||||
var platformDirectives;
|
||||
var isPlatformReservedTag$1;
|
||||
var staticRenderFns;
|
||||
var onceCount;
|
||||
var currentOptions;
|
||||
|
@ -2060,6 +2083,7 @@ function generate (
|
|||
transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
|
||||
dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
||||
platformDirectives = options.directives || {};
|
||||
isPlatformReservedTag$1 = options.isReservedTag || no;
|
||||
var code = ast ? genElement(ast) : '_c("div")';
|
||||
staticRenderFns = prevStaticRenderFns;
|
||||
onceCount = prevOnceCount;
|
||||
|
@ -2299,27 +2323,40 @@ function genChildren (el, checkSkip) {
|
|||
el$1.tag !== 'slot') {
|
||||
return genElement(el$1)
|
||||
}
|
||||
var normalizationType = getNormalizationType(children);
|
||||
return ("[" + (children.map(genNode).join(',')) + "]" + (checkSkip
|
||||
? canSkipNormalization(children) ? '' : ',true'
|
||||
? normalizationType ? ("," + normalizationType) : ''
|
||||
: ''))
|
||||
}
|
||||
}
|
||||
|
||||
function canSkipNormalization (children) {
|
||||
// determine the normalzation needed for the children array.
|
||||
// 0: no normalization needed
|
||||
// 1: simple normalization needed (possible 1-level deep nested array)
|
||||
// 2: full nomralization needed
|
||||
function getNormalizationType (children) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var el = children[i];
|
||||
if (needsNormalization(el) ||
|
||||
(el.if && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
|
||||
return false
|
||||
return 2
|
||||
}
|
||||
if (maybeComponent(el) ||
|
||||
(el.if && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
return true
|
||||
return 0
|
||||
}
|
||||
|
||||
function needsNormalization (el) {
|
||||
return el.for || el.tag === 'template' || el.tag === 'slot'
|
||||
}
|
||||
|
||||
function maybeComponent (el) {
|
||||
return el.type === 1 && !isPlatformReservedTag$1(el.tag)
|
||||
}
|
||||
|
||||
function genNode (node) {
|
||||
if (node.type === 1) {
|
||||
return genElement(node)
|
||||
|
@ -2337,7 +2374,19 @@ function genText (text) {
|
|||
function genSlot (el) {
|
||||
var slotName = el.slotName || '"default"';
|
||||
var children = genChildren(el);
|
||||
return ("_t(" + slotName + (children ? ("," + children) : '') + (el.attrs ? ((children ? '' : ',null') + ",{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}") : '') + ")")
|
||||
var res = "_t(" + slotName + (children ? ("," + children) : '');
|
||||
var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
|
||||
var bind$$1 = el.attrsMap['v-bind'];
|
||||
if ((attrs || bind$$1) && !children) {
|
||||
res += ",null";
|
||||
}
|
||||
if (attrs) {
|
||||
res += "," + attrs;
|
||||
}
|
||||
if (bind$$1) {
|
||||
res += (attrs ? '' : ',null') + "," + bind$$1;
|
||||
}
|
||||
return res + ')'
|
||||
}
|
||||
|
||||
// componentName is el.component, take it as argument to shun flow's pessimistic refinement
|
||||
|
@ -3114,16 +3163,17 @@ var Watcher = function Watcher (
|
|||
cb,
|
||||
options
|
||||
) {
|
||||
if ( options === void 0 ) options = {};
|
||||
|
||||
this.vm = vm$$1;
|
||||
vm$$1._watchers.push(this);
|
||||
// options
|
||||
if (options) {
|
||||
this.deep = !!options.deep;
|
||||
this.user = !!options.user;
|
||||
this.lazy = !!options.lazy;
|
||||
this.sync = !!options.sync;
|
||||
this.expression = expOrFn.toString();
|
||||
} else {
|
||||
this.deep = this.user = this.lazy = this.sync = false;
|
||||
}
|
||||
this.cb = cb;
|
||||
this.id = ++uid$1; // uid for batching
|
||||
this.active = true;
|
||||
|
@ -3132,6 +3182,9 @@ var Watcher = function Watcher (
|
|||
this.newDeps = [];
|
||||
this.depIds = new _Set();
|
||||
this.newDepIds = new _Set();
|
||||
this.expression = process.env.NODE_ENV !== 'production'
|
||||
? expOrFn.toString()
|
||||
: '';
|
||||
// parse expression for getter
|
||||
if (typeof expOrFn === 'function') {
|
||||
this.getter = expOrFn;
|
||||
|
@ -3473,7 +3526,7 @@ function copyAugment (target, src, keys) {
|
|||
* returns the new observer if successfully observed,
|
||||
* or the existing observer if the value already has one.
|
||||
*/
|
||||
function observe (value) {
|
||||
function observe (value, asRootData) {
|
||||
if (!isObject(value)) {
|
||||
return
|
||||
}
|
||||
|
@ -3489,6 +3542,9 @@ function observe (value) {
|
|||
) {
|
||||
ob = new Observer(value);
|
||||
}
|
||||
if (asRootData && ob) {
|
||||
ob.vmCount++;
|
||||
}
|
||||
return ob
|
||||
}
|
||||
|
||||
|
@ -3622,18 +3678,21 @@ function dependArray (value) {
|
|||
|
||||
function initState (vm$$1) {
|
||||
vm$$1._watchers = [];
|
||||
initProps(vm$$1);
|
||||
initMethods(vm$$1);
|
||||
var opts = vm$$1.$options;
|
||||
if (opts.props) { initProps(vm$$1, opts.props); }
|
||||
if (opts.methods) { initMethods(vm$$1, opts.methods); }
|
||||
if (opts.data) {
|
||||
initData(vm$$1);
|
||||
initComputed(vm$$1);
|
||||
initWatch(vm$$1);
|
||||
} else {
|
||||
observe(vm$$1._data = {}, true /* asRootData */);
|
||||
}
|
||||
if (opts.computed) { initComputed(vm$$1, opts.computed); }
|
||||
if (opts.watch) { initWatch(vm$$1, opts.watch); }
|
||||
}
|
||||
|
||||
var isReservedProp = { key: 1, ref: 1, slot: 1 };
|
||||
|
||||
function initProps (vm$$1) {
|
||||
var props = vm$$1.$options.props;
|
||||
if (props) {
|
||||
function initProps (vm$$1, props) {
|
||||
var propsData = vm$$1.$options.propsData || {};
|
||||
var keys = vm$$1.$options._propKeys = Object.keys(props);
|
||||
var isRoot = !vm$$1.$parent;
|
||||
|
@ -3667,7 +3726,6 @@ function initProps (vm$$1) {
|
|||
|
||||
for (var i = 0; i < keys.length; i++) loop( i );
|
||||
observerState.shouldConvert = true;
|
||||
}
|
||||
}
|
||||
|
||||
function initData (vm$$1) {
|
||||
|
@ -3699,8 +3757,7 @@ function initData (vm$$1) {
|
|||
}
|
||||
}
|
||||
// observe data
|
||||
observe(data);
|
||||
data.__ob__ && data.__ob__.vmCount++;
|
||||
observe(data, true /* asRootData */);
|
||||
}
|
||||
|
||||
var computedSharedDefinition = {
|
||||
|
@ -3710,9 +3767,7 @@ var computedSharedDefinition = {
|
|||
set: noop
|
||||
};
|
||||
|
||||
function initComputed (vm$$1) {
|
||||
var computed = vm$$1.$options.computed;
|
||||
if (computed) {
|
||||
function initComputed (vm$$1, computed) {
|
||||
for (var key in computed) {
|
||||
var userDef = computed[key];
|
||||
if (typeof userDef === 'function') {
|
||||
|
@ -3730,7 +3785,6 @@ function initComputed (vm$$1) {
|
|||
}
|
||||
Object.defineProperty(vm$$1, key, computedSharedDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeComputedGetter (getter, owner) {
|
||||
|
@ -3748,9 +3802,7 @@ function makeComputedGetter (getter, owner) {
|
|||
}
|
||||
}
|
||||
|
||||
function initMethods (vm$$1) {
|
||||
var methods = vm$$1.$options.methods;
|
||||
if (methods) {
|
||||
function initMethods (vm$$1, methods) {
|
||||
for (var key in methods) {
|
||||
vm$$1[key] = methods[key] == null ? noop : bind(methods[key], vm$$1);
|
||||
if (process.env.NODE_ENV !== 'production' && methods[key] == null) {
|
||||
|
@ -3761,12 +3813,9 @@ function initMethods (vm$$1) {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initWatch (vm$$1) {
|
||||
var watch = vm$$1.$options.watch;
|
||||
if (watch) {
|
||||
function initWatch (vm$$1, watch) {
|
||||
for (var key in watch) {
|
||||
var handler = watch[key];
|
||||
if (Array.isArray(handler)) {
|
||||
|
@ -3777,7 +3826,6 @@ function initWatch (vm$$1) {
|
|||
createWatcher(vm$$1, key, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createWatcher (vm$$1, key, handler) {
|
||||
|
@ -3920,6 +3968,252 @@ function cloneVNodes (vnodes) {
|
|||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
|
||||
function updateListeners (
|
||||
on,
|
||||
oldOn,
|
||||
add,
|
||||
remove$$1,
|
||||
vm$$1
|
||||
) {
|
||||
var name, cur, old, fn, event, capture, once;
|
||||
for (name in on) {
|
||||
cur = on[name];
|
||||
old = oldOn[name];
|
||||
if (!cur) {
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
"Invalid handler for event \"" + name + "\": got " + String(cur),
|
||||
vm$$1
|
||||
);
|
||||
} else if (!old) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
if (Array.isArray(cur)) {
|
||||
add(event, (cur.invoker = arrInvoker(cur)), once, capture);
|
||||
} else {
|
||||
if (!cur.invoker) {
|
||||
fn = cur;
|
||||
cur = on[name] = {};
|
||||
cur.fn = fn;
|
||||
cur.invoker = fnInvoker(cur);
|
||||
}
|
||||
add(event, cur.invoker, once, capture);
|
||||
}
|
||||
} else if (cur !== old) {
|
||||
if (Array.isArray(old)) {
|
||||
old.length = cur.length;
|
||||
for (var i = 0; i < old.length; i++) { old[i] = cur[i]; }
|
||||
on[name] = old;
|
||||
} else {
|
||||
old.fn = cur;
|
||||
on[name] = old;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (name in oldOn) {
|
||||
if (!on[name]) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
remove$$1(event, oldOn[name].invoker, capture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function arrInvoker (arr) {
|
||||
return function (ev) {
|
||||
var arguments$1 = arguments;
|
||||
|
||||
var single = arguments.length === 1;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
single ? arr[i](ev) : arr[i].apply(null, arguments$1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fnInvoker (o) {
|
||||
return function (ev) {
|
||||
var single = arguments.length === 1;
|
||||
single ? o.fn(ev) : o.fn.apply(null, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
// The template compiler attempts to minimize the need for normalization by
|
||||
// statically analyzing the template at compile time.
|
||||
//
|
||||
// For plain HTML markup, normalization can be completely skipped because the
|
||||
// generated render function is guaranteed to return Array<VNode>. There are
|
||||
// two cases where extra normalization is needed:
|
||||
|
||||
// 1. When the children contains components - because a functional component
|
||||
// may return an Array instead of a single root. In this case, just a simple
|
||||
// nomralization is needed - if any child is an Array, we flatten the whole
|
||||
// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
|
||||
// because functional components already normalize their own children.
|
||||
function simpleNormalizeChildren (children) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
if (Array.isArray(children[i])) {
|
||||
return Array.prototype.concat.apply([], children)
|
||||
}
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
// 2. When the children contains constrcuts that always generated nested Arrays,
|
||||
// e.g. <template>, <slot>, v-for, or when the children is provided by user
|
||||
// with hand-written render functions / JSX. In such cases a full normalization
|
||||
// is needed to cater to all possible types of children values.
|
||||
function normalizeChildren (children) {
|
||||
return isPrimitive(children)
|
||||
? [createTextVNode(children)]
|
||||
: Array.isArray(children)
|
||||
? normalizeArrayChildren(children)
|
||||
: undefined
|
||||
}
|
||||
|
||||
function normalizeArrayChildren (children, nestedIndex) {
|
||||
var res = [];
|
||||
var i, c, last;
|
||||
for (i = 0; i < children.length; i++) {
|
||||
c = children[i];
|
||||
if (c == null || typeof c === 'boolean') { continue }
|
||||
last = res[res.length - 1];
|
||||
// nested
|
||||
if (Array.isArray(c)) {
|
||||
res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
|
||||
} else if (isPrimitive(c)) {
|
||||
if (last && last.text) {
|
||||
last.text += String(c);
|
||||
} else if (c !== '') {
|
||||
// convert primitive to vnode
|
||||
res.push(createTextVNode(c));
|
||||
}
|
||||
} else {
|
||||
if (c.text && last && last.text) {
|
||||
res[res.length - 1] = createTextVNode(last.text + c.text);
|
||||
} else {
|
||||
// default key for nested array children (likely generated by v-for)
|
||||
if (c.tag && c.key == null && nestedIndex != null) {
|
||||
c.key = "__vlist" + nestedIndex + "_" + i + "__";
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
|
||||
function initEvents (vm$$1) {
|
||||
vm$$1._events = Object.create(null);
|
||||
vm$$1._hasHookEvent = false;
|
||||
// init parent attached events
|
||||
var listeners = vm$$1.$options._parentListeners;
|
||||
if (listeners) {
|
||||
updateComponentListeners(vm$$1, listeners);
|
||||
}
|
||||
}
|
||||
|
||||
var target;
|
||||
|
||||
function add$1 (event, fn, once) {
|
||||
if (once) {
|
||||
target.$once(event, fn);
|
||||
} else {
|
||||
target.$on(event, fn);
|
||||
}
|
||||
}
|
||||
|
||||
function remove$1 (event, fn) {
|
||||
target.$off(event, fn);
|
||||
}
|
||||
|
||||
function updateComponentListeners (
|
||||
vm$$1,
|
||||
listeners,
|
||||
oldListeners
|
||||
) {
|
||||
target = vm$$1;
|
||||
updateListeners(listeners, oldListeners || {}, add$1, remove$1, vm$$1);
|
||||
}
|
||||
|
||||
function eventsMixin (Vue) {
|
||||
var hookRE = /^hook:/;
|
||||
Vue.prototype.$on = function (event, fn) {
|
||||
var vm$$1 = this;(vm$$1._events[event] || (vm$$1._events[event] = [])).push(fn);
|
||||
// optimize hook:event cost by using a boolean flag marked at registration
|
||||
// instead of a hash lookup
|
||||
if (hookRE.test(event)) {
|
||||
vm$$1._hasHookEvent = true;
|
||||
}
|
||||
return vm$$1
|
||||
};
|
||||
|
||||
Vue.prototype.$once = function (event, fn) {
|
||||
var vm$$1 = this;
|
||||
function on () {
|
||||
vm$$1.$off(event, on);
|
||||
fn.apply(vm$$1, arguments);
|
||||
}
|
||||
on.fn = fn;
|
||||
vm$$1.$on(event, on);
|
||||
return vm$$1
|
||||
};
|
||||
|
||||
Vue.prototype.$off = function (event, fn) {
|
||||
var vm$$1 = this;
|
||||
// all
|
||||
if (!arguments.length) {
|
||||
vm$$1._events = Object.create(null);
|
||||
return vm$$1
|
||||
}
|
||||
// specific event
|
||||
var cbs = vm$$1._events[event];
|
||||
if (!cbs) {
|
||||
return vm$$1
|
||||
}
|
||||
if (arguments.length === 1) {
|
||||
vm$$1._events[event] = null;
|
||||
return vm$$1
|
||||
}
|
||||
// specific handler
|
||||
var cb;
|
||||
var i = cbs.length;
|
||||
while (i--) {
|
||||
cb = cbs[i];
|
||||
if (cb === fn || cb.fn === fn) {
|
||||
cbs.splice(i, 1);
|
||||
break
|
||||
}
|
||||
}
|
||||
return vm$$1
|
||||
};
|
||||
|
||||
Vue.prototype.$emit = function (event) {
|
||||
var vm$$1 = this;
|
||||
var cbs = vm$$1._events[event];
|
||||
if (cbs) {
|
||||
cbs = cbs.length > 1 ? toArray(cbs) : cbs;
|
||||
var args = toArray(arguments, 1);
|
||||
for (var i = 0, l = cbs.length; i < l; i++) {
|
||||
cbs[i].apply(vm$$1, args);
|
||||
}
|
||||
}
|
||||
return vm$$1
|
||||
};
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
var activeInstance = null;
|
||||
|
||||
function initLifecycle (vm$$1) {
|
||||
|
@ -4062,7 +4356,7 @@ function lifecycleMixin (Vue) {
|
|||
if (listeners) {
|
||||
var oldListeners = vm$$1.$options._parentListeners;
|
||||
vm$$1.$options._parentListeners = listeners;
|
||||
vm$$1._updateListeners(listeners, oldListeners);
|
||||
updateComponentListeners(vm$$1, listeners, oldListeners);
|
||||
}
|
||||
// resolve slots + force update if has children
|
||||
if (hasChildren) {
|
||||
|
@ -4124,7 +4418,9 @@ function callHook (vm$$1, hook) {
|
|||
handlers[i].call(vm$$1);
|
||||
}
|
||||
}
|
||||
if (vm$$1._hasHookEvent) {
|
||||
vm$$1.$emit('hook:' + hook);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
@ -4447,125 +4743,8 @@ function mergeHook$1 (one, two) {
|
|||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
|
||||
function updateListeners (
|
||||
on,
|
||||
oldOn,
|
||||
add,
|
||||
remove$$1,
|
||||
vm$$1
|
||||
) {
|
||||
var name, cur, old, fn, event, capture, once;
|
||||
for (name in on) {
|
||||
cur = on[name];
|
||||
old = oldOn[name];
|
||||
if (!cur) {
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
"Invalid handler for event \"" + name + "\": got " + String(cur),
|
||||
vm$$1
|
||||
);
|
||||
} else if (!old) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
if (Array.isArray(cur)) {
|
||||
add(event, (cur.invoker = arrInvoker(cur)), once, capture);
|
||||
} else {
|
||||
if (!cur.invoker) {
|
||||
fn = cur;
|
||||
cur = on[name] = {};
|
||||
cur.fn = fn;
|
||||
cur.invoker = fnInvoker(cur);
|
||||
}
|
||||
add(event, cur.invoker, once, capture);
|
||||
}
|
||||
} else if (cur !== old) {
|
||||
if (Array.isArray(old)) {
|
||||
old.length = cur.length;
|
||||
for (var i = 0; i < old.length; i++) { old[i] = cur[i]; }
|
||||
on[name] = old;
|
||||
} else {
|
||||
old.fn = cur;
|
||||
on[name] = old;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (name in oldOn) {
|
||||
if (!on[name]) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
remove$$1(event, oldOn[name].invoker, capture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function arrInvoker (arr) {
|
||||
return function (ev) {
|
||||
var arguments$1 = arguments;
|
||||
|
||||
var single = arguments.length === 1;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
single ? arr[i](ev) : arr[i].apply(null, arguments$1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fnInvoker (o) {
|
||||
return function (ev) {
|
||||
var single = arguments.length === 1;
|
||||
single ? o.fn(ev) : o.fn.apply(null, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
function normalizeChildren (children) {
|
||||
return isPrimitive(children)
|
||||
? [createTextVNode(children)]
|
||||
: Array.isArray(children)
|
||||
? normalizeArrayChildren(children)
|
||||
: undefined
|
||||
}
|
||||
|
||||
function normalizeArrayChildren (children, nestedIndex) {
|
||||
var res = [];
|
||||
var i, c, last;
|
||||
for (i = 0; i < children.length; i++) {
|
||||
c = children[i];
|
||||
if (c == null || typeof c === 'boolean') { continue }
|
||||
last = res[res.length - 1];
|
||||
// nested
|
||||
if (Array.isArray(c)) {
|
||||
res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
|
||||
} else if (isPrimitive(c)) {
|
||||
if (last && last.text) {
|
||||
last.text += String(c);
|
||||
} else if (c !== '') {
|
||||
// convert primitive to vnode
|
||||
res.push(createTextVNode(c));
|
||||
}
|
||||
} else {
|
||||
if (c.text && last && last.text) {
|
||||
res[res.length - 1] = createTextVNode(last.text + c.text);
|
||||
} else {
|
||||
// default key for nested array children (likely generated by v-for)
|
||||
if (c.tag && c.key == null && nestedIndex != null) {
|
||||
c.key = "__vlist" + nestedIndex + "_" + i + "__";
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
var SIMPLE_NORMALIZE = 1;
|
||||
var ALWAYS_NORMALIZE = 2;
|
||||
|
||||
// wrapper function for providing a more flexible interface
|
||||
// without getting yelled at by flow
|
||||
|
@ -4574,16 +4753,16 @@ function createElement (
|
|||
tag,
|
||||
data,
|
||||
children,
|
||||
needNormalization,
|
||||
normalizationType,
|
||||
alwaysNormalize
|
||||
) {
|
||||
if (Array.isArray(data) || isPrimitive(data)) {
|
||||
needNormalization = children;
|
||||
normalizationType = children;
|
||||
children = data;
|
||||
data = undefined;
|
||||
}
|
||||
if (alwaysNormalize) { needNormalization = true; }
|
||||
return _createElement(context, tag, data, children, needNormalization)
|
||||
if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
|
||||
return _createElement(context, tag, data, children, normalizationType)
|
||||
}
|
||||
|
||||
function _createElement (
|
||||
|
@ -4591,7 +4770,7 @@ function _createElement (
|
|||
tag,
|
||||
data,
|
||||
children,
|
||||
needNormalization
|
||||
normalizationType
|
||||
) {
|
||||
if (data && data.__ob__) {
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
|
@ -4612,8 +4791,10 @@ function _createElement (
|
|||
data.scopedSlots = { default: children[0] };
|
||||
children.length = 0;
|
||||
}
|
||||
if (needNormalization) {
|
||||
if (normalizationType === ALWAYS_NORMALIZE) {
|
||||
children = normalizeChildren(children);
|
||||
} else if (normalizationType === SIMPLE_NORMALIZE) {
|
||||
children = simpleNormalizeChildren(children);
|
||||
}
|
||||
var vnode, ns;
|
||||
if (typeof tag === 'string') {
|
||||
|
@ -4632,7 +4813,6 @@ function _createElement (
|
|||
// unknown or unlisted namespaced elements
|
||||
// check at runtime because it may get assigned a namespace when its
|
||||
// parent normalizes children
|
||||
ns = tag === 'foreignObject' ? 'xhtml' : ns;
|
||||
vnode = new VNode(
|
||||
tag, data, children,
|
||||
undefined, undefined, context
|
||||
|
@ -4652,6 +4832,10 @@ function _createElement (
|
|||
|
||||
function applyNS (vnode, ns) {
|
||||
vnode.ns = ns;
|
||||
if (vnode.tag === 'foreignObject') {
|
||||
// use default namespace inside foreignObject
|
||||
return
|
||||
}
|
||||
if (vnode.children) {
|
||||
for (var i = 0, l = vnode.children.length; i < l; i++) {
|
||||
var child = vnode.children[i];
|
||||
|
@ -4674,7 +4858,7 @@ function initRender (vm$$1) {
|
|||
vm$$1.$scopedSlots = {};
|
||||
// bind the createElement fn to this instance
|
||||
// so that we get proper render context inside it.
|
||||
// args order: tag, data, children, needNormalization, alwaysNormalize
|
||||
// args order: tag, data, children, normalizationType, alwaysNormalize
|
||||
// internal version is used by render functions compiled from templates
|
||||
vm$$1._c = function (a, b, c, d) { return createElement(vm$$1, a, b, c, d, false); };
|
||||
// normalization is always applied for the public version, used in
|
||||
|
@ -4818,7 +5002,7 @@ function renderMixin (Vue) {
|
|||
render
|
||||
) {
|
||||
var ret, i, l, keys, key;
|
||||
if (Array.isArray(val)) {
|
||||
if (Array.isArray(val) || typeof val === 'string') {
|
||||
ret = new Array(val.length);
|
||||
for (i = 0, l = val.length; i < l; i++) {
|
||||
ret[i] = render(val[i], i);
|
||||
|
@ -4843,11 +5027,16 @@ function renderMixin (Vue) {
|
|||
Vue.prototype._t = function (
|
||||
name,
|
||||
fallback,
|
||||
props
|
||||
props,
|
||||
bindObject
|
||||
) {
|
||||
var scopedSlotFn = this.$scopedSlots[name];
|
||||
if (scopedSlotFn) { // scoped slot
|
||||
return scopedSlotFn(props || {}) || fallback
|
||||
props = props || {};
|
||||
if (bindObject) {
|
||||
extend(props, bindObject);
|
||||
}
|
||||
return scopedSlotFn(props) || fallback
|
||||
} else {
|
||||
var slotNodes = this.$slots[name];
|
||||
// warn duplicate slot usage
|
||||
|
@ -4948,84 +5137,6 @@ function resolveSlots (
|
|||
|
||||
/* */
|
||||
|
||||
function initEvents (vm$$1) {
|
||||
vm$$1._events = Object.create(null);
|
||||
// init parent attached events
|
||||
var listeners = vm$$1.$options._parentListeners;
|
||||
var add = function (event, fn, once) {
|
||||
once ? vm$$1.$once(event, fn) : vm$$1.$on(event, fn);
|
||||
};
|
||||
var remove$$1 = bind(vm$$1.$off, vm$$1);
|
||||
vm$$1._updateListeners = function (listeners, oldListeners) {
|
||||
updateListeners(listeners, oldListeners || {}, add, remove$$1, vm$$1);
|
||||
};
|
||||
if (listeners) {
|
||||
vm$$1._updateListeners(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
function eventsMixin (Vue) {
|
||||
Vue.prototype.$on = function (event, fn) {
|
||||
var vm$$1 = this;(vm$$1._events[event] || (vm$$1._events[event] = [])).push(fn);
|
||||
return vm$$1
|
||||
};
|
||||
|
||||
Vue.prototype.$once = function (event, fn) {
|
||||
var vm$$1 = this;
|
||||
function on () {
|
||||
vm$$1.$off(event, on);
|
||||
fn.apply(vm$$1, arguments);
|
||||
}
|
||||
on.fn = fn;
|
||||
vm$$1.$on(event, on);
|
||||
return vm$$1
|
||||
};
|
||||
|
||||
Vue.prototype.$off = function (event, fn) {
|
||||
var vm$$1 = this;
|
||||
// all
|
||||
if (!arguments.length) {
|
||||
vm$$1._events = Object.create(null);
|
||||
return vm$$1
|
||||
}
|
||||
// specific event
|
||||
var cbs = vm$$1._events[event];
|
||||
if (!cbs) {
|
||||
return vm$$1
|
||||
}
|
||||
if (arguments.length === 1) {
|
||||
vm$$1._events[event] = null;
|
||||
return vm$$1
|
||||
}
|
||||
// specific handler
|
||||
var cb;
|
||||
var i = cbs.length;
|
||||
while (i--) {
|
||||
cb = cbs[i];
|
||||
if (cb === fn || cb.fn === fn) {
|
||||
cbs.splice(i, 1);
|
||||
break
|
||||
}
|
||||
}
|
||||
return vm$$1
|
||||
};
|
||||
|
||||
Vue.prototype.$emit = function (event) {
|
||||
var vm$$1 = this;
|
||||
var cbs = vm$$1._events[event];
|
||||
if (cbs) {
|
||||
cbs = cbs.length > 1 ? toArray(cbs) : cbs;
|
||||
var args = toArray(arguments, 1);
|
||||
for (var i = 0, l = cbs.length; i < l; i++) {
|
||||
cbs[i].apply(vm$$1, args);
|
||||
}
|
||||
}
|
||||
return vm$$1
|
||||
};
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
var uid = 0;
|
||||
|
||||
function initMixin (Vue) {
|
||||
|
@ -5454,10 +5565,10 @@ function validateProp (
|
|||
var absent = !hasOwn(propsData, key);
|
||||
var value = propsData[key];
|
||||
// handle boolean props
|
||||
if (isBooleanType(prop.type)) {
|
||||
if (isType(Boolean, prop.type)) {
|
||||
if (absent && !hasOwn(prop, 'default')) {
|
||||
value = false;
|
||||
} else if (value === '' || value === hyphenate(key)) {
|
||||
} else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
|
||||
value = true;
|
||||
}
|
||||
}
|
||||
|
@ -5598,12 +5709,12 @@ function getType (fn) {
|
|||
return match && match[1]
|
||||
}
|
||||
|
||||
function isBooleanType (fn) {
|
||||
function isType (type, fn) {
|
||||
if (!Array.isArray(fn)) {
|
||||
return getType(fn) === 'Boolean'
|
||||
return getType(fn) === getType(type)
|
||||
}
|
||||
for (var i = 0, len = fn.length; i < len; i++) {
|
||||
if (getType(fn[i]) === 'Boolean') {
|
||||
if (getType(fn[i]) === getType(type)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -6307,7 +6418,7 @@ var isAttr = makeMap(
|
|||
'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
|
||||
'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
|
||||
'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
|
||||
'form,formaction,headers,<th>,height,hidden,high,href,hreflang,http-equiv,' +
|
||||
'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
|
||||
'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
|
||||
'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
|
||||
'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
|
||||
|
@ -6350,6 +6461,7 @@ function renderDOMProps (node) {
|
|||
return res
|
||||
}
|
||||
|
||||
var attrs = node.data.attrs;
|
||||
for (var key in props) {
|
||||
if (key === 'innerHTML') {
|
||||
setText(node, props[key], true);
|
||||
|
@ -6357,7 +6469,9 @@ function renderDOMProps (node) {
|
|||
setText(node, props[key]);
|
||||
} else {
|
||||
var attr = propsToAttrMap[key] || key.toLowerCase();
|
||||
if (isRenderableAttr(attr)) {
|
||||
if (isRenderableAttr(attr) &&
|
||||
// avoid rendering double-bound props/attrs twice
|
||||
!(attrs && attrs[attr])) {
|
||||
res += renderAttr(attr, props[key]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vue-server-renderer",
|
||||
"version": "2.1.6",
|
||||
"version": "2.1.7",
|
||||
"description": "server renderer for Vue 2.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
|
|
@ -217,13 +217,15 @@ function genStaticKeys (modules) {
|
|||
* if they are plain objects, do they have the same shape?
|
||||
*/
|
||||
function looseEqual (a, b) {
|
||||
/* eslint-disable eqeqeq */
|
||||
return a == b || (
|
||||
isObject(a) && isObject(b)
|
||||
? JSON.stringify(a) === JSON.stringify(b)
|
||||
: false
|
||||
)
|
||||
/* eslint-enable eqeqeq */
|
||||
var isObjectA = isObject(a);
|
||||
var isObjectB = isObject(b);
|
||||
if (isObjectA && isObjectB) {
|
||||
return JSON.stringify(a) === JSON.stringify(b)
|
||||
} else if (!isObjectA && !isObjectB) {
|
||||
return String(a) === String(b)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function looseIndexOf (arr, val) {
|
||||
|
@ -259,7 +261,7 @@ var config = {
|
|||
/**
|
||||
* Ignore certain custom elements
|
||||
*/
|
||||
ignoredElements: null,
|
||||
ignoredElements: [],
|
||||
|
||||
/**
|
||||
* Custom user key aliases for v-on
|
||||
|
@ -1243,7 +1245,7 @@ function parse (
|
|||
process.env.NODE_ENV !== 'production' && warn$1(
|
||||
'Templates should only be responsible for mapping the state to the ' +
|
||||
'UI. Avoid placing tags with side-effects in your templates, such as ' +
|
||||
"<" + tag + ">."
|
||||
"<" + tag + ">" + ', as they will not be parsed.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1380,19 +1382,20 @@ function parse (
|
|||
currentParent.attrsMap.placeholder === text) {
|
||||
return
|
||||
}
|
||||
var children = currentParent.children;
|
||||
text = inPre || text.trim()
|
||||
? decodeHTMLCached(text)
|
||||
// only preserve whitespace if its not right after a starting tag
|
||||
: preserveWhitespace && currentParent.children.length ? ' ' : '';
|
||||
: preserveWhitespace && children.length ? ' ' : '';
|
||||
if (text) {
|
||||
var expression;
|
||||
if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
|
||||
currentParent.children.push({
|
||||
children.push({
|
||||
type: 2,
|
||||
expression: expression,
|
||||
text: text
|
||||
});
|
||||
} else {
|
||||
} else if (text !== ' ' || children[children.length - 1].text !== ' ') {
|
||||
currentParent.children.push({
|
||||
type: 3,
|
||||
text: text
|
||||
|
@ -1503,6 +1506,23 @@ function processIfConditions (el, parent) {
|
|||
}
|
||||
}
|
||||
|
||||
function findPrevElement (children) {
|
||||
var i = children.length;
|
||||
while (i--) {
|
||||
if (children[i].type === 1) {
|
||||
return children[i]
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
|
||||
warn$1(
|
||||
"text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
|
||||
"will be ignored."
|
||||
);
|
||||
}
|
||||
children.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addIfCondition (el, condition) {
|
||||
if (!el.ifConditions) {
|
||||
el.ifConditions = [];
|
||||
|
@ -1610,6 +1630,15 @@ function processAttrs (el) {
|
|||
}
|
||||
}
|
||||
addAttr(el, name, JSON.stringify(value));
|
||||
// #4530 also bind special attributes as props even if they are static
|
||||
// so that patches between dynamic/static are consistent
|
||||
if (platformMustUseProp(el.tag, name)) {
|
||||
if (name === 'value') {
|
||||
addProp(el, name, JSON.stringify(value));
|
||||
} else {
|
||||
addProp(el, name, 'true');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1645,13 +1674,6 @@ function makeAttrsMap (attrs) {
|
|||
return map
|
||||
}
|
||||
|
||||
function findPrevElement (children) {
|
||||
var i = children.length;
|
||||
while (i--) {
|
||||
if (children[i].tag) { return children[i] }
|
||||
}
|
||||
}
|
||||
|
||||
function isForbiddenTag (el) {
|
||||
return (
|
||||
el.tag === 'style' ||
|
||||
|
@ -1917,6 +1939,7 @@ var warn$2;
|
|||
var transforms$1;
|
||||
var dataGenFns;
|
||||
var platformDirectives;
|
||||
var isPlatformReservedTag$1;
|
||||
var staticRenderFns;
|
||||
var onceCount;
|
||||
var currentOptions;
|
||||
|
@ -1935,6 +1958,7 @@ function generate (
|
|||
transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
|
||||
dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
||||
platformDirectives = options.directives || {};
|
||||
isPlatformReservedTag$1 = options.isReservedTag || no;
|
||||
var code = ast ? genElement(ast) : '_c("div")';
|
||||
staticRenderFns = prevStaticRenderFns;
|
||||
onceCount = prevOnceCount;
|
||||
|
@ -2174,27 +2198,40 @@ function genChildren (el, checkSkip) {
|
|||
el$1.tag !== 'slot') {
|
||||
return genElement(el$1)
|
||||
}
|
||||
var normalizationType = getNormalizationType(children);
|
||||
return ("[" + (children.map(genNode).join(',')) + "]" + (checkSkip
|
||||
? canSkipNormalization(children) ? '' : ',true'
|
||||
? normalizationType ? ("," + normalizationType) : ''
|
||||
: ''))
|
||||
}
|
||||
}
|
||||
|
||||
function canSkipNormalization (children) {
|
||||
// determine the normalzation needed for the children array.
|
||||
// 0: no normalization needed
|
||||
// 1: simple normalization needed (possible 1-level deep nested array)
|
||||
// 2: full nomralization needed
|
||||
function getNormalizationType (children) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var el = children[i];
|
||||
if (needsNormalization(el) ||
|
||||
(el.if && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
|
||||
return false
|
||||
return 2
|
||||
}
|
||||
if (maybeComponent(el) ||
|
||||
(el.if && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
return true
|
||||
return 0
|
||||
}
|
||||
|
||||
function needsNormalization (el) {
|
||||
return el.for || el.tag === 'template' || el.tag === 'slot'
|
||||
}
|
||||
|
||||
function maybeComponent (el) {
|
||||
return el.type === 1 && !isPlatformReservedTag$1(el.tag)
|
||||
}
|
||||
|
||||
function genNode (node) {
|
||||
if (node.type === 1) {
|
||||
return genElement(node)
|
||||
|
@ -2212,7 +2249,19 @@ function genText (text) {
|
|||
function genSlot (el) {
|
||||
var slotName = el.slotName || '"default"';
|
||||
var children = genChildren(el);
|
||||
return ("_t(" + slotName + (children ? ("," + children) : '') + (el.attrs ? ((children ? '' : ',null') + ",{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}") : '') + ")")
|
||||
var res = "_t(" + slotName + (children ? ("," + children) : '');
|
||||
var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
|
||||
var bind$$1 = el.attrsMap['v-bind'];
|
||||
if ((attrs || bind$$1) && !children) {
|
||||
res += ",null";
|
||||
}
|
||||
if (attrs) {
|
||||
res += "," + attrs;
|
||||
}
|
||||
if (bind$$1) {
|
||||
res += (attrs ? '' : ',null') + "," + bind$$1;
|
||||
}
|
||||
return res + ')'
|
||||
}
|
||||
|
||||
// componentName is el.component, take it as argument to shun flow's pessimistic refinement
|
||||
|
@ -2963,16 +3012,17 @@ var Watcher = function Watcher (
|
|||
cb,
|
||||
options
|
||||
) {
|
||||
if ( options === void 0 ) options = {};
|
||||
|
||||
this.vm = vm;
|
||||
vm._watchers.push(this);
|
||||
// options
|
||||
if (options) {
|
||||
this.deep = !!options.deep;
|
||||
this.user = !!options.user;
|
||||
this.lazy = !!options.lazy;
|
||||
this.sync = !!options.sync;
|
||||
this.expression = expOrFn.toString();
|
||||
} else {
|
||||
this.deep = this.user = this.lazy = this.sync = false;
|
||||
}
|
||||
this.cb = cb;
|
||||
this.id = ++uid$1; // uid for batching
|
||||
this.active = true;
|
||||
|
@ -2981,6 +3031,9 @@ var Watcher = function Watcher (
|
|||
this.newDeps = [];
|
||||
this.depIds = new _Set();
|
||||
this.newDepIds = new _Set();
|
||||
this.expression = process.env.NODE_ENV !== 'production'
|
||||
? expOrFn.toString()
|
||||
: '';
|
||||
// parse expression for getter
|
||||
if (typeof expOrFn === 'function') {
|
||||
this.getter = expOrFn;
|
||||
|
@ -3322,7 +3375,7 @@ function copyAugment (target, src, keys) {
|
|||
* returns the new observer if successfully observed,
|
||||
* or the existing observer if the value already has one.
|
||||
*/
|
||||
function observe (value) {
|
||||
function observe (value, asRootData) {
|
||||
if (!isObject(value)) {
|
||||
return
|
||||
}
|
||||
|
@ -3338,6 +3391,9 @@ function observe (value) {
|
|||
) {
|
||||
ob = new Observer(value);
|
||||
}
|
||||
if (asRootData && ob) {
|
||||
ob.vmCount++;
|
||||
}
|
||||
return ob
|
||||
}
|
||||
|
||||
|
@ -3471,18 +3527,21 @@ function dependArray (value) {
|
|||
|
||||
function initState (vm) {
|
||||
vm._watchers = [];
|
||||
initProps(vm);
|
||||
initMethods(vm);
|
||||
var opts = vm.$options;
|
||||
if (opts.props) { initProps(vm, opts.props); }
|
||||
if (opts.methods) { initMethods(vm, opts.methods); }
|
||||
if (opts.data) {
|
||||
initData(vm);
|
||||
initComputed(vm);
|
||||
initWatch(vm);
|
||||
} else {
|
||||
observe(vm._data = {}, true /* asRootData */);
|
||||
}
|
||||
if (opts.computed) { initComputed(vm, opts.computed); }
|
||||
if (opts.watch) { initWatch(vm, opts.watch); }
|
||||
}
|
||||
|
||||
var isReservedProp = { key: 1, ref: 1, slot: 1 };
|
||||
|
||||
function initProps (vm) {
|
||||
var props = vm.$options.props;
|
||||
if (props) {
|
||||
function initProps (vm, props) {
|
||||
var propsData = vm.$options.propsData || {};
|
||||
var keys = vm.$options._propKeys = Object.keys(props);
|
||||
var isRoot = !vm.$parent;
|
||||
|
@ -3516,7 +3575,6 @@ function initProps (vm) {
|
|||
|
||||
for (var i = 0; i < keys.length; i++) loop( i );
|
||||
observerState.shouldConvert = true;
|
||||
}
|
||||
}
|
||||
|
||||
function initData (vm) {
|
||||
|
@ -3548,8 +3606,7 @@ function initData (vm) {
|
|||
}
|
||||
}
|
||||
// observe data
|
||||
observe(data);
|
||||
data.__ob__ && data.__ob__.vmCount++;
|
||||
observe(data, true /* asRootData */);
|
||||
}
|
||||
|
||||
var computedSharedDefinition = {
|
||||
|
@ -3559,9 +3616,7 @@ var computedSharedDefinition = {
|
|||
set: noop
|
||||
};
|
||||
|
||||
function initComputed (vm) {
|
||||
var computed = vm.$options.computed;
|
||||
if (computed) {
|
||||
function initComputed (vm, computed) {
|
||||
for (var key in computed) {
|
||||
var userDef = computed[key];
|
||||
if (typeof userDef === 'function') {
|
||||
|
@ -3579,7 +3634,6 @@ function initComputed (vm) {
|
|||
}
|
||||
Object.defineProperty(vm, key, computedSharedDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeComputedGetter (getter, owner) {
|
||||
|
@ -3597,9 +3651,7 @@ function makeComputedGetter (getter, owner) {
|
|||
}
|
||||
}
|
||||
|
||||
function initMethods (vm) {
|
||||
var methods = vm.$options.methods;
|
||||
if (methods) {
|
||||
function initMethods (vm, methods) {
|
||||
for (var key in methods) {
|
||||
vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
|
||||
if (process.env.NODE_ENV !== 'production' && methods[key] == null) {
|
||||
|
@ -3610,12 +3662,9 @@ function initMethods (vm) {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initWatch (vm) {
|
||||
var watch = vm.$options.watch;
|
||||
if (watch) {
|
||||
function initWatch (vm, watch) {
|
||||
for (var key in watch) {
|
||||
var handler = watch[key];
|
||||
if (Array.isArray(handler)) {
|
||||
|
@ -3626,7 +3675,6 @@ function initWatch (vm) {
|
|||
createWatcher(vm, key, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createWatcher (vm, key, handler) {
|
||||
|
@ -3769,6 +3817,252 @@ function cloneVNodes (vnodes) {
|
|||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
|
||||
function updateListeners (
|
||||
on,
|
||||
oldOn,
|
||||
add,
|
||||
remove$$1,
|
||||
vm
|
||||
) {
|
||||
var name, cur, old, fn, event, capture, once;
|
||||
for (name in on) {
|
||||
cur = on[name];
|
||||
old = oldOn[name];
|
||||
if (!cur) {
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
"Invalid handler for event \"" + name + "\": got " + String(cur),
|
||||
vm
|
||||
);
|
||||
} else if (!old) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
if (Array.isArray(cur)) {
|
||||
add(event, (cur.invoker = arrInvoker(cur)), once, capture);
|
||||
} else {
|
||||
if (!cur.invoker) {
|
||||
fn = cur;
|
||||
cur = on[name] = {};
|
||||
cur.fn = fn;
|
||||
cur.invoker = fnInvoker(cur);
|
||||
}
|
||||
add(event, cur.invoker, once, capture);
|
||||
}
|
||||
} else if (cur !== old) {
|
||||
if (Array.isArray(old)) {
|
||||
old.length = cur.length;
|
||||
for (var i = 0; i < old.length; i++) { old[i] = cur[i]; }
|
||||
on[name] = old;
|
||||
} else {
|
||||
old.fn = cur;
|
||||
on[name] = old;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (name in oldOn) {
|
||||
if (!on[name]) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
remove$$1(event, oldOn[name].invoker, capture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function arrInvoker (arr) {
|
||||
return function (ev) {
|
||||
var arguments$1 = arguments;
|
||||
|
||||
var single = arguments.length === 1;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
single ? arr[i](ev) : arr[i].apply(null, arguments$1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fnInvoker (o) {
|
||||
return function (ev) {
|
||||
var single = arguments.length === 1;
|
||||
single ? o.fn(ev) : o.fn.apply(null, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
// The template compiler attempts to minimize the need for normalization by
|
||||
// statically analyzing the template at compile time.
|
||||
//
|
||||
// For plain HTML markup, normalization can be completely skipped because the
|
||||
// generated render function is guaranteed to return Array<VNode>. There are
|
||||
// two cases where extra normalization is needed:
|
||||
|
||||
// 1. When the children contains components - because a functional component
|
||||
// may return an Array instead of a single root. In this case, just a simple
|
||||
// nomralization is needed - if any child is an Array, we flatten the whole
|
||||
// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
|
||||
// because functional components already normalize their own children.
|
||||
function simpleNormalizeChildren (children) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
if (Array.isArray(children[i])) {
|
||||
return Array.prototype.concat.apply([], children)
|
||||
}
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
// 2. When the children contains constrcuts that always generated nested Arrays,
|
||||
// e.g. <template>, <slot>, v-for, or when the children is provided by user
|
||||
// with hand-written render functions / JSX. In such cases a full normalization
|
||||
// is needed to cater to all possible types of children values.
|
||||
function normalizeChildren (children) {
|
||||
return isPrimitive(children)
|
||||
? [createTextVNode(children)]
|
||||
: Array.isArray(children)
|
||||
? normalizeArrayChildren(children)
|
||||
: undefined
|
||||
}
|
||||
|
||||
function normalizeArrayChildren (children, nestedIndex) {
|
||||
var res = [];
|
||||
var i, c, last;
|
||||
for (i = 0; i < children.length; i++) {
|
||||
c = children[i];
|
||||
if (c == null || typeof c === 'boolean') { continue }
|
||||
last = res[res.length - 1];
|
||||
// nested
|
||||
if (Array.isArray(c)) {
|
||||
res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
|
||||
} else if (isPrimitive(c)) {
|
||||
if (last && last.text) {
|
||||
last.text += String(c);
|
||||
} else if (c !== '') {
|
||||
// convert primitive to vnode
|
||||
res.push(createTextVNode(c));
|
||||
}
|
||||
} else {
|
||||
if (c.text && last && last.text) {
|
||||
res[res.length - 1] = createTextVNode(last.text + c.text);
|
||||
} else {
|
||||
// default key for nested array children (likely generated by v-for)
|
||||
if (c.tag && c.key == null && nestedIndex != null) {
|
||||
c.key = "__vlist" + nestedIndex + "_" + i + "__";
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
|
||||
function initEvents (vm) {
|
||||
vm._events = Object.create(null);
|
||||
vm._hasHookEvent = false;
|
||||
// init parent attached events
|
||||
var listeners = vm.$options._parentListeners;
|
||||
if (listeners) {
|
||||
updateComponentListeners(vm, listeners);
|
||||
}
|
||||
}
|
||||
|
||||
var target;
|
||||
|
||||
function add$1 (event, fn, once) {
|
||||
if (once) {
|
||||
target.$once(event, fn);
|
||||
} else {
|
||||
target.$on(event, fn);
|
||||
}
|
||||
}
|
||||
|
||||
function remove$1 (event, fn) {
|
||||
target.$off(event, fn);
|
||||
}
|
||||
|
||||
function updateComponentListeners (
|
||||
vm,
|
||||
listeners,
|
||||
oldListeners
|
||||
) {
|
||||
target = vm;
|
||||
updateListeners(listeners, oldListeners || {}, add$1, remove$1, vm);
|
||||
}
|
||||
|
||||
function eventsMixin (Vue) {
|
||||
var hookRE = /^hook:/;
|
||||
Vue.prototype.$on = function (event, fn) {
|
||||
var vm = this;(vm._events[event] || (vm._events[event] = [])).push(fn);
|
||||
// optimize hook:event cost by using a boolean flag marked at registration
|
||||
// instead of a hash lookup
|
||||
if (hookRE.test(event)) {
|
||||
vm._hasHookEvent = true;
|
||||
}
|
||||
return vm
|
||||
};
|
||||
|
||||
Vue.prototype.$once = function (event, fn) {
|
||||
var vm = this;
|
||||
function on () {
|
||||
vm.$off(event, on);
|
||||
fn.apply(vm, arguments);
|
||||
}
|
||||
on.fn = fn;
|
||||
vm.$on(event, on);
|
||||
return vm
|
||||
};
|
||||
|
||||
Vue.prototype.$off = function (event, fn) {
|
||||
var vm = this;
|
||||
// all
|
||||
if (!arguments.length) {
|
||||
vm._events = Object.create(null);
|
||||
return vm
|
||||
}
|
||||
// specific event
|
||||
var cbs = vm._events[event];
|
||||
if (!cbs) {
|
||||
return vm
|
||||
}
|
||||
if (arguments.length === 1) {
|
||||
vm._events[event] = null;
|
||||
return vm
|
||||
}
|
||||
// specific handler
|
||||
var cb;
|
||||
var i = cbs.length;
|
||||
while (i--) {
|
||||
cb = cbs[i];
|
||||
if (cb === fn || cb.fn === fn) {
|
||||
cbs.splice(i, 1);
|
||||
break
|
||||
}
|
||||
}
|
||||
return vm
|
||||
};
|
||||
|
||||
Vue.prototype.$emit = function (event) {
|
||||
var vm = this;
|
||||
var cbs = vm._events[event];
|
||||
if (cbs) {
|
||||
cbs = cbs.length > 1 ? toArray(cbs) : cbs;
|
||||
var args = toArray(arguments, 1);
|
||||
for (var i = 0, l = cbs.length; i < l; i++) {
|
||||
cbs[i].apply(vm, args);
|
||||
}
|
||||
}
|
||||
return vm
|
||||
};
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
var activeInstance = null;
|
||||
|
||||
function initLifecycle (vm) {
|
||||
|
@ -3911,7 +4205,7 @@ function lifecycleMixin (Vue) {
|
|||
if (listeners) {
|
||||
var oldListeners = vm.$options._parentListeners;
|
||||
vm.$options._parentListeners = listeners;
|
||||
vm._updateListeners(listeners, oldListeners);
|
||||
updateComponentListeners(vm, listeners, oldListeners);
|
||||
}
|
||||
// resolve slots + force update if has children
|
||||
if (hasChildren) {
|
||||
|
@ -3973,7 +4267,9 @@ function callHook (vm, hook) {
|
|||
handlers[i].call(vm);
|
||||
}
|
||||
}
|
||||
if (vm._hasHookEvent) {
|
||||
vm.$emit('hook:' + hook);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
@ -4296,125 +4592,8 @@ function mergeHook$1 (one, two) {
|
|||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
|
||||
function updateListeners (
|
||||
on,
|
||||
oldOn,
|
||||
add,
|
||||
remove$$1,
|
||||
vm
|
||||
) {
|
||||
var name, cur, old, fn, event, capture, once;
|
||||
for (name in on) {
|
||||
cur = on[name];
|
||||
old = oldOn[name];
|
||||
if (!cur) {
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
"Invalid handler for event \"" + name + "\": got " + String(cur),
|
||||
vm
|
||||
);
|
||||
} else if (!old) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
if (Array.isArray(cur)) {
|
||||
add(event, (cur.invoker = arrInvoker(cur)), once, capture);
|
||||
} else {
|
||||
if (!cur.invoker) {
|
||||
fn = cur;
|
||||
cur = on[name] = {};
|
||||
cur.fn = fn;
|
||||
cur.invoker = fnInvoker(cur);
|
||||
}
|
||||
add(event, cur.invoker, once, capture);
|
||||
}
|
||||
} else if (cur !== old) {
|
||||
if (Array.isArray(old)) {
|
||||
old.length = cur.length;
|
||||
for (var i = 0; i < old.length; i++) { old[i] = cur[i]; }
|
||||
on[name] = old;
|
||||
} else {
|
||||
old.fn = cur;
|
||||
on[name] = old;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (name in oldOn) {
|
||||
if (!on[name]) {
|
||||
once = name.charAt(0) === '~'; // Prefixed last, checked first
|
||||
event = once ? name.slice(1) : name;
|
||||
capture = event.charAt(0) === '!';
|
||||
event = capture ? event.slice(1) : event;
|
||||
remove$$1(event, oldOn[name].invoker, capture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function arrInvoker (arr) {
|
||||
return function (ev) {
|
||||
var arguments$1 = arguments;
|
||||
|
||||
var single = arguments.length === 1;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
single ? arr[i](ev) : arr[i].apply(null, arguments$1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fnInvoker (o) {
|
||||
return function (ev) {
|
||||
var single = arguments.length === 1;
|
||||
single ? o.fn(ev) : o.fn.apply(null, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
function normalizeChildren (children) {
|
||||
return isPrimitive(children)
|
||||
? [createTextVNode(children)]
|
||||
: Array.isArray(children)
|
||||
? normalizeArrayChildren(children)
|
||||
: undefined
|
||||
}
|
||||
|
||||
function normalizeArrayChildren (children, nestedIndex) {
|
||||
var res = [];
|
||||
var i, c, last;
|
||||
for (i = 0; i < children.length; i++) {
|
||||
c = children[i];
|
||||
if (c == null || typeof c === 'boolean') { continue }
|
||||
last = res[res.length - 1];
|
||||
// nested
|
||||
if (Array.isArray(c)) {
|
||||
res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
|
||||
} else if (isPrimitive(c)) {
|
||||
if (last && last.text) {
|
||||
last.text += String(c);
|
||||
} else if (c !== '') {
|
||||
// convert primitive to vnode
|
||||
res.push(createTextVNode(c));
|
||||
}
|
||||
} else {
|
||||
if (c.text && last && last.text) {
|
||||
res[res.length - 1] = createTextVNode(last.text + c.text);
|
||||
} else {
|
||||
// default key for nested array children (likely generated by v-for)
|
||||
if (c.tag && c.key == null && nestedIndex != null) {
|
||||
c.key = "__vlist" + nestedIndex + "_" + i + "__";
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
/* */
|
||||
var SIMPLE_NORMALIZE = 1;
|
||||
var ALWAYS_NORMALIZE = 2;
|
||||
|
||||
// wrapper function for providing a more flexible interface
|
||||
// without getting yelled at by flow
|
||||
|
@ -4423,16 +4602,16 @@ function createElement (
|
|||
tag,
|
||||
data,
|
||||
children,
|
||||
needNormalization,
|
||||
normalizationType,
|
||||
alwaysNormalize
|
||||
) {
|
||||
if (Array.isArray(data) || isPrimitive(data)) {
|
||||
needNormalization = children;
|
||||
normalizationType = children;
|
||||
children = data;
|
||||
data = undefined;
|
||||
}
|
||||
if (alwaysNormalize) { needNormalization = true; }
|
||||
return _createElement(context, tag, data, children, needNormalization)
|
||||
if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
|
||||
return _createElement(context, tag, data, children, normalizationType)
|
||||
}
|
||||
|
||||
function _createElement (
|
||||
|
@ -4440,7 +4619,7 @@ function _createElement (
|
|||
tag,
|
||||
data,
|
||||
children,
|
||||
needNormalization
|
||||
normalizationType
|
||||
) {
|
||||
if (data && data.__ob__) {
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
|
@ -4461,8 +4640,10 @@ function _createElement (
|
|||
data.scopedSlots = { default: children[0] };
|
||||
children.length = 0;
|
||||
}
|
||||
if (needNormalization) {
|
||||
if (normalizationType === ALWAYS_NORMALIZE) {
|
||||
children = normalizeChildren(children);
|
||||
} else if (normalizationType === SIMPLE_NORMALIZE) {
|
||||
children = simpleNormalizeChildren(children);
|
||||
}
|
||||
var vnode, ns;
|
||||
if (typeof tag === 'string') {
|
||||
|
@ -4481,7 +4662,6 @@ function _createElement (
|
|||
// unknown or unlisted namespaced elements
|
||||
// check at runtime because it may get assigned a namespace when its
|
||||
// parent normalizes children
|
||||
ns = tag === 'foreignObject' ? 'xhtml' : ns;
|
||||
vnode = new VNode(
|
||||
tag, data, children,
|
||||
undefined, undefined, context
|
||||
|
@ -4501,6 +4681,10 @@ function _createElement (
|
|||
|
||||
function applyNS (vnode, ns) {
|
||||
vnode.ns = ns;
|
||||
if (vnode.tag === 'foreignObject') {
|
||||
// use default namespace inside foreignObject
|
||||
return
|
||||
}
|
||||
if (vnode.children) {
|
||||
for (var i = 0, l = vnode.children.length; i < l; i++) {
|
||||
var child = vnode.children[i];
|
||||
|
@ -4523,7 +4707,7 @@ function initRender (vm) {
|
|||
vm.$scopedSlots = {};
|
||||
// bind the createElement fn to this instance
|
||||
// so that we get proper render context inside it.
|
||||
// args order: tag, data, children, needNormalization, alwaysNormalize
|
||||
// args order: tag, data, children, normalizationType, alwaysNormalize
|
||||
// internal version is used by render functions compiled from templates
|
||||
vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
|
||||
// normalization is always applied for the public version, used in
|
||||
|
@ -4667,7 +4851,7 @@ function renderMixin (Vue) {
|
|||
render
|
||||
) {
|
||||
var ret, i, l, keys, key;
|
||||
if (Array.isArray(val)) {
|
||||
if (Array.isArray(val) || typeof val === 'string') {
|
||||
ret = new Array(val.length);
|
||||
for (i = 0, l = val.length; i < l; i++) {
|
||||
ret[i] = render(val[i], i);
|
||||
|
@ -4692,11 +4876,16 @@ function renderMixin (Vue) {
|
|||
Vue.prototype._t = function (
|
||||
name,
|
||||
fallback,
|
||||
props
|
||||
props,
|
||||
bindObject
|
||||
) {
|
||||
var scopedSlotFn = this.$scopedSlots[name];
|
||||
if (scopedSlotFn) { // scoped slot
|
||||
return scopedSlotFn(props || {}) || fallback
|
||||
props = props || {};
|
||||
if (bindObject) {
|
||||
extend(props, bindObject);
|
||||
}
|
||||
return scopedSlotFn(props) || fallback
|
||||
} else {
|
||||
var slotNodes = this.$slots[name];
|
||||
// warn duplicate slot usage
|
||||
|
@ -4797,84 +4986,6 @@ function resolveSlots (
|
|||
|
||||
/* */
|
||||
|
||||
function initEvents (vm) {
|
||||
vm._events = Object.create(null);
|
||||
// init parent attached events
|
||||
var listeners = vm.$options._parentListeners;
|
||||
var add = function (event, fn, once) {
|
||||
once ? vm.$once(event, fn) : vm.$on(event, fn);
|
||||
};
|
||||
var remove$$1 = bind(vm.$off, vm);
|
||||
vm._updateListeners = function (listeners, oldListeners) {
|
||||
updateListeners(listeners, oldListeners || {}, add, remove$$1, vm);
|
||||
};
|
||||
if (listeners) {
|
||||
vm._updateListeners(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
function eventsMixin (Vue) {
|
||||
Vue.prototype.$on = function (event, fn) {
|
||||
var vm = this;(vm._events[event] || (vm._events[event] = [])).push(fn);
|
||||
return vm
|
||||
};
|
||||
|
||||
Vue.prototype.$once = function (event, fn) {
|
||||
var vm = this;
|
||||
function on () {
|
||||
vm.$off(event, on);
|
||||
fn.apply(vm, arguments);
|
||||
}
|
||||
on.fn = fn;
|
||||
vm.$on(event, on);
|
||||
return vm
|
||||
};
|
||||
|
||||
Vue.prototype.$off = function (event, fn) {
|
||||
var vm = this;
|
||||
// all
|
||||
if (!arguments.length) {
|
||||
vm._events = Object.create(null);
|
||||
return vm
|
||||
}
|
||||
// specific event
|
||||
var cbs = vm._events[event];
|
||||
if (!cbs) {
|
||||
return vm
|
||||
}
|
||||
if (arguments.length === 1) {
|
||||
vm._events[event] = null;
|
||||
return vm
|
||||
}
|
||||
// specific handler
|
||||
var cb;
|
||||
var i = cbs.length;
|
||||
while (i--) {
|
||||
cb = cbs[i];
|
||||
if (cb === fn || cb.fn === fn) {
|
||||
cbs.splice(i, 1);
|
||||
break
|
||||
}
|
||||
}
|
||||
return vm
|
||||
};
|
||||
|
||||
Vue.prototype.$emit = function (event) {
|
||||
var vm = this;
|
||||
var cbs = vm._events[event];
|
||||
if (cbs) {
|
||||
cbs = cbs.length > 1 ? toArray(cbs) : cbs;
|
||||
var args = toArray(arguments, 1);
|
||||
for (var i = 0, l = cbs.length; i < l; i++) {
|
||||
cbs[i].apply(vm, args);
|
||||
}
|
||||
}
|
||||
return vm
|
||||
};
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
var uid = 0;
|
||||
|
||||
function initMixin (Vue) {
|
||||
|
@ -5303,10 +5414,10 @@ function validateProp (
|
|||
var absent = !hasOwn(propsData, key);
|
||||
var value = propsData[key];
|
||||
// handle boolean props
|
||||
if (isBooleanType(prop.type)) {
|
||||
if (isType(Boolean, prop.type)) {
|
||||
if (absent && !hasOwn(prop, 'default')) {
|
||||
value = false;
|
||||
} else if (value === '' || value === hyphenate(key)) {
|
||||
} else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
|
||||
value = true;
|
||||
}
|
||||
}
|
||||
|
@ -5447,12 +5558,12 @@ function getType (fn) {
|
|||
return match && match[1]
|
||||
}
|
||||
|
||||
function isBooleanType (fn) {
|
||||
function isType (type, fn) {
|
||||
if (!Array.isArray(fn)) {
|
||||
return getType(fn) === 'Boolean'
|
||||
return getType(fn) === getType(type)
|
||||
}
|
||||
for (var i = 0, len = fn.length; i < len; i++) {
|
||||
if (getType(fn[i]) === 'Boolean') {
|
||||
if (getType(fn[i]) === getType(type)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vue-template-compiler",
|
||||
"version": "2.1.6",
|
||||
"version": "2.1.7",
|
||||
"description": "template compiler for Vue 2.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
|
|
@ -587,7 +587,6 @@ export function createPatchFunction (backend) {
|
|||
// create an empty node and replace it
|
||||
oldVnode = emptyNodeAt(oldVnode)
|
||||
}
|
||||
|
||||
// replacing existing element
|
||||
elm = oldVnode.elm
|
||||
parent = nodeOps.parentNode(elm)
|
||||
|
|
Loading…
Reference in New Issue