diff --git a/dist/vue-chartjs.js b/dist/vue-chartjs.js index 7705227..812344f 100644 --- a/dist/vue-chartjs.js +++ b/dist/vue-chartjs.js @@ -65,31 +65,31 @@ return /******/ (function(modules) { // webpackBootstrap var _Bar2 = _interopRequireDefault(_Bar); - var _Doughnut = __webpack_require__(379); + var _Doughnut = __webpack_require__(380); var _Doughnut2 = _interopRequireDefault(_Doughnut); - var _Line = __webpack_require__(380); + var _Line = __webpack_require__(381); var _Line2 = _interopRequireDefault(_Line); - var _Pie = __webpack_require__(381); + var _Pie = __webpack_require__(382); var _Pie2 = _interopRequireDefault(_Pie); - var _PolarArea = __webpack_require__(382); + var _PolarArea = __webpack_require__(383); var _PolarArea2 = _interopRequireDefault(_PolarArea); - var _Radar = __webpack_require__(383); + var _Radar = __webpack_require__(384); var _Radar2 = _interopRequireDefault(_Radar); - var _Bubble = __webpack_require__(384); + var _Bubble = __webpack_require__(385); var _Bubble2 = _interopRequireDefault(_Bubble); - var _index = __webpack_require__(385); + var _index = __webpack_require__(386); var _index2 = _interopRequireDefault(_index); @@ -212,8 +212,8 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process, global) {/*! - * Vue.js v2.1.6 - * (c) 2014-2016 Evan You + * Vue.js v2.1.10 + * (c) 2014-2017 Evan You * Released under the MIT License. */ 'use strict'; @@ -236,8 +236,8 @@ return /******/ (function(modules) { // webpackBootstrap * If the conversion fails, return original string. */ function toNumber (val) { - var n = parseFloat(val, 10); - return (n || n === 0) ? n : val + var n = parseFloat(val); + return isNaN(n) ? val : n } /** @@ -295,14 +295,14 @@ return /******/ (function(modules) { // webpackBootstrap */ function cached (fn) { var cache = Object.create(null); - return function cachedFn (str) { + return (function cachedFn (str) { var hit = cache[str]; return hit || (cache[str] = fn(str)) - } + }) } /** - * Camelize a hyphen-delmited string. + * Camelize a hyphen-delimited string. */ var camelizeRE = /-(\w)/g; var camelize = cached(function (str) { @@ -428,13 +428,15 @@ return /******/ (function(modules) { // webpackBootstrap * 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) { @@ -470,7 +472,7 @@ return /******/ (function(modules) { // webpackBootstrap /** * Ignore certain custom elements */ - ignoredElements: null, + ignoredElements: [], /** * Custom user key aliases for v-on @@ -943,7 +945,7 @@ return /******/ (function(modules) { // webpackBootstrap * 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 } @@ -959,6 +961,9 @@ return /******/ (function(modules) { // webpackBootstrap ) { ob = new Observer(value); } + if (asRootData && ob) { + ob.vmCount++; + } return ob } @@ -1425,10 +1430,10 @@ return /******/ (function(modules) { // webpackBootstrap 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; } } @@ -1508,7 +1513,7 @@ return /******/ (function(modules) { // webpackBootstrap } for (var i = 0; i < type.length && !valid; i++) { var assertedType = assertType(value, type[i]); - expectedTypes.push(assertedType.expectedType); + expectedTypes.push(assertedType.expectedType || ''); valid = assertedType.valid; } } @@ -1569,12 +1574,12 @@ return /******/ (function(modules) { // webpackBootstrap 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 } } @@ -1707,572 +1712,6 @@ return /******/ (function(modules) { // webpackBootstrap /* */ - - var queue = []; - var has$1 = {}; - var circular = {}; - var waiting = false; - var flushing = false; - var index = 0; - - /** - * Reset the scheduler's state. - */ - function resetSchedulerState () { - queue.length = 0; - has$1 = {}; - if (process.env.NODE_ENV !== 'production') { - circular = {}; - } - waiting = flushing = false; - } - - /** - * Flush both queues and run the watchers. - */ - function flushSchedulerQueue () { - flushing = true; - - // Sort queue before flush. - // This ensures that: - // 1. Components are updated from parent to child. (because parent is always - // created before the child) - // 2. A component's user watchers are run before its render watcher (because - // user watchers are created before the render watcher) - // 3. If a component is destroyed during a parent component's watcher run, - // its watchers can be skipped. - queue.sort(function (a, b) { return a.id - b.id; }); - - // do not cache length because more watchers might be pushed - // as we run existing watchers - for (index = 0; index < queue.length; index++) { - var watcher = queue[index]; - var id = watcher.id; - has$1[id] = null; - watcher.run(); - // in dev build, check and stop circular updates. - if (process.env.NODE_ENV !== 'production' && has$1[id] != null) { - circular[id] = (circular[id] || 0) + 1; - if (circular[id] > config._maxUpdateCount) { - warn( - 'You may have an infinite update loop ' + ( - watcher.user - ? ("in watcher with expression \"" + (watcher.expression) + "\"") - : "in a component render function." - ), - watcher.vm - ); - break - } - } - } - - // devtool hook - /* istanbul ignore if */ - if (devtools && config.devtools) { - devtools.emit('flush'); - } - - resetSchedulerState(); - } - - /** - * Push a watcher into the watcher queue. - * Jobs with duplicate IDs will be skipped unless it's - * pushed when the queue is being flushed. - */ - function queueWatcher (watcher) { - var id = watcher.id; - if (has$1[id] == null) { - has$1[id] = true; - if (!flushing) { - queue.push(watcher); - } else { - // if already flushing, splice the watcher based on its id - // if already past its id, it will be run next immediately. - var i = queue.length - 1; - while (i >= 0 && queue[i].id > watcher.id) { - i--; - } - queue.splice(Math.max(i, index) + 1, 0, watcher); - } - // queue the flush - if (!waiting) { - waiting = true; - nextTick(flushSchedulerQueue); - } - } - } - - /* */ - - var uid$2 = 0; - - /** - * A watcher parses an expression, collects dependencies, - * and fires callback when the expression value changes. - * This is used for both the $watch() api and directives. - */ - var Watcher = function Watcher ( - vm, - expOrFn, - cb, - options - ) { - if ( options === void 0 ) options = {}; - - this.vm = vm; - vm._watchers.push(this); - // options - this.deep = !!options.deep; - this.user = !!options.user; - this.lazy = !!options.lazy; - this.sync = !!options.sync; - this.expression = expOrFn.toString(); - this.cb = cb; - this.id = ++uid$2; // uid for batching - this.active = true; - this.dirty = this.lazy; // for lazy watchers - this.deps = []; - this.newDeps = []; - this.depIds = new _Set(); - this.newDepIds = new _Set(); - // parse expression for getter - if (typeof expOrFn === 'function') { - this.getter = expOrFn; - } else { - this.getter = parsePath(expOrFn); - if (!this.getter) { - this.getter = function () {}; - process.env.NODE_ENV !== 'production' && warn( - "Failed watching path: \"" + expOrFn + "\" " + - 'Watcher only accepts simple dot-delimited paths. ' + - 'For full control, use a function instead.', - vm - ); - } - } - this.value = this.lazy - ? undefined - : this.get(); - }; - - /** - * Evaluate the getter, and re-collect dependencies. - */ - Watcher.prototype.get = function get () { - pushTarget(this); - var value = this.getter.call(this.vm, this.vm); - // "touch" every property so they are all tracked as - // dependencies for deep watching - if (this.deep) { - traverse(value); - } - popTarget(); - this.cleanupDeps(); - return value - }; - - /** - * Add a dependency to this directive. - */ - Watcher.prototype.addDep = function addDep (dep) { - var id = dep.id; - if (!this.newDepIds.has(id)) { - this.newDepIds.add(id); - this.newDeps.push(dep); - if (!this.depIds.has(id)) { - dep.addSub(this); - } - } - }; - - /** - * Clean up for dependency collection. - */ - Watcher.prototype.cleanupDeps = function cleanupDeps () { - var this$1 = this; - - var i = this.deps.length; - while (i--) { - var dep = this$1.deps[i]; - if (!this$1.newDepIds.has(dep.id)) { - dep.removeSub(this$1); - } - } - var tmp = this.depIds; - this.depIds = this.newDepIds; - this.newDepIds = tmp; - this.newDepIds.clear(); - tmp = this.deps; - this.deps = this.newDeps; - this.newDeps = tmp; - this.newDeps.length = 0; - }; - - /** - * Subscriber interface. - * Will be called when a dependency changes. - */ - Watcher.prototype.update = function update () { - /* istanbul ignore else */ - if (this.lazy) { - this.dirty = true; - } else if (this.sync) { - this.run(); - } else { - queueWatcher(this); - } - }; - - /** - * Scheduler job interface. - * Will be called by the scheduler. - */ - Watcher.prototype.run = function run () { - if (this.active) { - var value = this.get(); - if ( - value !== this.value || - // Deep watchers and watchers on Object/Arrays should fire even - // when the value is the same, because the value may - // have mutated. - isObject(value) || - this.deep - ) { - // set new value - var oldValue = this.value; - this.value = value; - if (this.user) { - try { - this.cb.call(this.vm, value, oldValue); - } catch (e) { - /* istanbul ignore else */ - if (config.errorHandler) { - config.errorHandler.call(null, e, this.vm); - } else { - process.env.NODE_ENV !== 'production' && warn( - ("Error in watcher \"" + (this.expression) + "\""), - this.vm - ); - throw e - } - } - } else { - this.cb.call(this.vm, value, oldValue); - } - } - } - }; - - /** - * Evaluate the value of the watcher. - * This only gets called for lazy watchers. - */ - Watcher.prototype.evaluate = function evaluate () { - this.value = this.get(); - this.dirty = false; - }; - - /** - * Depend on all deps collected by this watcher. - */ - Watcher.prototype.depend = function depend () { - var this$1 = this; - - var i = this.deps.length; - while (i--) { - this$1.deps[i].depend(); - } - }; - - /** - * Remove self from all dependencies' subscriber list. - */ - Watcher.prototype.teardown = function teardown () { - var this$1 = this; - - if (this.active) { - // remove self from vm's watcher list - // this is a somewhat expensive operation so we skip it - // if the vm is being destroyed or is performing a v-for - // re-render (the watcher list is then filtered by v-for). - if (!this.vm._isBeingDestroyed && !this.vm._vForRemoving) { - remove$1(this.vm._watchers, this); - } - var i = this.deps.length; - while (i--) { - this$1.deps[i].removeSub(this$1); - } - this.active = false; - } - }; - - /** - * Recursively traverse an object to evoke all converted - * getters, so that every nested property inside the object - * is collected as a "deep" dependency. - */ - var seenObjects = new _Set(); - function traverse (val) { - seenObjects.clear(); - _traverse(val, seenObjects); - } - - function _traverse (val, seen) { - var i, keys; - var isA = Array.isArray(val); - if ((!isA && !isObject(val)) || !Object.isExtensible(val)) { - return - } - if (val.__ob__) { - var depId = val.__ob__.dep.id; - if (seen.has(depId)) { - return - } - seen.add(depId); - } - if (isA) { - i = val.length; - while (i--) { _traverse(val[i], seen); } - } else { - keys = Object.keys(val); - i = keys.length; - while (i--) { _traverse(val[keys[i]], seen); } - } - } - - /* */ - - function initState (vm) { - vm._watchers = []; - initProps(vm); - initMethods(vm); - initData(vm); - initComputed(vm); - initWatch(vm); - } - - var isReservedProp = { key: 1, ref: 1, slot: 1 }; - - function initProps (vm) { - var props = vm.$options.props; - if (props) { - var propsData = vm.$options.propsData || {}; - var keys = vm.$options._propKeys = Object.keys(props); - var isRoot = !vm.$parent; - // root instance props should be converted - observerState.shouldConvert = isRoot; - var loop = function ( i ) { - var key = keys[i]; - /* istanbul ignore else */ - if (process.env.NODE_ENV !== 'production') { - if (isReservedProp[key]) { - warn( - ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."), - vm - ); - } - defineReactive$$1(vm, key, validateProp(key, props, propsData, vm), function () { - if (vm.$parent && !observerState.isSettingProps) { - warn( - "Avoid mutating a prop directly since the value will be " + - "overwritten whenever the parent component re-renders. " + - "Instead, use a data or computed property based on the prop's " + - "value. Prop being mutated: \"" + key + "\"", - vm - ); - } - }); - } else { - defineReactive$$1(vm, key, validateProp(key, props, propsData, vm)); - } - }; - - for (var i = 0; i < keys.length; i++) loop( i ); - observerState.shouldConvert = true; - } - } - - function initData (vm) { - var data = vm.$options.data; - data = vm._data = typeof data === 'function' - ? data.call(vm) - : data || {}; - if (!isPlainObject(data)) { - data = {}; - process.env.NODE_ENV !== 'production' && warn( - 'data functions should return an object:\n' + - 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', - vm - ); - } - // proxy data on instance - var keys = Object.keys(data); - var props = vm.$options.props; - var i = keys.length; - while (i--) { - if (props && hasOwn(props, keys[i])) { - process.env.NODE_ENV !== 'production' && warn( - "The data property \"" + (keys[i]) + "\" is already declared as a prop. " + - "Use prop default value instead.", - vm - ); - } else { - proxy(vm, keys[i]); - } - } - // observe data - observe(data); - data.__ob__ && data.__ob__.vmCount++; - } - - var computedSharedDefinition = { - enumerable: true, - configurable: true, - get: noop, - set: noop - }; - - function initComputed (vm) { - var computed = vm.$options.computed; - if (computed) { - for (var key in computed) { - var userDef = computed[key]; - if (typeof userDef === 'function') { - computedSharedDefinition.get = makeComputedGetter(userDef, vm); - computedSharedDefinition.set = noop; - } else { - computedSharedDefinition.get = userDef.get - ? userDef.cache !== false - ? makeComputedGetter(userDef.get, vm) - : bind$1(userDef.get, vm) - : noop; - computedSharedDefinition.set = userDef.set - ? bind$1(userDef.set, vm) - : noop; - } - Object.defineProperty(vm, key, computedSharedDefinition); - } - } - } - - function makeComputedGetter (getter, owner) { - var watcher = new Watcher(owner, getter, noop, { - lazy: true - }); - return function computedGetter () { - if (watcher.dirty) { - watcher.evaluate(); - } - if (Dep.target) { - watcher.depend(); - } - return watcher.value - } - } - - function initMethods (vm) { - var methods = vm.$options.methods; - if (methods) { - for (var key in methods) { - vm[key] = methods[key] == null ? noop : bind$1(methods[key], vm); - if (process.env.NODE_ENV !== 'production' && methods[key] == null) { - warn( - "method \"" + key + "\" has an undefined value in the component definition. " + - "Did you reference the function correctly?", - vm - ); - } - } - } - } - - function initWatch (vm) { - var watch = vm.$options.watch; - if (watch) { - for (var key in watch) { - var handler = watch[key]; - if (Array.isArray(handler)) { - for (var i = 0; i < handler.length; i++) { - createWatcher(vm, key, handler[i]); - } - } else { - createWatcher(vm, key, handler); - } - } - } - } - - function createWatcher (vm, key, handler) { - var options; - if (isPlainObject(handler)) { - options = handler; - handler = handler.handler; - } - if (typeof handler === 'string') { - handler = vm[handler]; - } - vm.$watch(key, handler, options); - } - - function stateMixin (Vue) { - // flow somehow has problems with directly declared definition object - // when using Object.defineProperty, so we have to procedurally build up - // the object here. - var dataDef = {}; - dataDef.get = function () { - return this._data - }; - if (process.env.NODE_ENV !== 'production') { - dataDef.set = function (newData) { - warn( - 'Avoid replacing instance root $data. ' + - 'Use nested data properties instead.', - this - ); - }; - } - Object.defineProperty(Vue.prototype, '$data', dataDef); - - Vue.prototype.$set = set$1; - Vue.prototype.$delete = del; - - Vue.prototype.$watch = function ( - expOrFn, - cb, - options - ) { - var vm = this; - options = options || {}; - options.user = true; - var watcher = new Watcher(vm, expOrFn, cb, options); - if (options.immediate) { - cb.call(vm, watcher.value); - } - return function unwatchFn () { - watcher.teardown(); - } - }; - } - - function proxy (vm, key) { - if (!isReserved(key)) { - Object.defineProperty(vm, key, { - configurable: true, - enumerable: true, - get: function proxyGetter () { - return vm._data[key] - }, - set: function proxySetter (val) { - vm._data[key] = val; - } - }); - } - } - - /* */ - var VNode = function VNode ( tag, data, @@ -2292,7 +1731,7 @@ return /******/ (function(modules) { // webpackBootstrap this.functionalContext = undefined; this.key = data && data.key; this.componentOptions = componentOptions; - this.child = undefined; + this.componentInstance = undefined; this.parent = undefined; this.raw = false; this.isStatic = false; @@ -2302,6 +1741,16 @@ return /******/ (function(modules) { // webpackBootstrap this.isOnce = false; }; + var prototypeAccessors = { child: {} }; + + // DEPRECATED: alias for componentInstance for backwards compat. + /* istanbul ignore next */ + prototypeAccessors.child.get = function () { + return this.componentInstance + }; + + Object.defineProperties( VNode.prototype, prototypeAccessors ); + var createEmptyVNode = function () { var node = new VNode(); node.text = ''; @@ -2344,215 +1793,6 @@ return /******/ (function(modules) { // webpackBootstrap /* */ - var activeInstance = null; - - function initLifecycle (vm) { - var options = vm.$options; - - // locate first non-abstract parent - var parent = options.parent; - if (parent && !options.abstract) { - while (parent.$options.abstract && parent.$parent) { - parent = parent.$parent; - } - parent.$children.push(vm); - } - - vm.$parent = parent; - vm.$root = parent ? parent.$root : vm; - - vm.$children = []; - vm.$refs = {}; - - vm._watcher = null; - vm._inactive = false; - vm._isMounted = false; - vm._isDestroyed = false; - vm._isBeingDestroyed = false; - } - - function lifecycleMixin (Vue) { - Vue.prototype._mount = function ( - el, - hydrating - ) { - var vm = this; - vm.$el = el; - if (!vm.$options.render) { - vm.$options.render = createEmptyVNode; - if (process.env.NODE_ENV !== 'production') { - /* istanbul ignore if */ - if (vm.$options.template && vm.$options.template.charAt(0) !== '#') { - warn( - 'You are using the runtime-only build of Vue where the template ' + - 'option is not available. Either pre-compile the templates into ' + - 'render functions, or use the compiler-included build.', - vm - ); - } else { - warn( - 'Failed to mount component: template or render function not defined.', - vm - ); - } - } - } - callHook(vm, 'beforeMount'); - vm._watcher = new Watcher(vm, function () { - vm._update(vm._render(), hydrating); - }, noop); - hydrating = false; - // manually mounted instance, call mounted on self - // mounted is called for render-created child components in its inserted hook - if (vm.$vnode == null) { - vm._isMounted = true; - callHook(vm, 'mounted'); - } - return vm - }; - - Vue.prototype._update = function (vnode, hydrating) { - var vm = this; - if (vm._isMounted) { - callHook(vm, 'beforeUpdate'); - } - var prevEl = vm.$el; - var prevVnode = vm._vnode; - var prevActiveInstance = activeInstance; - activeInstance = vm; - vm._vnode = vnode; - // Vue.prototype.__patch__ is injected in entry points - // based on the rendering backend used. - if (!prevVnode) { - // initial render - vm.$el = vm.__patch__( - vm.$el, vnode, hydrating, false /* removeOnly */, - vm.$options._parentElm, - vm.$options._refElm - ); - } else { - // updates - vm.$el = vm.__patch__(prevVnode, vnode); - } - activeInstance = prevActiveInstance; - // update __vue__ reference - if (prevEl) { - prevEl.__vue__ = null; - } - if (vm.$el) { - vm.$el.__vue__ = vm; - } - // if parent is an HOC, update its $el as well - if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { - vm.$parent.$el = vm.$el; - } - if (vm._isMounted) { - callHook(vm, 'updated'); - } - }; - - Vue.prototype._updateFromParent = function ( - propsData, - listeners, - parentVnode, - renderChildren - ) { - var vm = this; - var hasChildren = !!(vm.$options._renderChildren || renderChildren); - vm.$options._parentVnode = parentVnode; - vm.$vnode = parentVnode; // update vm's placeholder node without re-render - if (vm._vnode) { // update child tree's parent - vm._vnode.parent = parentVnode; - } - vm.$options._renderChildren = renderChildren; - // update props - if (propsData && vm.$options.props) { - observerState.shouldConvert = false; - if (process.env.NODE_ENV !== 'production') { - observerState.isSettingProps = true; - } - var propKeys = vm.$options._propKeys || []; - for (var i = 0; i < propKeys.length; i++) { - var key = propKeys[i]; - vm[key] = validateProp(key, vm.$options.props, propsData, vm); - } - observerState.shouldConvert = true; - if (process.env.NODE_ENV !== 'production') { - observerState.isSettingProps = false; - } - vm.$options.propsData = propsData; - } - // update listeners - if (listeners) { - var oldListeners = vm.$options._parentListeners; - vm.$options._parentListeners = listeners; - vm._updateListeners(listeners, oldListeners); - } - // resolve slots + force update if has children - if (hasChildren) { - vm.$slots = resolveSlots(renderChildren, parentVnode.context); - vm.$forceUpdate(); - } - }; - - Vue.prototype.$forceUpdate = function () { - var vm = this; - if (vm._watcher) { - vm._watcher.update(); - } - }; - - Vue.prototype.$destroy = function () { - var vm = this; - if (vm._isBeingDestroyed) { - return - } - callHook(vm, 'beforeDestroy'); - vm._isBeingDestroyed = true; - // remove self from parent - var parent = vm.$parent; - if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { - remove$1(parent.$children, vm); - } - // teardown watchers - if (vm._watcher) { - vm._watcher.teardown(); - } - var i = vm._watchers.length; - while (i--) { - vm._watchers[i].teardown(); - } - // remove reference from data ob - // frozen object may not have observer. - if (vm._data.__ob__) { - vm._data.__ob__.vmCount--; - } - // call the last hook... - vm._isDestroyed = true; - callHook(vm, 'destroyed'); - // turn off all instance listeners. - vm.$off(); - // remove __vue__ reference - if (vm.$el) { - vm.$el.__vue__ = null; - } - // invoke destroy hooks on current rendered tree - vm.__patch__(vm._vnode, null); - }; - } - - function callHook (vm, hook) { - var handlers = vm.$options[hook]; - if (handlers) { - for (var i = 0, j = handlers.length; i < j; i++) { - handlers[i].call(vm); - } - } - vm.$emit('hook:' + hook); - } - - /* */ - var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy$1 }; var hooksToMerge = Object.keys(hooks); @@ -2703,8 +1943,8 @@ return /******/ (function(modules) { // webpackBootstrap parentElm, refElm ) { - if (!vnode.child || vnode.child._isDestroyed) { - var child = vnode.child = createComponentInstanceForVnode( + if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) { + var child = vnode.componentInstance = createComponentInstanceForVnode( vnode, activeInstance, parentElm, @@ -2723,7 +1963,7 @@ return /******/ (function(modules) { // webpackBootstrap vnode ) { var options = vnode.componentOptions; - var child = vnode.child = oldVnode.child; + var child = vnode.componentInstance = oldVnode.componentInstance; child._updateFromParent( options.propsData, // updated props options.listeners, // updated listeners @@ -2733,23 +1973,23 @@ return /******/ (function(modules) { // webpackBootstrap } function insert (vnode) { - if (!vnode.child._isMounted) { - vnode.child._isMounted = true; - callHook(vnode.child, 'mounted'); + if (!vnode.componentInstance._isMounted) { + vnode.componentInstance._isMounted = true; + callHook(vnode.componentInstance, 'mounted'); } if (vnode.data.keepAlive) { - vnode.child._inactive = false; - callHook(vnode.child, 'activated'); + vnode.componentInstance._inactive = false; + callHook(vnode.componentInstance, 'activated'); } } function destroy$1 (vnode) { - if (!vnode.child._isDestroyed) { + if (!vnode.componentInstance._isDestroyed) { if (!vnode.data.keepAlive) { - vnode.child.$destroy(); + vnode.componentInstance.$destroy(); } else { - vnode.child._inactive = true; - callHook(vnode.child, 'deactivated'); + vnode.componentInstance._inactive = true; + callHook(vnode.componentInstance, 'deactivated'); } } } @@ -2890,6 +2130,37 @@ return /******/ (function(modules) { // webpackBootstrap /* */ + var normalizeEvent = cached(function (name) { + var once = name.charAt(0) === '~'; // Prefixed last, checked first + name = once ? name.slice(1) : name; + var capture = name.charAt(0) === '!'; + name = capture ? name.slice(1) : name; + return { + name: name, + once: once, + capture: capture + } + }); + + function createEventHandle (fn) { + var handle = { + fn: fn, + invoker: function () { + var arguments$1 = arguments; + + var fn = handle.fn; + if (Array.isArray(fn)) { + for (var i = 0; i < fn.length; i++) { + fn[i].apply(null, arguments$1); + } + } else { + fn.apply(null, arguments); + } + } + }; + return handle + } + function updateListeners ( on, oldOn, @@ -2897,73 +2168,61 @@ return /******/ (function(modules) { // webpackBootstrap remove$$1, vm ) { - var name, cur, old, fn, event, capture, once; + var name, cur, old, event; for (name in on) { cur = on[name]; old = oldOn[name]; + event = normalizeEvent(name); if (!cur) { process.env.NODE_ENV !== 'production' && warn( - "Invalid handler for event \"" + name + "\": got " + String(cur), + "Invalid handler for event \"" + (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); + if (!cur.invoker) { + cur = on[name] = createEventHandle(cur); } + add(event.name, cur.invoker, event.once, event.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; - } + 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); + event = normalizeEvent(name); + remove$$1(event.name, oldOn[name].invoker, event.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. 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.