From e917a891c4aecccfd93a7ca776f827d33d89a13d Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 16 Jan 2017 18:48:06 -0500 Subject: [PATCH] [build] 2.1.9 --- dist/vue.common.js | 2833 ++++++++-------- dist/vue.js | 2833 ++++++++-------- dist/vue.min.js | 10 +- dist/vue.runtime.common.js | 2762 ++++++++-------- dist/vue.runtime.js | 2762 ++++++++-------- dist/vue.runtime.min.js | 8 +- packages/vue-server-renderer/build.js | 3259 +++++++++---------- packages/vue-server-renderer/package.json | 2 +- packages/vue-template-compiler/build.js | 3237 +++++++++--------- packages/vue-template-compiler/package.json | 2 +- 10 files changed, 8960 insertions(+), 8748 deletions(-) diff --git a/dist/vue.common.js b/dist/vue.common.js index 2fea0f33c..6d50356d7 100644 --- a/dist/vue.common.js +++ b/dist/vue.common.js @@ -1,6 +1,6 @@ /*! - * Vue.js v2.1.8 - * (c) 2014-2016 Evan You + * Vue.js v2.1.9 + * (c) 2014-2017 Evan You * Released under the MIT License. */ 'use strict'; @@ -23,8 +23,8 @@ function _toString (val) { * 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 } /** @@ -89,7 +89,7 @@ function cached (fn) { } /** - * Camelize a hyphen-delmited string. + * Camelize a hyphen-delimited string. */ var camelizeRE = /-(\w)/g; var camelize = cached(function (str) { @@ -1499,6 +1499,1268 @@ if (process.env.NODE_ENV !== 'production') { /* */ +var VNode = function VNode ( + tag, + data, + children, + text, + elm, + context, + componentOptions +) { + this.tag = tag; + this.data = data; + this.children = children; + this.text = text; + this.elm = elm; + this.ns = undefined; + this.context = context; + this.functionalContext = undefined; + this.key = data && data.key; + this.componentOptions = componentOptions; + this.componentInstance = undefined; + this.parent = undefined; + this.raw = false; + this.isStatic = false; + this.isRootInsert = true; + this.isComment = false; + this.isCloned = false; + 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 = ''; + node.isComment = true; + return node +}; + +function createTextVNode (val) { + return new VNode(undefined, undefined, undefined, String(val)) +} + +// optimized shallow clone +// used for static nodes and slot nodes because they may be reused across +// multiple renders, cloning them avoids errors when DOM manipulations rely +// on their elm reference. +function cloneVNode (vnode) { + var cloned = new VNode( + vnode.tag, + vnode.data, + vnode.children, + vnode.text, + vnode.elm, + vnode.context, + vnode.componentOptions + ); + cloned.ns = vnode.ns; + cloned.isStatic = vnode.isStatic; + cloned.key = vnode.key; + cloned.isCloned = true; + return cloned +} + +function cloneVNodes (vnodes) { + var res = new Array(vnodes.length); + for (var i = 0; i < vnodes.length; i++) { + res[i] = cloneVNode(vnodes[i]); + } + return res +} + +/* */ + +var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy$1 }; +var hooksToMerge = Object.keys(hooks); + +function createComponent ( + Ctor, + data, + context, + children, + tag +) { + if (!Ctor) { + return + } + + var baseCtor = context.$options._base; + if (isObject(Ctor)) { + Ctor = baseCtor.extend(Ctor); + } + + if (typeof Ctor !== 'function') { + if (process.env.NODE_ENV !== 'production') { + warn(("Invalid Component definition: " + (String(Ctor))), context); + } + return + } + + // async component + if (!Ctor.cid) { + if (Ctor.resolved) { + Ctor = Ctor.resolved; + } else { + Ctor = resolveAsyncComponent(Ctor, baseCtor, function () { + // it's ok to queue this on every render because + // $forceUpdate is buffered by the scheduler. + context.$forceUpdate(); + }); + if (!Ctor) { + // return nothing if this is indeed an async component + // wait for the callback to trigger parent update. + return + } + } + } + + // resolve constructor options in case global mixins are applied after + // component constructor creation + resolveConstructorOptions(Ctor); + + data = data || {}; + + // extract props + var propsData = extractProps(data, Ctor); + + // functional component + if (Ctor.options.functional) { + return createFunctionalComponent(Ctor, propsData, data, context, children) + } + + // extract listeners, since these needs to be treated as + // child component listeners instead of DOM listeners + var listeners = data.on; + // replace with listeners with .native modifier + data.on = data.nativeOn; + + if (Ctor.options.abstract) { + // abstract components do not keep anything + // other than props & listeners + data = {}; + } + + // merge component management hooks onto the placeholder node + mergeHooks(data); + + // return a placeholder vnode + var name = Ctor.options.name || tag; + var vnode = new VNode( + ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), + data, undefined, undefined, undefined, context, + { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children } + ); + return vnode +} + +function createFunctionalComponent ( + Ctor, + propsData, + data, + context, + children +) { + var props = {}; + var propOptions = Ctor.options.props; + if (propOptions) { + for (var key in propOptions) { + props[key] = validateProp(key, propOptions, propsData); + } + } + // ensure the createElement function in functional components + // gets a unique context - this is necessary for correct named slot check + var _context = Object.create(context); + var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); }; + var vnode = Ctor.options.render.call(null, h, { + props: props, + data: data, + parent: context, + children: children, + slots: function () { return resolveSlots(children, context); } + }); + if (vnode instanceof VNode) { + vnode.functionalContext = context; + if (data.slot) { + (vnode.data || (vnode.data = {})).slot = data.slot; + } + } + return vnode +} + +function createComponentInstanceForVnode ( + vnode, // we know it's MountedComponentVNode but flow doesn't + parent, // activeInstance in lifecycle state + parentElm, + refElm +) { + var vnodeComponentOptions = vnode.componentOptions; + var options = { + _isComponent: true, + parent: parent, + propsData: vnodeComponentOptions.propsData, + _componentTag: vnodeComponentOptions.tag, + _parentVnode: vnode, + _parentListeners: vnodeComponentOptions.listeners, + _renderChildren: vnodeComponentOptions.children, + _parentElm: parentElm || null, + _refElm: refElm || null + }; + // check inline-template render functions + var inlineTemplate = vnode.data.inlineTemplate; + if (inlineTemplate) { + options.render = inlineTemplate.render; + options.staticRenderFns = inlineTemplate.staticRenderFns; + } + return new vnodeComponentOptions.Ctor(options) +} + +function init ( + vnode, + hydrating, + parentElm, + refElm +) { + if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) { + var child = vnode.componentInstance = createComponentInstanceForVnode( + vnode, + activeInstance, + parentElm, + refElm + ); + child.$mount(hydrating ? vnode.elm : undefined, hydrating); + } else if (vnode.data.keepAlive) { + // kept-alive components, treat as a patch + var mountedNode = vnode; // work around flow + prepatch(mountedNode, mountedNode); + } +} + +function prepatch ( + oldVnode, + vnode +) { + var options = vnode.componentOptions; + var child = vnode.componentInstance = oldVnode.componentInstance; + child._updateFromParent( + options.propsData, // updated props + options.listeners, // updated listeners + vnode, // new parent vnode + options.children // new children + ); +} + +function insert (vnode) { + if (!vnode.componentInstance._isMounted) { + vnode.componentInstance._isMounted = true; + callHook(vnode.componentInstance, 'mounted'); + } + if (vnode.data.keepAlive) { + vnode.componentInstance._inactive = false; + callHook(vnode.componentInstance, 'activated'); + } +} + +function destroy$1 (vnode) { + if (!vnode.componentInstance._isDestroyed) { + if (!vnode.data.keepAlive) { + vnode.componentInstance.$destroy(); + } else { + vnode.componentInstance._inactive = true; + callHook(vnode.componentInstance, 'deactivated'); + } + } +} + +function resolveAsyncComponent ( + factory, + baseCtor, + cb +) { + if (factory.requested) { + // pool callbacks + factory.pendingCallbacks.push(cb); + } else { + factory.requested = true; + var cbs = factory.pendingCallbacks = [cb]; + var sync = true; + + var resolve = function (res) { + if (isObject(res)) { + res = baseCtor.extend(res); + } + // cache resolved + factory.resolved = res; + // invoke callbacks only if this is not a synchronous resolve + // (async resolves are shimmed as synchronous during SSR) + if (!sync) { + for (var i = 0, l = cbs.length; i < l; i++) { + cbs[i](res); + } + } + }; + + var reject = function (reason) { + process.env.NODE_ENV !== 'production' && warn( + "Failed to resolve async component: " + (String(factory)) + + (reason ? ("\nReason: " + reason) : '') + ); + }; + + var res = factory(resolve, reject); + + // handle promise + if (res && typeof res.then === 'function' && !factory.resolved) { + res.then(resolve, reject); + } + + sync = false; + // return in case resolved synchronously + return factory.resolved + } +} + +function extractProps (data, Ctor) { + // we are only extracting raw values here. + // validation and default values are handled in the child + // component itself. + var propOptions = Ctor.options.props; + if (!propOptions) { + return + } + var res = {}; + var attrs = data.attrs; + var props = data.props; + var domProps = data.domProps; + if (attrs || props || domProps) { + for (var key in propOptions) { + var altKey = hyphenate(key); + checkProp(res, props, key, altKey, true) || + checkProp(res, attrs, key, altKey) || + checkProp(res, domProps, key, altKey); + } + } + return res +} + +function checkProp ( + res, + hash, + key, + altKey, + preserve +) { + if (hash) { + if (hasOwn(hash, key)) { + res[key] = hash[key]; + if (!preserve) { + delete hash[key]; + } + return true + } else if (hasOwn(hash, altKey)) { + res[key] = hash[altKey]; + if (!preserve) { + delete hash[altKey]; + } + return true + } + } + return false +} + +function mergeHooks (data) { + if (!data.hook) { + data.hook = {}; + } + for (var i = 0; i < hooksToMerge.length; i++) { + var key = hooksToMerge[i]; + var fromParent = data.hook[key]; + var ours = hooks[key]; + data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours; + } +} + +function mergeHook$1 (one, two) { + return function (a, b, c, d) { + one(a, b, c, d); + two(a, b, c, d); + } +} + +/* */ + +function mergeVNodeHook (def, hookKey, hook, key) { + key = key + hookKey; + var injectedHash = def.__injected || (def.__injected = {}); + if (!injectedHash[key]) { + injectedHash[key] = true; + var oldHook = def[hookKey]; + if (oldHook) { + def[hookKey] = function () { + oldHook.apply(this, arguments); + hook.apply(this, arguments); + }; + } else { + def[hookKey] = hook; + } + } +} + +/* */ + +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, + add, + remove$$1, + vm +) { + 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 \"" + (event.name) + "\": got " + String(cur), + vm + ); + } else if (!old) { + if (!cur.invoker) { + cur = on[name] = createEventHandle(cur); + } + add(event.name, cur.invoker, event.once, event.capture); + } else if (cur !== old) { + old.fn = cur; + on[name] = old; + } + } + for (name in oldOn) { + if (!on[name]) { + event = normalizeEvent(name); + remove$$1(event.name, oldOn[name].invoker, event.capture); + } + } +} + +/* */ + +// 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.