diff --git a/benchmarks/ssr/renderToStream.js b/benchmarks/ssr/renderToStream.js index e068d94c6ac..6fbcfd20965 100644 --- a/benchmarks/ssr/renderToStream.js +++ b/benchmarks/ssr/renderToStream.js @@ -1,3 +1,5 @@ +/* eslint-disable no-unused-vars */ + 'use strict' const Vue = require('../../dist/vue.runtime.common.js') @@ -7,20 +9,21 @@ const gridComponent = require('./common.js') console.log('--- renderToStream --- ') const self = (global || root) -self.s = self.performance.now() +const s = self.performance.now() const stream = renderToStream(new Vue(gridComponent)) let str = '' -const stats = [] +let first +let complete +stream.once('data', () => { + first = self.performance.now() - s +}) stream.on('data', chunk => { str += chunk - stats.push(self.performance.now()) }) stream.on('end', () => { - stats.push(self.performance.now()) - stats.forEach((val, index) => { - const type = index !== stats.length - 1 ? 'Chunk' : 'Complete' - console.log(type + ' time: ' + (val - self.s).toFixed(2) + 'ms') - }) + complete = self.performance.now() - s + console.log(`first chunk: ${first.toFixed(2)}ms`) + console.log(`complete: ${complete.toFixed(2)}ms`) console.log() }) diff --git a/build/build.js b/build/build.js index 5aee4484d4e..b9cb997e026 100644 --- a/build/build.js +++ b/build/build.js @@ -8,20 +8,6 @@ if (!fs.existsSync('dist')) { fs.mkdirSync('dist') } -// Update main file -const version = process.env.VERSION || require('../package.json').version -const main = fs - .readFileSync('src/core/index.js', 'utf-8') - .replace(/Vue\.version = '[^']+'/, "Vue.version = '" + version + "'") -fs.writeFileSync('src/core/index.js', main) - -// update weex subversion -const weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version -const weexMain = fs - .readFileSync('src/entries/weex-framework.js', 'utf-8') - .replace(/Vue\.version = '[^']+'/, "Vue.version = '" + weexVersion + "'") -fs.writeFileSync('src/entries/weex-framework.js', weexMain) - let builds = require('./config').getAllBuilds() // filter builds via command line arg diff --git a/build/config.js b/build/config.js index 042c455dff7..026a962a597 100644 --- a/build/config.js +++ b/build/config.js @@ -4,6 +4,7 @@ const buble = require('rollup-plugin-buble') const replace = require('rollup-plugin-replace') const alias = require('rollup-plugin-alias') const version = process.env.VERSION || require('../package.json').version +const weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version const banner = '/*!\n' + @@ -103,7 +104,9 @@ function genConfig (opts) { moduleName: 'Vue', plugins: [ replace({ - __WEEX__: !!opts.weex + __WEEX__: !!opts.weex, + __WEEX_VERSION__: weexVersion, + __VERSION__: version }), flow(), buble(), diff --git a/build/karma.cover.config.js b/build/karma.cover.config.js index c030035709c..c70a8ec5f64 100644 --- a/build/karma.cover.config.js +++ b/build/karma.cover.config.js @@ -15,8 +15,8 @@ module.exports = function (config) { // add babel-plugin-coverage for code intrumentation options.webpack.babel = { - plugins: [['coverage', { - ignore: [ + plugins: [['istanbul', { + exclude: [ 'test/', 'src/compiler/parser/html-parser.js', 'src/core/instance/proxy.js', diff --git a/dist/vue.common.js b/dist/vue.common.js index 90b74248546..6c89462f960 100644 --- a/dist/vue.common.js +++ b/dist/vue.common.js @@ -1,5 +1,5 @@ /*! - * Vue.js v2.1.4 + * Vue.js v2.1.5 * (c) 2014-2016 Evan You * Released under the MIT License. */ @@ -196,6 +196,11 @@ function noop () {} */ var no = function () { return false; }; +/** + * Return same value + */ +var identity = function (_) { return _; }; + /** * Generate a static keys string from compiler modules. */ @@ -276,6 +281,11 @@ var config = { */ getTagNamespace: noop, + /** + * Parse the real tag name for the specific platform. + */ + parsePlatformTagName: identity, + /** * Check if an attribute must be bound using property, e.g. value * Platform-dependent. @@ -485,10 +495,10 @@ if (typeof Set !== 'undefined' && isNative(Set)) { this.set = Object.create(null); } Set.prototype.has = function has (key) { - return this.set[key] !== undefined + return this.set[key] === true }; Set.prototype.add = function add (key) { - this.set[key] = 1; + this.set[key] = true; }; Set.prototype.clear = function clear () { this.set = Object.create(null); @@ -706,9 +716,8 @@ function protoAugment (target, src) { /** * Augment an target Object or Array by defining * hidden properties. - * - * istanbul ignore next */ +/* istanbul ignore next */ function copyAugment (target, src, keys) { for (var i = 0, l = keys.length; i < l; i++) { var key = keys[i]; @@ -1174,11 +1183,14 @@ function resolveAsset ( return } var assets = options[type]; - var res = assets[id] || - // camelCase ID - assets[camelize(id)] || - // Pascal Case ID - assets[capitalize(camelize(id))]; + // check local registration variations first + if (hasOwn(assets, id)) { return assets[id] } + var camelizedId = camelize(id); + if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } + var PascalCaseId = capitalize(camelizedId); + if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } + // fallback to prototype chain + var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; if (process.env.NODE_ENV !== 'production' && warnMissing && !res) { warn( 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, @@ -1380,6 +1392,7 @@ var util = Object.freeze({ toObject: toObject, noop: noop, no: no, + identity: identity, genStaticKeys: genStaticKeys, looseEqual: looseEqual, looseIndexOf: looseIndexOf, @@ -1876,7 +1889,8 @@ function initData (vm) { if (!isPlainObject(data)) { data = {}; process.env.NODE_ENV !== 'production' && warn( - 'data functions should return an object.', + 'data functions should return an object:\n' + + 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm ); } @@ -2052,7 +2066,6 @@ var VNode = function VNode ( children, text, elm, - ns, context, componentOptions ) { @@ -2061,7 +2074,7 @@ var VNode = function VNode ( this.children = children; this.text = text; this.elm = elm; - this.ns = ns; + this.ns = undefined; this.context = context; this.functionalContext = undefined; this.key = data && data.key; @@ -2076,13 +2089,17 @@ var VNode = function VNode ( this.isOnce = false; }; -var emptyVNode = function () { +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 @@ -2094,10 +2111,10 @@ function cloneVNode (vnode) { vnode.children, vnode.text, vnode.elm, - vnode.ns, vnode.context, vnode.componentOptions ); + cloned.ns = vnode.ns; cloned.isStatic = vnode.isStatic; cloned.key = vnode.key; cloned.isCloned = true; @@ -2114,167 +2131,6 @@ function cloneVNodes (vnodes) { /* */ -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; - } - } -} - -/* */ - -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, - ns, - nestedIndex -) { - if (isPrimitive(children)) { - return [createTextVNode(children)] - } - if (Array.isArray(children)) { - var res = []; - for (var i = 0, l = children.length; i < l; i++) { - var c = children[i]; - var last = res[res.length - 1]; - // nested - if (Array.isArray(c)) { - res.push.apply(res, normalizeChildren(c, ns, ((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 instanceof VNode) { - if (c.text && last && last.text) { - if (!last.isCloned) { - last.text += c.text; - } - } else { - // inherit parent namespace - if (ns) { - applyNS(c, ns); - } - // 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 createTextVNode (val) { - return new VNode(undefined, undefined, undefined, String(val)) -} - -function applyNS (vnode, ns) { - if (vnode.tag && !vnode.ns) { - vnode.ns = ns; - if (vnode.children) { - for (var i = 0, l = vnode.children.length; i < l; i++) { - applyNS(vnode.children[i], ns); - } - } - } -} - -/* */ - -function getFirstComponentChild (children) { - return children && children.filter(function (c) { return c && c.componentOptions; })[0] -} - -/* */ - var activeInstance = null; function initLifecycle (vm) { @@ -2310,7 +2166,7 @@ function lifecycleMixin (Vue) { var vm = this; vm.$el = el; if (!vm.$options.render) { - vm.$options.render = emptyVNode; + vm.$options.render = createEmptyVNode; if (process.env.NODE_ENV !== 'production') { /* istanbul ignore if */ if (vm.$options.template && vm.$options.template.charAt(0) !== '#') { @@ -2561,7 +2417,7 @@ function createComponent ( var name = Ctor.options.name || tag; var vnode = new VNode( ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), - data, undefined, undefined, undefined, undefined, context, + data, undefined, undefined, undefined, context, { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children } ); return vnode @@ -2581,19 +2437,17 @@ function createFunctionalComponent ( props[key] = validateProp(key, propOptions, propsData); } } - var vnode = Ctor.options.render.call( - null, - // ensure the createElement function in functional components - // gets a unique context - this is necessary for correct named slot check - bind$1(createElement, { _self: Object.create(context) }), - { - props: props, - data: data, - parent: context, - children: normalizeChildren(children), - slots: function () { return resolveSlots(children, context); } - } - ); + // 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) { @@ -2804,26 +2658,172 @@ function mergeHook$1 (one, two) { /* */ +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; + } + } +} + +/* */ + +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) { 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 getFirstComponentChild (children) { + return children && children.filter(function (c) { return c && c.componentOptions; })[0] +} + +/* */ + // wrapper function for providing a more flexible interface // without getting yelled at by flow function createElement ( + context, tag, data, - children + children, + needNormalization, + alwaysNormalize ) { - if (data && (Array.isArray(data) || typeof data !== 'object')) { + if (Array.isArray(data) || isPrimitive(data)) { + needNormalization = children; children = data; data = undefined; } - // make sure to use real instance instead of proxy as context - return _createElement(this._self, tag, data, children) + if (alwaysNormalize) { needNormalization = true; } + return _createElement(context, tag, data, children, needNormalization) } function _createElement ( context, tag, data, - children + children, + needNormalization ) { if (data && data.__ob__) { process.env.NODE_ENV !== 'production' && warn( @@ -2831,11 +2831,11 @@ function _createElement ( 'Always create fresh vnode data objects in each render!', context ); - return + return createEmptyVNode() } if (!tag) { // in case of component :is set to falsy value - return emptyVNode() + return createEmptyVNode() } // support single function children as default scoped slot if (Array.isArray(children) && @@ -2844,31 +2844,53 @@ function _createElement ( data.scopedSlots = { default: children[0] }; children.length = 0; } + if (needNormalization) { + children = normalizeChildren(children); + } + var vnode, ns; if (typeof tag === 'string') { var Ctor; - var ns = config.getTagNamespace(tag); + ns = config.getTagNamespace(tag); if (config.isReservedTag(tag)) { // platform built-in elements - return new VNode( - tag, data, normalizeChildren(children, ns), - undefined, undefined, ns, context - ) + vnode = new VNode( + config.parsePlatformTagName(tag), data, children, + undefined, undefined, context + ); } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) { // component - return createComponent(Ctor, data, context, children, tag) + vnode = createComponent(Ctor, data, context, children, tag); } else { // unknown or unlisted namespaced elements // check at runtime because it may get assigned a namespace when its // parent normalizes children - var childNs = tag === 'foreignObject' ? 'xhtml' : ns; - return new VNode( - tag, data, normalizeChildren(children, childNs), - undefined, undefined, ns, context - ) + ns = tag === 'foreignObject' ? 'xhtml' : ns; + vnode = new VNode( + tag, data, children, + undefined, undefined, context + ); } } else { // direct component options / constructor - return createComponent(tag, data, context, children) + vnode = createComponent(tag, data, context, children); + } + if (vnode) { + if (ns) { applyNS(vnode, ns); } + return vnode + } else { + return createEmptyVNode() + } +} + +function applyNS (vnode, ns) { + vnode.ns = ns; + if (vnode.children) { + for (var i = 0, l = vnode.children.length; i < l; i++) { + var child = vnode.children[i]; + if (child.tag && !child.ns) { + applyNS(child, ns); + } + } } } @@ -2882,9 +2904,14 @@ function initRender (vm) { var renderContext = parentVnode && parentVnode.context; vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext); vm.$scopedSlots = {}; - // bind the public createElement fn to this instance + // bind the createElement fn to this instance // so that we get proper render context inside it. - vm.$createElement = bind$1(createElement, vm); + // args order: tag, data, children, needNormalization, 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 + // user-written render functions. + vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }; if (vm.$options.el) { vm.$mount(vm.$options.el); } @@ -2945,21 +2972,21 @@ function renderMixin (Vue) { vm ); } - vnode = emptyVNode(); + vnode = createEmptyVNode(); } // set parent vnode.parent = _parentVnode; return vnode }; - // shorthands used in render functions - Vue.prototype._h = createElement; // toString for mustaches Vue.prototype._s = _toString; + // convert text to vnode + Vue.prototype._v = createTextVNode; // number conversion Vue.prototype._n = toNumber; // empty vnode - Vue.prototype._e = emptyVNode; + Vue.prototype._e = createEmptyVNode; // loose equal Vue.prototype._q = looseEqual; // loose indexOf @@ -3013,7 +3040,6 @@ function renderMixin (Vue) { } // filter resolution helper - var identity = function (_) { return _; }; Vue.prototype._f = function resolveFilter (id) { return resolveAsset(this.$options, 'filters', id, true) || identity }; @@ -3117,14 +3143,13 @@ function renderMixin (Vue) { } function resolveSlots ( - renderChildren, + children, context ) { var slots = {}; - if (!renderChildren) { + if (!children) { return slots } - var children = normalizeChildren(renderChildren) || []; var defaultSlot = []; var name, child; for (var i = 0, l = children.length; i < l; i++) { @@ -3380,7 +3405,8 @@ function initExtend (Vue) { if (!/^[a-zA-Z][\w-]*$/.test(name)) { warn( 'Invalid component name: "' + name + '". Component names ' + - 'can only contain alphanumeric characaters and the hyphen.' + 'can only contain alphanumeric characters and the hyphen, ' + + 'and must start with a letter.' ); } } @@ -3561,14 +3587,15 @@ Object.defineProperty(Vue$3.prototype, '$isServer', { get: isServerRendering }); -Vue$3.version = '2.1.4'; +Vue$3.version = '2.1.5'; /* */ // attributes that should be using props for binding +var acceptValue = makeMap('input,textarea,option,select'); var mustUseProp = function (tag, attr) { return ( - (attr === 'value' && (tag === 'input' || tag === 'textarea' || tag === 'option')) || + (attr === 'value' && acceptValue(tag)) || (attr === 'selected' && tag === 'option') || (attr === 'checked' && tag === 'input') || (attr === 'muted' && tag === 'video') @@ -3818,10 +3845,6 @@ function setTextContent (node, text) { node.textContent = text; } -function childNodes (node) { - return node.childNodes -} - function setAttribute (node, key, val) { node.setAttribute(key, val); } @@ -3839,7 +3862,6 @@ var nodeOps = Object.freeze({ nextSibling: nextSibling, tagName: tagName, setTextContent: setTextContent, - childNodes: childNodes, setAttribute: setAttribute }); @@ -4067,7 +4089,11 @@ function createPatchFunction (backend) { function insert (parent, elm, ref) { if (parent) { - nodeOps.insertBefore(parent, elm, ref); + if (ref) { + nodeOps.insertBefore(parent, elm, ref); + } else { + nodeOps.appendChild(parent, elm); + } } } @@ -4247,15 +4273,15 @@ function createPatchFunction (backend) { 'Make sure each v-for item has a unique key.' ); } - if (elmToMove.tag !== newStartVnode.tag) { - // same key but different element. treat as new element - createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); - newStartVnode = newCh[++newStartIdx]; - } else { + if (sameVnode(elmToMove, newStartVnode)) { patchVnode(elmToMove, newStartVnode, insertedVnodeQueue); oldCh[idxInOld] = undefined; canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm); newStartVnode = newCh[++newStartIdx]; + } else { + // same key but different element. treat as new element + createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); + newStartVnode = newCh[++newStartIdx]; } } } @@ -4329,6 +4355,11 @@ function createPatchFunction (backend) { } var bailed = false; + // list of modules that can skip create hook during hydration because they + // are already rendered on the client or has no need for initialization + var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key'); + + // Note: this is a browser-only function so we can assume elms are DOM nodes. function hydrate (elm, vnode, insertedVnodeQueue) { if (process.env.NODE_ENV !== 'production') { if (!assertNodeMatch(elm, vnode)) { @@ -4349,36 +4380,40 @@ function createPatchFunction (backend) { } if (isDef(tag)) { if (isDef(children)) { - var childNodes = nodeOps.childNodes(elm); // empty element, allow client to pick up and populate children - if (!childNodes.length) { + if (!elm.hasChildNodes()) { createChildren(vnode, children, insertedVnodeQueue); } else { var childrenMatch = true; - if (childNodes.length !== children.length) { - childrenMatch = false; - } else { - for (var i$1 = 0; i$1 < children.length; i$1++) { - if (!hydrate(childNodes[i$1], children[i$1], insertedVnodeQueue)) { - childrenMatch = false; - break - } + var childNode = elm.firstChild; + for (var i$1 = 0; i$1 < children.length; i$1++) { + if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) { + childrenMatch = false; + break } + childNode = childNode.nextSibling; } - if (!childrenMatch) { + // if childNode is not null, it means the actual childNodes list is + // longer than the virtual children list. + if (!childrenMatch || childNode) { if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined' && !bailed) { bailed = true; console.warn('Parent: ', elm); - console.warn('Mismatching childNodes vs. VNodes: ', childNodes, children); + console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); } return false } } } if (isDef(data)) { - invokeCreateHooks(vnode, insertedVnodeQueue); + for (var key in data) { + if (!isRenderedModule(key)) { + invokeCreateHooks(vnode, insertedVnodeQueue); + break + } + } } } return true @@ -4388,7 +4423,7 @@ function createPatchFunction (backend) { if (vnode.tag) { return ( vnode.tag.indexOf('vue-component') === 0 || - vnode.tag.toLowerCase() === nodeOps.tagName(node).toLowerCase() + vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) ) } else { return _toString(vnode.text) === node.data @@ -4485,13 +4520,13 @@ var directives = { } }; -function updateDirectives ( - oldVnode, - vnode -) { - if (!oldVnode.data.directives && !vnode.data.directives) { - return +function updateDirectives (oldVnode, vnode) { + if (oldVnode.data.directives || vnode.data.directives) { + _update(oldVnode, vnode); } +} + +function _update (oldVnode, vnode) { var isCreate = oldVnode === emptyNode; var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); @@ -4521,9 +4556,9 @@ function updateDirectives ( if (dirsWithInsert.length) { var callInsert = function () { - dirsWithInsert.forEach(function (dir) { - callHook$1(dir, 'inserted', vnode, oldVnode); - }); + for (var i = 0; i < dirsWithInsert.length; i++) { + callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); + } }; if (isCreate) { mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert, 'dir-insert'); @@ -4534,9 +4569,9 @@ function updateDirectives ( if (dirsWithPostpatch.length) { mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () { - dirsWithPostpatch.forEach(function (dir) { - callHook$1(dir, 'componentUpdated', vnode, oldVnode); - }); + for (var i = 0; i < dirsWithPostpatch.length; i++) { + callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); + } }, 'dir-postpatch'); } @@ -4610,6 +4645,11 @@ function updateAttrs (oldVnode, vnode) { setAttr(elm, key, cur); } } + // #4391: in IE9, setting type can reset value for input[type=radio] + /* istanbul ignore if */ + if (isIE9 && attrs.value !== oldAttrs.value) { + setAttr(elm, 'value', attrs.value); + } for (key in oldAttrs) { if (attrs[key] == null) { if (isXlink(key)) { @@ -4683,8 +4723,26 @@ var klass = { update: updateClass }; -// skip type checking this file because we need to attach private properties -// to elements +/* */ + +var target; + +function add$1 (event, handler, once, capture) { + if (once) { + var oldHandler = handler; + handler = function (ev) { + remove$2(event, handler, capture); + arguments.length === 1 + ? oldHandler(ev) + : oldHandler.apply(null, arguments); + }; + } + target.addEventListener(event, handler, capture); +} + +function remove$2 (event, handler, capture) { + target.removeEventListener(event, handler, capture); +} function updateDOMListeners (oldVnode, vnode) { if (!oldVnode.data.on && !vnode.data.on) { @@ -4692,26 +4750,8 @@ function updateDOMListeners (oldVnode, vnode) { } var on = vnode.data.on || {}; var oldOn = oldVnode.data.on || {}; - var add = vnode.elm._v_add || ( - vnode.elm._v_add = function (event, handler, once, capture) { - if (once) { - var oldHandler = handler; - handler = function (ev) { - remove(event, handler, capture); - arguments.length === 1 - ? oldHandler(ev) - : oldHandler.apply(null, arguments); - }; - } - vnode.elm.addEventListener(event, handler, capture); - } - ); - var remove = vnode.elm._v_remove || ( - vnode.elm._v_remove = function (event, handler, capture) { - vnode.elm.removeEventListener(event, handler, capture); - } - ); - updateListeners(on, oldOn, add, remove, vnode.context); + target = vnode.elm; + updateListeners(on, oldOn, add$1, remove$2, vnode.context); } var events = { @@ -4754,7 +4794,10 @@ function updateDOMProps (oldVnode, vnode) { elm._value = cur; // avoid resetting cursor position when value is the same var strCur = cur == null ? '' : String(cur); - if (elm.value !== strCur && !elm.composing) { + if (!elm.composing && ( + (document.activeElement !== elm && elm.value !== strCur) || + isValueChanged(vnode, strCur) + )) { elm.value = strCur; } } else { @@ -4763,6 +4806,18 @@ function updateDOMProps (oldVnode, vnode) { } } +function isValueChanged (vnode, newVal) { + var value = vnode.elm.value; + var modifiers = vnode.elm._vModifiers; // injected by v-model runtime + if ((modifiers && modifiers.number) || vnode.elm.type === 'number') { + return toNumber(value) !== toNumber(newVal) + } + if (modifiers && modifiers.trim) { + return value.trim() !== newVal.trim() + } + return value !== newVal +} + var domProps = { create: updateDOMProps, update: updateDOMProps @@ -5107,7 +5162,7 @@ function toMs (s) { /* */ -function enter (vnode) { +function enter (vnode, toggleDisplay) { var el = vnode.elm; // call leave callback now @@ -5216,6 +5271,7 @@ function enter (vnode) { } if (vnode.data.show) { + toggleDisplay && toggleDisplay(); enterHook && enterHook(el, cb); } @@ -5425,17 +5481,17 @@ var model = { if (isIE || isEdge) { setTimeout(cb, 0); } - } else if ( - (vnode.tag === 'textarea' || el.type === 'text') && - !binding.modifiers.lazy - ) { - if (!isAndroid) { - el.addEventListener('compositionstart', onCompositionStart); - el.addEventListener('compositionend', onCompositionEnd); - } - /* istanbul ignore if */ - if (isIE9) { - el.vmodel = true; + } else if (vnode.tag === 'textarea' || el.type === 'text') { + el._vModifiers = binding.modifiers; + if (!binding.modifiers.lazy) { + if (!isAndroid) { + el.addEventListener('compositionstart', onCompositionStart); + el.addEventListener('compositionend', onCompositionEnd); + } + /* istanbul ignore if */ + if (isIE9) { + el.vmodel = true; + } } } }, @@ -5534,12 +5590,16 @@ var show = { vnode = locateNode(vnode); var transition = vnode.data && vnode.data.transition; + var originalDisplay = el.__vOriginalDisplay = + el.style.display === 'none' ? '' : el.style.display; if (value && transition && !isIE9) { - enter(vnode); + vnode.data.show = true; + enter(vnode, function () { + el.style.display = originalDisplay; + }); + } else { + el.style.display = value ? originalDisplay : 'none'; } - var originalDisplay = el.style.display === 'none' ? '' : el.style.display; - el.style.display = value ? originalDisplay : 'none'; - el.__vOriginalDisplay = originalDisplay; }, update: function update (el, ref, vnode) { var value = ref.value; @@ -5550,9 +5610,11 @@ var show = { vnode = locateNode(vnode); var transition = vnode.data && vnode.data.transition; if (transition && !isIE9) { + vnode.data.show = true; if (value) { - enter(vnode); - el.style.display = el.__vOriginalDisplay; + enter(vnode, function () { + el.style.display = el.__vOriginalDisplay; + }); } else { leave(vnode, function () { el.style.display = 'none'; @@ -5924,7 +5986,7 @@ setTimeout(function () { devtools.emit('init', Vue$3); } else if ( process.env.NODE_ENV !== 'production' && - inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent) + inBrowser && !isEdge && /Chrome\/\d+/.test(window.navigator.userAgent) ) { console.log( 'Download the Vue Devtools for a better development experience:\n' + @@ -6337,7 +6399,6 @@ function parseFilters (exp) { case 0x22: inDouble = true; break // " case 0x27: inSingle = true; break // ' case 0x60: inTemplateString = true; break // ` - case 0x2f: inRegex = true; break // / case 0x28: paren++; break // ( case 0x29: paren--; break // ) case 0x5B: square++; break // [ @@ -6345,6 +6406,18 @@ function parseFilters (exp) { case 0x7B: curly++; break // { case 0x7D: curly--; break // } } + if (c === 0x2f) { // / + var j = i - 1; + var p = (void 0); + // find first non-whitespace prev char + for (; j >= 0; j--) { + p = exp.charAt(j); + if (p !== ' ') { break } + } + if (!p || !/[\w$]/.test(p)) { + inRegex = true; + } + } } } @@ -7007,6 +7080,7 @@ function processAttrs (el) { if (bindRE.test(name)) { // v-bind name = name.replace(bindRE, ''); value = parseFilters(value); + isProp = false; if (modifiers) { if (modifiers.prop) { isProp = true; @@ -7376,7 +7450,7 @@ function generate ( transforms$1 = pluckModuleFunction(options.modules, 'transformCode'); dataGenFns = pluckModuleFunction(options.modules, 'genData'); platformDirectives$1 = options.directives || {}; - var code = ast ? genElement(ast) : '_h("div")'; + var code = ast ? genElement(ast) : '_c("div")'; staticRenderFns = prevStaticRenderFns; onceCount = prevOnceCount; return { @@ -7406,8 +7480,8 @@ function genElement (el) { } else { var data = el.plain ? undefined : genData(el); - var children = el.inlineTemplate ? null : genChildren(el); - code = "_h('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; + var children = el.inlineTemplate ? null : genChildren(el, true); + code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; } // module transforms for (var i = 0; i < transforms$1.length; i++) { @@ -7604,12 +7678,34 @@ function genScopedSlot (key, el) { : genElement(el)) + "}" } -function genChildren (el) { - if (el.children.length) { - return '[' + el.children.map(genNode).join(',') + ']' +function genChildren (el, checkSkip) { + var children = el.children; + if (children.length) { + var el$1 = children[0]; + // optimize single v-for + if (children.length === 1 && + el$1.for && + el$1.tag !== 'template' && + el$1.tag !== 'slot') { + return genElement(el$1) + } + return ("[" + (children.map(genNode).join(',')) + "]" + (checkSkip + ? canSkipNormalization(children) ? '' : ',true' + : '')) } } +function canSkipNormalization (children) { + for (var i = 0; i < children.length; i++) { + var el = children[i]; + if (el.for || el.tag === 'template' || el.tag === 'slot' || + (el.if && el.ifConditions.some(function (c) { return c.tag === 'template'; }))) { + return false + } + } + return true +} + function genNode (node) { if (node.type === 1) { return genElement(node) @@ -7619,9 +7715,9 @@ function genNode (node) { } function genText (text) { - return text.type === 2 + return ("_v(" + (text.type === 2 ? text.expression // no need for () because already wrapped in _s() - : transformSpecialNewlines(JSON.stringify(text.text)) + : transformSpecialNewlines(JSON.stringify(text.text))) + ")") } function genSlot (el) { @@ -7632,8 +7728,8 @@ function genSlot (el) { // componentName is el.component, take it as argument to shun flow's pessimistic refinement function genComponent (componentName, el) { - var children = el.inlineTemplate ? null : genChildren(el); - return ("_h(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") + var children = el.inlineTemplate ? null : genChildren(el, true); + return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") } function genProps (props) { @@ -7966,10 +8062,12 @@ function genDefaultModel ( valueExpression = number || type === 'number' ? ("_n(" + valueExpression + ")") : valueExpression; + var code = genAssignmentCode(value, valueExpression); if (isNative && needCompositionGuard) { code = "if($event.target.composing)return;" + code; } + // inputs with type="file" are read only and setting the input's // value will throw an error. if (process.env.NODE_ENV !== 'production' && @@ -7979,8 +8077,12 @@ function genDefaultModel ( "File inputs are read only. Use a v-on:change listener instead." ); } + addProp(el, 'value', isNative ? ("_s(" + value + ")") : ("(" + value + ")")); addHandler(el, event, code, null, true); + if (trim || number || type === 'number') { + addHandler(el, 'blur', '$forceUpdate()'); + } } function genSelect ( diff --git a/dist/vue.js b/dist/vue.js index 67d4c5c2470..35873500b13 100644 --- a/dist/vue.js +++ b/dist/vue.js @@ -1,5 +1,5 @@ /*! - * Vue.js v2.1.4 + * Vue.js v2.1.5 * (c) 2014-2016 Evan You * Released under the MIT License. */ @@ -200,6 +200,11 @@ function noop () {} */ var no = function () { return false; }; +/** + * Return same value + */ +var identity = function (_) { return _; }; + /** * Generate a static keys string from compiler modules. */ @@ -280,6 +285,11 @@ var config = { */ getTagNamespace: noop, + /** + * Parse the real tag name for the specific platform. + */ + parsePlatformTagName: identity, + /** * Check if an attribute must be bound using property, e.g. value * Platform-dependent. @@ -489,10 +499,10 @@ if (typeof Set !== 'undefined' && isNative(Set)) { this.set = Object.create(null); } Set.prototype.has = function has (key) { - return this.set[key] !== undefined + return this.set[key] === true }; Set.prototype.add = function add (key) { - this.set[key] = 1; + this.set[key] = true; }; Set.prototype.clear = function clear () { this.set = Object.create(null); @@ -710,9 +720,8 @@ function protoAugment (target, src) { /** * Augment an target Object or Array by defining * hidden properties. - * - * istanbul ignore next */ +/* istanbul ignore next */ function copyAugment (target, src, keys) { for (var i = 0, l = keys.length; i < l; i++) { var key = keys[i]; @@ -1178,11 +1187,14 @@ function resolveAsset ( return } var assets = options[type]; - var res = assets[id] || - // camelCase ID - assets[camelize(id)] || - // Pascal Case ID - assets[capitalize(camelize(id))]; + // check local registration variations first + if (hasOwn(assets, id)) { return assets[id] } + var camelizedId = camelize(id); + if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } + var PascalCaseId = capitalize(camelizedId); + if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } + // fallback to prototype chain + var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; if ("development" !== 'production' && warnMissing && !res) { warn( 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, @@ -1384,6 +1396,7 @@ var util = Object.freeze({ toObject: toObject, noop: noop, no: no, + identity: identity, genStaticKeys: genStaticKeys, looseEqual: looseEqual, looseIndexOf: looseIndexOf, @@ -1878,7 +1891,8 @@ function initData (vm) { if (!isPlainObject(data)) { data = {}; "development" !== 'production' && warn( - 'data functions should return an object.', + 'data functions should return an object:\n' + + 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm ); } @@ -2054,7 +2068,6 @@ var VNode = function VNode ( children, text, elm, - ns, context, componentOptions ) { @@ -2063,7 +2076,7 @@ var VNode = function VNode ( this.children = children; this.text = text; this.elm = elm; - this.ns = ns; + this.ns = undefined; this.context = context; this.functionalContext = undefined; this.key = data && data.key; @@ -2078,13 +2091,17 @@ var VNode = function VNode ( this.isOnce = false; }; -var emptyVNode = function () { +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 @@ -2096,10 +2113,10 @@ function cloneVNode (vnode) { vnode.children, vnode.text, vnode.elm, - vnode.ns, vnode.context, vnode.componentOptions ); + cloned.ns = vnode.ns; cloned.isStatic = vnode.isStatic; cloned.key = vnode.key; cloned.isCloned = true; @@ -2116,167 +2133,6 @@ function cloneVNodes (vnodes) { /* */ -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; - } - } -} - -/* */ - -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) { - "development" !== '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, - ns, - nestedIndex -) { - if (isPrimitive(children)) { - return [createTextVNode(children)] - } - if (Array.isArray(children)) { - var res = []; - for (var i = 0, l = children.length; i < l; i++) { - var c = children[i]; - var last = res[res.length - 1]; - // nested - if (Array.isArray(c)) { - res.push.apply(res, normalizeChildren(c, ns, ((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 instanceof VNode) { - if (c.text && last && last.text) { - if (!last.isCloned) { - last.text += c.text; - } - } else { - // inherit parent namespace - if (ns) { - applyNS(c, ns); - } - // 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 createTextVNode (val) { - return new VNode(undefined, undefined, undefined, String(val)) -} - -function applyNS (vnode, ns) { - if (vnode.tag && !vnode.ns) { - vnode.ns = ns; - if (vnode.children) { - for (var i = 0, l = vnode.children.length; i < l; i++) { - applyNS(vnode.children[i], ns); - } - } - } -} - -/* */ - -function getFirstComponentChild (children) { - return children && children.filter(function (c) { return c && c.componentOptions; })[0] -} - -/* */ - var activeInstance = null; function initLifecycle (vm) { @@ -2312,7 +2168,7 @@ function lifecycleMixin (Vue) { var vm = this; vm.$el = el; if (!vm.$options.render) { - vm.$options.render = emptyVNode; + vm.$options.render = createEmptyVNode; { /* istanbul ignore if */ if (vm.$options.template && vm.$options.template.charAt(0) !== '#') { @@ -2563,7 +2419,7 @@ function createComponent ( var name = Ctor.options.name || tag; var vnode = new VNode( ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), - data, undefined, undefined, undefined, undefined, context, + data, undefined, undefined, undefined, context, { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children } ); return vnode @@ -2583,19 +2439,17 @@ function createFunctionalComponent ( props[key] = validateProp(key, propOptions, propsData); } } - var vnode = Ctor.options.render.call( - null, - // ensure the createElement function in functional components - // gets a unique context - this is necessary for correct named slot check - bind$1(createElement, { _self: Object.create(context) }), - { - props: props, - data: data, - parent: context, - children: normalizeChildren(children), - slots: function () { return resolveSlots(children, context); } - } - ); + // 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) { @@ -2806,26 +2660,172 @@ function mergeHook$1 (one, two) { /* */ +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; + } + } +} + +/* */ + +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) { + "development" !== '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) { 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 getFirstComponentChild (children) { + return children && children.filter(function (c) { return c && c.componentOptions; })[0] +} + +/* */ + // wrapper function for providing a more flexible interface // without getting yelled at by flow function createElement ( + context, tag, data, - children + children, + needNormalization, + alwaysNormalize ) { - if (data && (Array.isArray(data) || typeof data !== 'object')) { + if (Array.isArray(data) || isPrimitive(data)) { + needNormalization = children; children = data; data = undefined; } - // make sure to use real instance instead of proxy as context - return _createElement(this._self, tag, data, children) + if (alwaysNormalize) { needNormalization = true; } + return _createElement(context, tag, data, children, needNormalization) } function _createElement ( context, tag, data, - children + children, + needNormalization ) { if (data && data.__ob__) { "development" !== 'production' && warn( @@ -2833,11 +2833,11 @@ function _createElement ( 'Always create fresh vnode data objects in each render!', context ); - return + return createEmptyVNode() } if (!tag) { // in case of component :is set to falsy value - return emptyVNode() + return createEmptyVNode() } // support single function children as default scoped slot if (Array.isArray(children) && @@ -2846,31 +2846,53 @@ function _createElement ( data.scopedSlots = { default: children[0] }; children.length = 0; } + if (needNormalization) { + children = normalizeChildren(children); + } + var vnode, ns; if (typeof tag === 'string') { var Ctor; - var ns = config.getTagNamespace(tag); + ns = config.getTagNamespace(tag); if (config.isReservedTag(tag)) { // platform built-in elements - return new VNode( - tag, data, normalizeChildren(children, ns), - undefined, undefined, ns, context - ) + vnode = new VNode( + config.parsePlatformTagName(tag), data, children, + undefined, undefined, context + ); } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) { // component - return createComponent(Ctor, data, context, children, tag) + vnode = createComponent(Ctor, data, context, children, tag); } else { // unknown or unlisted namespaced elements // check at runtime because it may get assigned a namespace when its // parent normalizes children - var childNs = tag === 'foreignObject' ? 'xhtml' : ns; - return new VNode( - tag, data, normalizeChildren(children, childNs), - undefined, undefined, ns, context - ) + ns = tag === 'foreignObject' ? 'xhtml' : ns; + vnode = new VNode( + tag, data, children, + undefined, undefined, context + ); } } else { // direct component options / constructor - return createComponent(tag, data, context, children) + vnode = createComponent(tag, data, context, children); + } + if (vnode) { + if (ns) { applyNS(vnode, ns); } + return vnode + } else { + return createEmptyVNode() + } +} + +function applyNS (vnode, ns) { + vnode.ns = ns; + if (vnode.children) { + for (var i = 0, l = vnode.children.length; i < l; i++) { + var child = vnode.children[i]; + if (child.tag && !child.ns) { + applyNS(child, ns); + } + } } } @@ -2884,9 +2906,14 @@ function initRender (vm) { var renderContext = parentVnode && parentVnode.context; vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext); vm.$scopedSlots = {}; - // bind the public createElement fn to this instance + // bind the createElement fn to this instance // so that we get proper render context inside it. - vm.$createElement = bind$1(createElement, vm); + // args order: tag, data, children, needNormalization, 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 + // user-written render functions. + vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }; if (vm.$options.el) { vm.$mount(vm.$options.el); } @@ -2947,21 +2974,21 @@ function renderMixin (Vue) { vm ); } - vnode = emptyVNode(); + vnode = createEmptyVNode(); } // set parent vnode.parent = _parentVnode; return vnode }; - // shorthands used in render functions - Vue.prototype._h = createElement; // toString for mustaches Vue.prototype._s = _toString; + // convert text to vnode + Vue.prototype._v = createTextVNode; // number conversion Vue.prototype._n = toNumber; // empty vnode - Vue.prototype._e = emptyVNode; + Vue.prototype._e = createEmptyVNode; // loose equal Vue.prototype._q = looseEqual; // loose indexOf @@ -3015,7 +3042,6 @@ function renderMixin (Vue) { } // filter resolution helper - var identity = function (_) { return _; }; Vue.prototype._f = function resolveFilter (id) { return resolveAsset(this.$options, 'filters', id, true) || identity }; @@ -3119,14 +3145,13 @@ function renderMixin (Vue) { } function resolveSlots ( - renderChildren, + children, context ) { var slots = {}; - if (!renderChildren) { + if (!children) { return slots } - var children = normalizeChildren(renderChildren) || []; var defaultSlot = []; var name, child; for (var i = 0, l = children.length; i < l; i++) { @@ -3380,7 +3405,8 @@ function initExtend (Vue) { if (!/^[a-zA-Z][\w-]*$/.test(name)) { warn( 'Invalid component name: "' + name + '". Component names ' + - 'can only contain alphanumeric characaters and the hyphen.' + 'can only contain alphanumeric characters and the hyphen, ' + + 'and must start with a letter.' ); } } @@ -3561,14 +3587,15 @@ Object.defineProperty(Vue$3.prototype, '$isServer', { get: isServerRendering }); -Vue$3.version = '2.1.4'; +Vue$3.version = '2.1.5'; /* */ // attributes that should be using props for binding +var acceptValue = makeMap('input,textarea,option,select'); var mustUseProp = function (tag, attr) { return ( - (attr === 'value' && (tag === 'input' || tag === 'textarea' || tag === 'option')) || + (attr === 'value' && acceptValue(tag)) || (attr === 'selected' && tag === 'option') || (attr === 'checked' && tag === 'input') || (attr === 'muted' && tag === 'video') @@ -3818,10 +3845,6 @@ function setTextContent (node, text) { node.textContent = text; } -function childNodes (node) { - return node.childNodes -} - function setAttribute (node, key, val) { node.setAttribute(key, val); } @@ -3839,7 +3862,6 @@ var nodeOps = Object.freeze({ nextSibling: nextSibling, tagName: tagName, setTextContent: setTextContent, - childNodes: childNodes, setAttribute: setAttribute }); @@ -4067,7 +4089,11 @@ function createPatchFunction (backend) { function insert (parent, elm, ref) { if (parent) { - nodeOps.insertBefore(parent, elm, ref); + if (ref) { + nodeOps.insertBefore(parent, elm, ref); + } else { + nodeOps.appendChild(parent, elm); + } } } @@ -4247,15 +4273,15 @@ function createPatchFunction (backend) { 'Make sure each v-for item has a unique key.' ); } - if (elmToMove.tag !== newStartVnode.tag) { - // same key but different element. treat as new element - createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); - newStartVnode = newCh[++newStartIdx]; - } else { + if (sameVnode(elmToMove, newStartVnode)) { patchVnode(elmToMove, newStartVnode, insertedVnodeQueue); oldCh[idxInOld] = undefined; canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm); newStartVnode = newCh[++newStartIdx]; + } else { + // same key but different element. treat as new element + createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); + newStartVnode = newCh[++newStartIdx]; } } } @@ -4329,6 +4355,11 @@ function createPatchFunction (backend) { } var bailed = false; + // list of modules that can skip create hook during hydration because they + // are already rendered on the client or has no need for initialization + var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key'); + + // Note: this is a browser-only function so we can assume elms are DOM nodes. function hydrate (elm, vnode, insertedVnodeQueue) { { if (!assertNodeMatch(elm, vnode)) { @@ -4349,36 +4380,40 @@ function createPatchFunction (backend) { } if (isDef(tag)) { if (isDef(children)) { - var childNodes = nodeOps.childNodes(elm); // empty element, allow client to pick up and populate children - if (!childNodes.length) { + if (!elm.hasChildNodes()) { createChildren(vnode, children, insertedVnodeQueue); } else { var childrenMatch = true; - if (childNodes.length !== children.length) { - childrenMatch = false; - } else { - for (var i$1 = 0; i$1 < children.length; i$1++) { - if (!hydrate(childNodes[i$1], children[i$1], insertedVnodeQueue)) { - childrenMatch = false; - break - } + var childNode = elm.firstChild; + for (var i$1 = 0; i$1 < children.length; i$1++) { + if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) { + childrenMatch = false; + break } + childNode = childNode.nextSibling; } - if (!childrenMatch) { + // if childNode is not null, it means the actual childNodes list is + // longer than the virtual children list. + if (!childrenMatch || childNode) { if ("development" !== 'production' && typeof console !== 'undefined' && !bailed) { bailed = true; console.warn('Parent: ', elm); - console.warn('Mismatching childNodes vs. VNodes: ', childNodes, children); + console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); } return false } } } if (isDef(data)) { - invokeCreateHooks(vnode, insertedVnodeQueue); + for (var key in data) { + if (!isRenderedModule(key)) { + invokeCreateHooks(vnode, insertedVnodeQueue); + break + } + } } } return true @@ -4388,7 +4423,7 @@ function createPatchFunction (backend) { if (vnode.tag) { return ( vnode.tag.indexOf('vue-component') === 0 || - vnode.tag.toLowerCase() === nodeOps.tagName(node).toLowerCase() + vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) ) } else { return _toString(vnode.text) === node.data @@ -4485,13 +4520,13 @@ var directives = { } }; -function updateDirectives ( - oldVnode, - vnode -) { - if (!oldVnode.data.directives && !vnode.data.directives) { - return +function updateDirectives (oldVnode, vnode) { + if (oldVnode.data.directives || vnode.data.directives) { + _update(oldVnode, vnode); } +} + +function _update (oldVnode, vnode) { var isCreate = oldVnode === emptyNode; var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); @@ -4521,9 +4556,9 @@ function updateDirectives ( if (dirsWithInsert.length) { var callInsert = function () { - dirsWithInsert.forEach(function (dir) { - callHook$1(dir, 'inserted', vnode, oldVnode); - }); + for (var i = 0; i < dirsWithInsert.length; i++) { + callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); + } }; if (isCreate) { mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert, 'dir-insert'); @@ -4534,9 +4569,9 @@ function updateDirectives ( if (dirsWithPostpatch.length) { mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () { - dirsWithPostpatch.forEach(function (dir) { - callHook$1(dir, 'componentUpdated', vnode, oldVnode); - }); + for (var i = 0; i < dirsWithPostpatch.length; i++) { + callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); + } }, 'dir-postpatch'); } @@ -4610,6 +4645,11 @@ function updateAttrs (oldVnode, vnode) { setAttr(elm, key, cur); } } + // #4391: in IE9, setting type can reset value for input[type=radio] + /* istanbul ignore if */ + if (isIE9 && attrs.value !== oldAttrs.value) { + setAttr(elm, 'value', attrs.value); + } for (key in oldAttrs) { if (attrs[key] == null) { if (isXlink(key)) { @@ -4683,8 +4723,26 @@ var klass = { update: updateClass }; -// skip type checking this file because we need to attach private properties -// to elements +/* */ + +var target; + +function add$1 (event, handler, once, capture) { + if (once) { + var oldHandler = handler; + handler = function (ev) { + remove$2(event, handler, capture); + arguments.length === 1 + ? oldHandler(ev) + : oldHandler.apply(null, arguments); + }; + } + target.addEventListener(event, handler, capture); +} + +function remove$2 (event, handler, capture) { + target.removeEventListener(event, handler, capture); +} function updateDOMListeners (oldVnode, vnode) { if (!oldVnode.data.on && !vnode.data.on) { @@ -4692,26 +4750,8 @@ function updateDOMListeners (oldVnode, vnode) { } var on = vnode.data.on || {}; var oldOn = oldVnode.data.on || {}; - var add = vnode.elm._v_add || ( - vnode.elm._v_add = function (event, handler, once, capture) { - if (once) { - var oldHandler = handler; - handler = function (ev) { - remove(event, handler, capture); - arguments.length === 1 - ? oldHandler(ev) - : oldHandler.apply(null, arguments); - }; - } - vnode.elm.addEventListener(event, handler, capture); - } - ); - var remove = vnode.elm._v_remove || ( - vnode.elm._v_remove = function (event, handler, capture) { - vnode.elm.removeEventListener(event, handler, capture); - } - ); - updateListeners(on, oldOn, add, remove, vnode.context); + target = vnode.elm; + updateListeners(on, oldOn, add$1, remove$2, vnode.context); } var events = { @@ -4754,7 +4794,10 @@ function updateDOMProps (oldVnode, vnode) { elm._value = cur; // avoid resetting cursor position when value is the same var strCur = cur == null ? '' : String(cur); - if (elm.value !== strCur && !elm.composing) { + if (!elm.composing && ( + (document.activeElement !== elm && elm.value !== strCur) || + isValueChanged(vnode, strCur) + )) { elm.value = strCur; } } else { @@ -4763,6 +4806,18 @@ function updateDOMProps (oldVnode, vnode) { } } +function isValueChanged (vnode, newVal) { + var value = vnode.elm.value; + var modifiers = vnode.elm._vModifiers; // injected by v-model runtime + if ((modifiers && modifiers.number) || vnode.elm.type === 'number') { + return toNumber(value) !== toNumber(newVal) + } + if (modifiers && modifiers.trim) { + return value.trim() !== newVal.trim() + } + return value !== newVal +} + var domProps = { create: updateDOMProps, update: updateDOMProps @@ -5107,7 +5162,7 @@ function toMs (s) { /* */ -function enter (vnode) { +function enter (vnode, toggleDisplay) { var el = vnode.elm; // call leave callback now @@ -5216,6 +5271,7 @@ function enter (vnode) { } if (vnode.data.show) { + toggleDisplay && toggleDisplay(); enterHook && enterHook(el, cb); } @@ -5425,17 +5481,17 @@ var model = { if (isIE || isEdge) { setTimeout(cb, 0); } - } else if ( - (vnode.tag === 'textarea' || el.type === 'text') && - !binding.modifiers.lazy - ) { - if (!isAndroid) { - el.addEventListener('compositionstart', onCompositionStart); - el.addEventListener('compositionend', onCompositionEnd); - } - /* istanbul ignore if */ - if (isIE9) { - el.vmodel = true; + } else if (vnode.tag === 'textarea' || el.type === 'text') { + el._vModifiers = binding.modifiers; + if (!binding.modifiers.lazy) { + if (!isAndroid) { + el.addEventListener('compositionstart', onCompositionStart); + el.addEventListener('compositionend', onCompositionEnd); + } + /* istanbul ignore if */ + if (isIE9) { + el.vmodel = true; + } } } }, @@ -5534,12 +5590,16 @@ var show = { vnode = locateNode(vnode); var transition = vnode.data && vnode.data.transition; + var originalDisplay = el.__vOriginalDisplay = + el.style.display === 'none' ? '' : el.style.display; if (value && transition && !isIE9) { - enter(vnode); + vnode.data.show = true; + enter(vnode, function () { + el.style.display = originalDisplay; + }); + } else { + el.style.display = value ? originalDisplay : 'none'; } - var originalDisplay = el.style.display === 'none' ? '' : el.style.display; - el.style.display = value ? originalDisplay : 'none'; - el.__vOriginalDisplay = originalDisplay; }, update: function update (el, ref, vnode) { var value = ref.value; @@ -5550,9 +5610,11 @@ var show = { vnode = locateNode(vnode); var transition = vnode.data && vnode.data.transition; if (transition && !isIE9) { + vnode.data.show = true; if (value) { - enter(vnode); - el.style.display = el.__vOriginalDisplay; + enter(vnode, function () { + el.style.display = el.__vOriginalDisplay; + }); } else { leave(vnode, function () { el.style.display = 'none'; @@ -5924,7 +5986,7 @@ setTimeout(function () { devtools.emit('init', Vue$3); } else if ( "development" !== 'production' && - inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent) + inBrowser && !isEdge && /Chrome\/\d+/.test(window.navigator.userAgent) ) { console.log( 'Download the Vue Devtools for a better development experience:\n' + @@ -6337,7 +6399,6 @@ function parseFilters (exp) { case 0x22: inDouble = true; break // " case 0x27: inSingle = true; break // ' case 0x60: inTemplateString = true; break // ` - case 0x2f: inRegex = true; break // / case 0x28: paren++; break // ( case 0x29: paren--; break // ) case 0x5B: square++; break // [ @@ -6345,6 +6406,18 @@ function parseFilters (exp) { case 0x7B: curly++; break // { case 0x7D: curly--; break // } } + if (c === 0x2f) { // / + var j = i - 1; + var p = (void 0); + // find first non-whitespace prev char + for (; j >= 0; j--) { + p = exp.charAt(j); + if (p !== ' ') { break } + } + if (!p || !/[\w$]/.test(p)) { + inRegex = true; + } + } } } @@ -7007,6 +7080,7 @@ function processAttrs (el) { if (bindRE.test(name)) { // v-bind name = name.replace(bindRE, ''); value = parseFilters(value); + isProp = false; if (modifiers) { if (modifiers.prop) { isProp = true; @@ -7376,7 +7450,7 @@ function generate ( transforms$1 = pluckModuleFunction(options.modules, 'transformCode'); dataGenFns = pluckModuleFunction(options.modules, 'genData'); platformDirectives$1 = options.directives || {}; - var code = ast ? genElement(ast) : '_h("div")'; + var code = ast ? genElement(ast) : '_c("div")'; staticRenderFns = prevStaticRenderFns; onceCount = prevOnceCount; return { @@ -7406,8 +7480,8 @@ function genElement (el) { } else { var data = el.plain ? undefined : genData(el); - var children = el.inlineTemplate ? null : genChildren(el); - code = "_h('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; + var children = el.inlineTemplate ? null : genChildren(el, true); + code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; } // module transforms for (var i = 0; i < transforms$1.length; i++) { @@ -7604,12 +7678,34 @@ function genScopedSlot (key, el) { : genElement(el)) + "}" } -function genChildren (el) { - if (el.children.length) { - return '[' + el.children.map(genNode).join(',') + ']' +function genChildren (el, checkSkip) { + var children = el.children; + if (children.length) { + var el$1 = children[0]; + // optimize single v-for + if (children.length === 1 && + el$1.for && + el$1.tag !== 'template' && + el$1.tag !== 'slot') { + return genElement(el$1) + } + return ("[" + (children.map(genNode).join(',')) + "]" + (checkSkip + ? canSkipNormalization(children) ? '' : ',true' + : '')) } } +function canSkipNormalization (children) { + for (var i = 0; i < children.length; i++) { + var el = children[i]; + if (el.for || el.tag === 'template' || el.tag === 'slot' || + (el.if && el.ifConditions.some(function (c) { return c.tag === 'template'; }))) { + return false + } + } + return true +} + function genNode (node) { if (node.type === 1) { return genElement(node) @@ -7619,9 +7715,9 @@ function genNode (node) { } function genText (text) { - return text.type === 2 + return ("_v(" + (text.type === 2 ? text.expression // no need for () because already wrapped in _s() - : transformSpecialNewlines(JSON.stringify(text.text)) + : transformSpecialNewlines(JSON.stringify(text.text))) + ")") } function genSlot (el) { @@ -7632,8 +7728,8 @@ function genSlot (el) { // componentName is el.component, take it as argument to shun flow's pessimistic refinement function genComponent (componentName, el) { - var children = el.inlineTemplate ? null : genChildren(el); - return ("_h(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") + var children = el.inlineTemplate ? null : genChildren(el, true); + return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") } function genProps (props) { @@ -7966,10 +8062,12 @@ function genDefaultModel ( valueExpression = number || type === 'number' ? ("_n(" + valueExpression + ")") : valueExpression; + var code = genAssignmentCode(value, valueExpression); if (isNative && needCompositionGuard) { code = "if($event.target.composing)return;" + code; } + // inputs with type="file" are read only and setting the input's // value will throw an error. if ("development" !== 'production' && @@ -7979,8 +8077,12 @@ function genDefaultModel ( "File inputs are read only. Use a v-on:change listener instead." ); } + addProp(el, 'value', isNative ? ("_s(" + value + ")") : ("(" + value + ")")); addHandler(el, event, code, null, true); + if (trim || number || type === 'number') { + addHandler(el, 'blur', '$forceUpdate()'); + } } function genSelect ( diff --git a/dist/vue.min.js b/dist/vue.min.js index 12fc623b5e9..9cc44cec9c9 100644 --- a/dist/vue.min.js +++ b/dist/vue.min.js @@ -1,8 +1,8 @@ /*! - * Vue.js v2.1.4 + * Vue.js v2.1.5 * (c) 2014-2016 Evan You * Released under the MIT License. */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Vue=t()}(this,function(){"use strict";function e(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function t(e){var t=parseFloat(e,10);return t||0===t?t:e}function n(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}function i(e,t){return Br.call(e,t)}function o(e){return"string"==typeof e||"number"==typeof e}function a(e){var t=Object.create(null);return function(n){var r=t[n];return r||(t[n]=e(n))}}function s(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n}function c(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function l(e,t){for(var n in t)e[n]=t[n];return e}function u(e){return null!==e&&"object"==typeof e}function f(e){return Wr.call(e)===Zr}function d(e){for(var t={},n=0;n=0&&xi[n].id>e.id;)n--;xi.splice(Math.max(n,Oi)+1,0,e)}else xi.push(e);ki||(ki=!0,li(B))}}function z(e){Ei.clear(),J(e,Ei)}function J(e,t){var n,r,i=Array.isArray(e);if((i||u(e))&&Object.isExtensible(e)){if(e.__ob__){var o=e.__ob__.dep.id;if(t.has(o))return;t.add(o)}if(i)for(n=e.length;n--;)J(e[n],t);else for(r=Object.keys(e),n=r.length;n--;)J(e[r[n]],t)}}function K(e){e._watchers=[],q(e),Y(e),W(e),Z(e),Q(e)}function q(e){var t=e.$options.props;if(t){var n=e.$options.propsData||{},r=e.$options._propKeys=Object.keys(t),i=!e.$parent;yi.shouldConvert=i;for(var o=function(i){var o=r[i];A(e,o,R(o,t,n,e))},a=0;a1?c(n):n;for(var r=c(arguments,1),i=0,o=n.length;i-1:e.test(t)}function Ve(e){var t={};t.get=function(){return Yr},Object.defineProperty(e,"config",t),e.util=wi,e.set=O,e.delete=S,e.nextTick=li,e.options=Object.create(null),Yr._assetTypes.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,l(e.options.components,Ui),Ie(e),Fe(e),Ue(e),He(e)}function ze(e){for(var t=e.data,n=e,r=e;r.child;)r=r.child._vnode,r.data&&(t=Je(r.data,t));for(;n=n.parent;)n.data&&(t=Je(t,n.data));return Ke(t)}function Je(e,t){return{staticClass:qe(e.staticClass,t.staticClass),class:e.class?[e.class,t.class]:t.class}}function Ke(e){var t=e.class,n=e.staticClass;return n||t?qe(n,We(t)):""}function qe(e,t){return e?t?e+" "+t:e:t||""}function We(e){var t="";if(!e)return t;if("string"==typeof e)return e;if(Array.isArray(e)){for(var n,r=0,i=e.length;r-1?eo[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:eo[e]=/HTMLUnknownElement/.test(t.toString())}function Ye(e){if("string"==typeof e){if(e=document.querySelector(e),!e)return document.createElement("div")}return e}function Qe(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&"multiple"in t.data.attrs&&n.setAttribute("multiple","multiple"),n)}function Xe(e,t){return document.createElementNS(Zi[e],t)}function et(e){return document.createTextNode(e)}function tt(e){return document.createComment(e)}function nt(e,t,n){e.insertBefore(t,n)}function rt(e,t){e.removeChild(t)}function it(e,t){e.appendChild(t)}function ot(e){return e.parentNode}function at(e){return e.nextSibling}function st(e){return e.tagName}function ct(e,t){e.textContent=t}function lt(e){return e.childNodes}function ut(e,t,n){e.setAttribute(t,n)}function ft(e,t){var n=e.data.ref;if(n){var i=e.context,o=e.child||e.elm,a=i.$refs;t?Array.isArray(a[n])?r(a[n],o):a[n]===o&&(a[n]=void 0):e.data.refInFor?Array.isArray(a[n])&&a[n].indexOf(o)<0?a[n].push(o):a[n]=[o]:a[n]=o}}function dt(e){return null==e}function pt(e){return null!=e}function vt(e,t){return e.key===t.key&&e.tag===t.tag&&e.isComment===t.isComment&&!e.data==!t.data}function ht(e,t,n){var r,i,o={};for(r=t;r<=n;++r)i=e[r].key,pt(i)&&(o[i]=r);return o}function mt(e){function t(e){return new Ni(A.tagName(e).toLowerCase(),{},[],void 0,e)}function n(e,t){function n(){0===--n.listeners&&r(e)}return n.listeners=t,n}function r(e){var t=A.parentNode(e);t&&A.removeChild(t,e)}function i(e,t,n,r,i){if(e.isRootInsert=!i,!a(e,t,n,r)){var o=e.data,s=e.children,u=e.tag;pt(u)?(e.elm=e.ns?A.createElementNS(e.ns,u):A.createElement(u,e),p(e),l(e,s,t),pt(o)&&f(e,t),c(n,e.elm,r)):e.isComment?(e.elm=A.createComment(e.text),c(n,e.elm,r)):(e.elm=A.createTextNode(e.text),c(n,e.elm,r))}}function a(e,t,n,r){var i=e.data;if(pt(i)){var o=pt(e.child)&&i.keepAlive;if(pt(i=i.hook)&&pt(i=i.init)&&i(e,!1,n,r),pt(e.child))return d(e,t),o&&s(e,t,n,r),!0}}function s(e,t,n,r){for(var i,o=e;o.child;)if(o=o.child._vnode,pt(i=o.data)&&pt(i=i.transition)){for(i=0;id?(l=dt(n[g+1])?null:n[g+1].elm,v(e,l,n,f,g,r)):f>g&&m(e,t,u,d)}function _(e,t,n,r){if(e!==t){if(t.isStatic&&e.isStatic&&t.key===e.key&&(t.isCloned||t.isOnce))return t.elm=e.elm,void(t.child=e.child);var i,o=t.data,a=pt(o);a&&pt(i=o.hook)&&pt(i=i.prepatch)&&i(e,t);var s=t.elm=e.elm,c=e.children,l=t.children;if(a&&u(t)){for(i=0;i-1?t.split(/\s+/).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+e.getAttribute("class")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function jt(e,t){if(t&&t.trim())if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t);else{for(var n=" "+e.getAttribute("class")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");e.setAttribute("class",n.trim())}}function Nt(e){Oo(function(){Oo(e)})}function Lt(e,t){(e._transitionClasses||(e._transitionClasses=[])).push(t),Et(e,t)}function Dt(e,t){e._transitionClasses&&r(e._transitionClasses,t),jt(e,t)}function Mt(e,t,n){var r=Pt(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===$o?Co:Ao,c=0,l=function(){e.removeEventListener(s,u),n()},u=function(t){t.target===e&&++c>=a&&l()};setTimeout(function(){c0&&(n=$o,u=a,f=o.length):t===wo?l>0&&(n=wo,u=l,f=c.length):(u=Math.max(a,l),n=u>0?a>l?$o:wo:null,f=n?n===$o?o.length:c.length:0);var d=n===$o&&So.test(r[xo+"Property"]);return{type:n,timeout:u,propCount:f,hasTransform:d}}function Rt(e,t){for(;e.length1,S=t._enterCb=Bt(function(){A&&Dt(t,$),S.cancelled?(A&&Dt(t,b),k&&k(t)):C&&C(t),t._enterCb=null});e.data.show||ie(e.data.hook||(e.data.hook={}),"insert",function(){var n=t.parentNode,r=n&&n._pending&&n._pending[e.key];r&&r.context===e.context&&r.tag===e.tag&&r.elm._leaveCb&&r.elm._leaveCb(),x&&x(t,S)},"transition-insert"),w&&w(t),A&&(Lt(t,b),Lt(t,$),Nt(function(){Dt(t,b),S.cancelled||O||Mt(t,i,S)})),e.data.show&&x&&x(t,S),A||O||S()}}}function Ut(e,t){function n(){m.cancelled||(e.data.show||((r.parentNode._pending||(r.parentNode._pending={}))[e.key]=e),l&&l(r),v&&(Lt(r,s),Lt(r,c),Nt(function(){Dt(r,s),m.cancelled||h||Mt(r,a,m); -})),u&&u(r,m),v||h||m())}var r=e.elm;r._enterCb&&(r._enterCb.cancelled=!0,r._enterCb());var i=Ht(e.data.transition);if(!i)return t();if(!r._leaveCb&&1===r.nodeType){var o=i.css,a=i.type,s=i.leaveClass,c=i.leaveActiveClass,l=i.beforeLeave,u=i.leave,f=i.afterLeave,d=i.leaveCancelled,p=i.delayLeave,v=o!==!1&&!ri,h=u&&(u._length||u.length)>1,m=r._leaveCb=Bt(function(){r.parentNode&&r.parentNode._pending&&(r.parentNode._pending[e.key]=null),v&&Dt(r,c),m.cancelled?(v&&Dt(r,s),d&&d(r)):(t(),f&&f(r)),r._leaveCb=null});p?p(n):n()}}function Ht(e){if(e){if("object"==typeof e){var t={};return e.css!==!1&&l(t,To(e.name||"v")),l(t,e),t}return"string"==typeof e?To(e):void 0}}function Bt(e){var t=!1;return function(){t||(t=!0,e())}}function Vt(e,t){t.data.show||Ft(t)}function zt(e,t,n){var r=t.value,i=e.multiple;if(!i||Array.isArray(r)){for(var o,a,s=0,c=e.options.length;s-1,a.selected!==o&&(a.selected=o);else if(h(Kt(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function Jt(e,t){for(var n=0,r=t.length;n',n.innerHTML.indexOf(t)>0}function an(e){return Bo=Bo||document.createElement("div"),Bo.innerHTML=e,Bo.textContent}function sn(e,t){return t&&(e=e.replace(Pa,"\n")),e.replace(Da,"<").replace(Ma,">").replace(Ra,"&").replace(Ia,'"')}function cn(e,t){function n(t){f+=t,e=e.substring(t)}function r(){var t=e.match(Xo);if(t){var r={tagName:t[1],attrs:[],start:f};n(t[0].length);for(var i,o;!(i=e.match(ea))&&(o=e.match(Go));)n(o[0].length),r.attrs.push(o);if(i)return r.unarySlash=i[1],n(i[0].length),r.end=f,r}}function i(e){var n=e.tagName,r=e.unarySlash;l&&("p"===s&&Ko(n)&&o("",s),Jo(n)&&s===n&&o("",n));for(var i=u(n)||"html"===n&&"head"===s||!!r,a=e.attrs.length,f=new Array(a),d=0;d=0&&c[o].tag.toLowerCase()!==a;o--);}else o=0;if(o>=0){for(var l=c.length-1;l>=o;l--)t.end&&t.end(c[l].tag,r,i);c.length=o,s=o&&c[o-1].tag}else"br"===n.toLowerCase()?t.start&&t.start(n,[],!0,r,i):"p"===n.toLowerCase()&&(t.start&&t.start(n,[],!1,r,i),t.end&&t.end(n,r,i))}for(var a,s,c=[],l=t.expectHTML,u=t.isUnaryTag||Gr,f=0;e;){if(a=e,s&&Na(s,t.sfc,c)){var d=s.toLowerCase(),p=La[d]||(La[d]=new RegExp("([\\s\\S]*?)(]*>)","i")),v=0,h=e.replace(p,function(e,n,r){return v=r.length,"script"!==d&&"style"!==d&&"noscript"!==d&&(n=n.replace(//g,"$1").replace(//g,"$1")),t.chars&&t.chars(n),""});f+=e.length-h.length,e=h,o("",d,f-v,f)}else{var m=e.indexOf("<");if(0===m){if(ra.test(e)){var g=e.indexOf("-->");if(g>=0){n(g+3);continue}}if(ia.test(e)){var y=e.indexOf("]>");if(y>=0){n(y+2);continue}}var _=e.match(na);if(_){n(_[0].length);continue}var b=e.match(ta);if(b){var $=f;n(b[0].length),o(b[0],b[1],$,f);continue}var w=r();if(w){i(w);continue}}var x=void 0,C=void 0,k=void 0;if(m>0){for(C=e.slice(m);!(ta.test(C)||Xo.test(C)||ra.test(C)||ia.test(C)||(k=C.indexOf("<",1),k<0));)m+=k,C=e.slice(m);x=e.substring(0,m),n(m)}m<0&&(x=e,e=""),t.chars&&x&&t.chars(x)}if(e===a&&t.chars){t.chars(e);break}}o()}function ln(e){function t(){(a||(a=[])).push(e.slice(v,i).trim()),v=i+1}var n,r,i,o,a,s=!1,c=!1,l=!1,u=!1,f=0,d=0,p=0,v=0;for(i=0;ia&&o.push(JSON.stringify(e.slice(a,i)));var s=ln(r[1].trim());o.push("_s("+s+")"),a=i+r[0].length}return a=aa}function xn(e){return 34===e||39===e}function Cn(e){var t=1;for(ua=la;!wn();)if(e=$n(),xn(e))kn(e);else if(91===e&&t++,93===e&&t--,0===t){fa=la;break}}function kn(e){for(var t=e;!wn()&&(e=$n(),e!==t););}function An(e,t){da=t.warn||dn,pa=t.getTagNamespace||Gr,va=t.mustUseProp||Gr,ha=t.isPreTag||Gr,ma=pn(t.modules,"preTransformNode"),ga=pn(t.modules,"transformNode"),ya=pn(t.modules,"postTransformNode"),_a=t.delimiters;var n,r,i=[],o=t.preserveWhitespace!==!1,a=!1,s=!1;return cn(e,{expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,shouldDecodeNewlines:t.shouldDecodeNewlines,start:function(e,o,c){function l(e){}var u=r&&r.ns||pa(e);ni&&"svg"===u&&(o=zn(o));var f={type:1,tag:e,attrsList:o,attrsMap:Hn(o),parent:r,children:[]};u&&(f.ns=u),Vn(f)&&!si()&&(f.forbidden=!0);for(var d=0;d-1:_q("+t+","+o+")"),gn(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$c){$$i<0&&("+t+"=$$a.concat($$v))}else{$$i>-1&&("+t+"=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}}else{"+t+"=$$c}",null,!0)}function Tr(e,t,n){var r=n&&n.number,i=yn(e,"value")||"null";i=r?"_n("+i+")":i,vn(e,"checked","_q("+t+","+i+")"),gn(e,"change",Nr(t,i),null,!0)}function Er(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=o||ni&&"range"===r?"change":"input",l=!o&&"range"!==r,u="input"===e.tag||"textarea"===e.tag,f=u?"$event.target.value"+(s?".trim()":""):s?"(typeof $event === 'string' ? $event.trim() : $event)":"$event";f=a||"number"===r?"_n("+f+")":f;var d=Nr(t,f);u&&l&&(d="if($event.target.composing)return;"+d),vn(e,"value",u?"_s("+t+")":"("+t+")"),gn(e,c,d,null,!0)}function jr(e,t,n){var r=n&&n.number,i='Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(r?"_n(val)":"val")+"})"+(null==e.attrsMap.multiple?"[0]":""),o=Nr(t,i);gn(e,"change",o,null,!0)}function Nr(e,t){var n=bn(e);return null===n.idx?e+"="+t:"var $$exp = "+n.exp+", $$idx = "+n.idx+";if (!Array.isArray($$exp)){"+e+"="+t+"}else{$$exp.splice($$idx, 1, "+t+")}"}function Lr(e,t){t.value&&vn(e,"textContent","_s("+t.value+")")}function Dr(e,t){t.value&&vn(e,"innerHTML","_s("+t.value+")")}function Mr(e,t){return t=t?l(l({},ls),t):ls,wr(e,t)}function Pr(e,t,n){var r=(t&&t.warn||fi,t&&t.delimiters?String(t.delimiters)+e:e);if(cs[r])return cs[r];var i={},o=Mr(e,t);i.render=Rr(o.render);var a=o.staticRenderFns.length;i.staticRenderFns=new Array(a);for(var s=0;s0,ii=ti&&ti.indexOf("edge/")>0,oi=ti&&ti.indexOf("android")>0,ai=ti&&/iphone|ipad|ipod|ios/.test(ti),si=function(){return void 0===Fr&&(Fr=!ei&&"undefined"!=typeof global&&"server"===global.process.env.VUE_ENV),Fr},ci=ei&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,li=function(){function e(){r=!1;var e=n.slice(0);n.length=0;for(var t=0;t1&&(t[n[0].trim()]=n[1].trim())}}),t}),vo=/^--/,ho=/\s*!important$/,mo=function(e,t,n){vo.test(t)?e.style.setProperty(t,n):ho.test(n)?e.style.setProperty(t,n.replace(ho,""),"important"):e.style[yo(t)]=n},go=["Webkit","Moz","ms"],yo=a(function(e){if(Hi=Hi||document.createElement("div"),e=zr(e),"filter"!==e&&e in Hi.style)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=0;n\/=]+)/,Wo=/(?:=)/,Zo=[/"([^"]*)"+/.source,/'([^']*)'+/.source,/([^\s"'=<>`]+)/.source],Go=new RegExp("^\\s*"+qo.source+"(?:\\s*("+Wo.source+")\\s*(?:"+Zo.join("|")+"))?"),Yo="[a-zA-Z_][\\w\\-\\.]*",Qo="((?:"+Yo+"\\:)?"+Yo+")",Xo=new RegExp("^<"+Qo),ea=/^\s*(\/?)>/,ta=new RegExp("^<\\/"+Qo+"[^>]*>"),na=/^]+>/i,ra=/^/g,"$1").replace(//g,"$1")),t.chars&&t.chars(n),""});f+=e.length-h.length,e=h,a("",d,f-v,f)}else{var m=e.indexOf("<");if(0===m){if(uo.test(e)){var g=e.indexOf("-->");if(g>=0){n(g+3);continue}}if(fo.test(e)){var y=e.indexOf("]>");if(y>=0){n(y+2);continue}}var _=e.match(lo);if(_){n(_[0].length);continue}var b=e.match(co);if(b){var $=f;n(b[0].length),a(b[0],b[1],$,f);continue}var w=r();if(w){i(w);continue}}var x=void 0,C=void 0,k=void 0;if(m>0){for(C=e.slice(m);!(co.test(C)||oo.test(C)||uo.test(C)||fo.test(C)||(k=C.indexOf("<",1),k<0));)m+=k,C=e.slice(m);x=e.substring(0,m),n(m)}m<0&&(x=e,e=""),t.chars&&x&&t.chars(x)}if(e===o&&t.chars){t.chars(e);break}}a()}function pn(e){function t(){(o||(o=[])).push(e.slice(v,i).trim()),v=i+1}var n,r,i,a,o,s=!1,c=!1,l=!1,u=!1,f=0,d=0,p=0,v=0;for(i=0;i=0&&(m=e.charAt(h)," "===m);h--);m&&/[\w$]/.test(m)||(u=!0)}}else void 0===a?(v=i+1,a=e.slice(0,i).trim()):t();if(void 0===a?a=e.slice(0,i).trim():0!==v&&t(),o)for(i=0;io&&a.push(JSON.stringify(e.slice(o,i)));var s=pn(r[1].trim());a.push("_s("+s+")"),o=i+r[0].length}return o=vo}function On(e){return 34===e||39===e}function Sn(e){var t=1;for(yo=go;!An();)if(e=kn(),On(e))Tn(e);else if(91===e&&t++,93===e&&t--,0===t){_o=go;break}}function Tn(e){for(var t=e;!An()&&(e=kn(),e!==t););}function En(e,t){bo=t.warn||mn,$o=t.getTagNamespace||ti,wo=t.mustUseProp||ti,xo=t.isPreTag||ti,Co=gn(t.modules,"preTransformNode"),ko=gn(t.modules,"transformNode"),Ao=gn(t.modules,"postTransformNode"),Oo=t.delimiters;var n,r,i=[],a=t.preserveWhitespace!==!1,o=!1,s=!1;return dn(e,{expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,shouldDecodeNewlines:t.shouldDecodeNewlines,start:function(e,a,c){function l(e){}var u=r&&r.ns||$o(e);ci&&"svg"===u&&(a=Wn(a));var f={type:1,tag:e,attrsList:a,attrsMap:Jn(a),parent:r,children:[]};u&&(f.ns=u),qn(f)&&!pi()&&(f.forbidden=!0);for(var d=0;d-1:_q("+t+","+a+")"),$n(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+a+"):("+o+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$c){$$i<0&&("+t+"=$$a.concat($$v))}else{$$i>-1&&("+t+"=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}}else{"+t+"=$$c}",null,!0)}function Dr(e,t,n){var r=n&&n.number,i=wn(e,"value")||"null";i=r?"_n("+i+")":i,yn(e,"checked","_q("+t+","+i+")"),$n(e,"change",Rr(t,i),null,!0)}function Mr(e,t,n){var r=e.attrsMap.type,i=n||{},a=i.lazy,o=i.number,s=i.trim,c=a||ci&&"range"===r?"change":"input",l=!a&&"range"!==r,u="input"===e.tag||"textarea"===e.tag,f=u?"$event.target.value"+(s?".trim()":""):s?"(typeof $event === 'string' ? $event.trim() : $event)":"$event";f=o||"number"===r?"_n("+f+")":f;var d=Rr(t,f);u&&l&&(d="if($event.target.composing)return;"+d),yn(e,"value",u?"_s("+t+")":"("+t+")"),$n(e,c,d,null,!0),(s||o||"number"===r)&&$n(e,"blur","$forceUpdate()")}function Pr(e,t,n){var r=n&&n.number,i='Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(r?"_n(val)":"val")+"})"+(null==e.attrsMap.multiple?"[0]":""),a=Rr(t,i);$n(e,"change",a,null,!0)}function Rr(e,t){var n=Cn(e);return null===n.idx?e+"="+t:"var $$exp = "+n.exp+", $$idx = "+n.idx+";if (!Array.isArray($$exp)){"+e+"="+t+"}else{$$exp.splice($$idx, 1, "+t+")}"}function Ir(e,t){t.value&&yn(e,"textContent","_s("+t.value+")")}function Fr(e,t){t.value&&yn(e,"innerHTML","_s("+t.value+")")}function Ur(e,t){return t=t?l(l({},gs),t):gs,Or(e,t)}function Hr(e,t,n){var r=(t&&t.warn||gi,t&&t.delimiters?String(t.delimiters)+e:e);if(ms[r])return ms[r];var i={},a=Ur(e,t);i.render=Br(a.render);var o=a.staticRenderFns.length;i.staticRenderFns=new Array(o);for(var s=0;s0,ui=si&&si.indexOf("edge/")>0,fi=si&&si.indexOf("android")>0,di=si&&/iphone|ipad|ipod|ios/.test(si),pi=function(){return void 0===zr&&(zr=!oi&&"undefined"!=typeof global&&"server"===global.process.env.VUE_ENV),zr},vi=oi&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,hi=function(){function e(){r=!1;var e=n.slice(0);n.length=0;for(var t=0;t1&&(t[n[0].trim()]=n[1].trim())}}),t}),$a=/^--/,wa=/\s*!important$/,xa=function(e,t,n){$a.test(t)?e.style.setProperty(t,n):wa.test(n)?e.style.setProperty(t,n.replace(wa,""),"important"):e.style[ka(t)]=n},Ca=["Webkit","Moz","ms"],ka=o(function(e){if(Wi=Wi||document.createElement("div"),e=Zr(e),"filter"!==e&&e in Wi.style)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=0;n\/=]+)/,to=/(?:=)/,no=[/"([^"]*)"+/.source,/'([^']*)'+/.source,/([^\s"'=<>`]+)/.source],ro=new RegExp("^\\s*"+eo.source+"(?:\\s*("+to.source+")\\s*(?:"+no.join("|")+"))?"),io="[a-zA-Z_][\\w\\-\\.]*",ao="((?:"+io+"\\:)?"+io+")",oo=new RegExp("^<"+ao),so=/^\s*(\/?)>/,co=new RegExp("^<\\/"+ao+"[^>]*>"),lo=/^]+>/i,uo=/^') expect(vm.$children.length).toBe(0) function next () { expect(vm.$el.innerHTML).toBe('
hi
') @@ -151,7 +151,7 @@ describe('Component async', () => { } } }).$mount() - expect(vm.$el.innerHTML).toBe('') + expect(vm.$el.innerHTML).toBe('') expect(vm.$children.length).toBe(0) function next () { expect(vm.$el.innerHTML).toBe('
hi
') diff --git a/test/unit/features/directives/bind.spec.js b/test/unit/features/directives/bind.spec.js index f9d17a584a9..5635778569c 100644 --- a/test/unit/features/directives/bind.spec.js +++ b/test/unit/features/directives/bind.spec.js @@ -121,6 +121,18 @@ describe('Directive v-bind', () => { expect(vm.$el.children[1].innerHTML).toBe('qux') }) + it('.prop modifier with normal attribute binding', () => { + const vm = new Vue({ + template: '', + data: { + some: 'hello', + id: false + } + }).$mount() + expect(vm.$el.some).toBe('hello') + expect(vm.$el.getAttribute('id')).toBe(null) + }) + it('.camel modifier', () => { const vm = new Vue({ template: '', diff --git a/test/unit/features/directives/model-text.spec.js b/test/unit/features/directives/model-text.spec.js index f4ce9e451a7..8c4112832de 100644 --- a/test/unit/features/directives/model-text.spec.js +++ b/test/unit/features/directives/model-text.spec.js @@ -64,6 +64,61 @@ describe('Directive v-model text', () => { expect(vm.test).toBe('what') }) + it('.number focus and typing', (done) => { + const vm = new Vue({ + data: { + test: 0, + update: 0 + }, + template: + '
' + + '{{ update }}' + + '' + + '
' + }).$mount() + document.body.appendChild(vm.$el) + vm.$refs.input.focus() + expect(vm.test).toBe(0) + vm.$refs.input.value = '1.0' + triggerEvent(vm.$refs.input, 'input') + expect(vm.test).toBe(1) + vm.update++ + waitForUpdate(() => { + expect(vm.$refs.input.value).toBe('1.0') + vm.$refs.blur.focus() + vm.update++ + }).then(() => { + expect(vm.$refs.input.value).toBe('1') + }).then(done) + }) + + it('.trim focus and typing', (done) => { + const vm = new Vue({ + data: { + test: 'abc', + update: 0 + }, + template: + '
' + + '{{ update }}' + + '' + + '
' + }).$mount() + document.body.appendChild(vm.$el) + vm.$refs.input.focus() + vm.$refs.input.value = ' abc ' + triggerEvent(vm.$refs.input, 'input') + expect(vm.test).toBe('abc') + vm.update++ + waitForUpdate(() => { + expect(vm.$refs.input.value).toBe(' abc ') + vm.$refs.blur.focus() + vm.update++ + }).then(() => { + expect(vm.$refs.input.value).toBe('abc') + }).then(done) + }) + it('multiple inputs', (done) => { const spy = jasmine.createSpy() const vm = new Vue({ diff --git a/test/unit/features/filter/filter.spec.js b/test/unit/features/filter/filter.spec.js index 98e0630e2d9..2a506dce960 100644 --- a/test/unit/features/filter/filter.spec.js +++ b/test/unit/features/filter/filter.spec.js @@ -69,6 +69,15 @@ describe('Filters', () => { expect(vm.$refs.test.pattern.toString()).toBe('/a|b\\//') }) + it('handle division', () => { + const vm = new Vue({ + data: { a: 2 }, + template: `
{{ 1/a / 4 | double }}
`, + filters: { double: v => v * 2 } + }).$mount() + expect(vm.$el.textContent).toBe(String(1 / 4)) + }) + it('arguments', () => { const vm = new Vue({ template: `
{{ msg | add(a, 3) }}
`, diff --git a/test/unit/features/global-api/assets.spec.js b/test/unit/features/global-api/assets.spec.js index e0095025c8d..41e6b5fa6b7 100644 --- a/test/unit/features/global-api/assets.spec.js +++ b/test/unit/features/global-api/assets.spec.js @@ -48,4 +48,21 @@ describe('Global API: assets', () => { // extended registration should not pollute global expect(Vue.options.components.test).toBeUndefined() }) + + // #4434 + it('local registration should take priority regardless of naming convention', () => { + Vue.component('x-foo', { + template: 'global' + }) + const vm = new Vue({ + components: { + xFoo: { + template: 'local' + } + }, + template: '
' + }).$mount() + expect(vm.$el.textContent).toBe('local') + delete Vue.options.components['x-foo'] + }) }) diff --git a/test/unit/features/options/name.spec.js b/test/unit/features/options/name.spec.js index 74cccd0024f..2f586f85893 100644 --- a/test/unit/features/options/name.spec.js +++ b/test/unit/features/options/name.spec.js @@ -15,7 +15,16 @@ describe('Options name', () => { }) /* eslint-disable */ - expect(`Invalid component name: "Hyper*Vue". Component names can only contain alphanumeric characaters and the hyphen.`) + expect(`Invalid component name: "Hyper*Vue". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`) + .toHaveBeenWarned() + /* eslint-enable */ + + Vue.extend({ + name: '2Cool2BValid' + }) + + /* eslint-disable */ + expect(`Invalid component name: "2Cool2BValid". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`) .toHaveBeenWarned() /* eslint-enable */ }) diff --git a/test/unit/features/transition/transition.spec.js b/test/unit/features/transition/transition.spec.js index 3252153b0a4..d1ceeeafe8d 100644 --- a/test/unit/features/transition/transition.spec.js +++ b/test/unit/features/transition/transition.spec.js @@ -279,20 +279,32 @@ if (!isIE9) { data: { ok: true }, methods: { beforeLeave: (el) => { + expect(el.style.display).toBe('') expect(el).toBe(vm.$el.children[0]) expect(el.className).toBe('test') beforeLeaveSpy(el) }, - leave: (el) => onLeaveSpy(el), - afterLeave: (el) => afterLeaveSpy(el), + leave: (el) => { + expect(el.style.display).toBe('') + onLeaveSpy(el) + }, + afterLeave: (el) => { + expect(el.style.display).toBe('none') + afterLeaveSpy(el) + }, beforeEnter: (el) => { expect(el.className).toBe('test') + expect(el.style.display).toBe('none') beforeEnterSpy(el) }, enter: (el) => { + expect(el.style.display).toBe('') onEnterSpy(el) }, - afterEnter: (el) => afterEnterSpy(el) + afterEnter: (el) => { + expect(el.style.display).toBe('') + afterEnterSpy(el) + } } }).$mount(el) diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js index 25fae4ea16a..ecee02e8a50 100644 --- a/test/unit/modules/compiler/codegen.spec.js +++ b/test/unit/modules/compiler/codegen.spec.js @@ -33,130 +33,135 @@ describe('codegen', () => { it('generate directive', () => { assertCodegen( '

', - `with(this){return _h('p',{directives:[{name:"custom1",rawName:"v-custom1:arg1.modifier",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifier":true}},{name:"custom2",rawName:"v-custom2",arg:"arg1"}]})}` + `with(this){return _c('p',{directives:[{name:"custom1",rawName:"v-custom1:arg1.modifier",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifier":true}},{name:"custom2",rawName:"v-custom2",arg:"arg1"}]})}` ) }) it('generate filters', () => { assertCodegen( '
{{ d | e | f }}
', - `with(this){return _h('div',{attrs:{"id":_f("c")(_f("b")(a))}},[_s(_f("f")(_f("e")(d)))])}` + `with(this){return _c('div',{attrs:{"id":_f("c")(_f("b")(a))}},[_v(_s(_f("f")(_f("e")(d))))])}` ) }) it('generate v-for directive', () => { assertCodegen( '
  • ', - `with(this){return _h('div',[_l((items),function(item){return _h('li',{key:item.uid})})])}` + `with(this){return _c('div',_l((items),function(item){return _c('li',{key:item.uid})}))}` ) // iterator syntax assertCodegen( '
  • ', - `with(this){return _h('div',[_l((items),function(item,i){return _h('li')})])}` + `with(this){return _c('div',_l((items),function(item,i){return _c('li')}))}` ) assertCodegen( '
  • ', - `with(this){return _h('div',[_l((items),function(item,key,index){return _h('li')})])}` + `with(this){return _c('div',_l((items),function(item,key,index){return _c('li')}))}` ) // destructuring assertCodegen( '
  • ', - `with(this){return _h('div',[_l((items),function({ a, b }){return _h('li')})])}` + `with(this){return _c('div',_l((items),function({ a, b }){return _c('li')}))}` ) assertCodegen( '
  • ', - `with(this){return _h('div',[_l((items),function({ a, b },key,index){return _h('li')})])}` + `with(this){return _c('div',_l((items),function({ a, b },key,index){return _c('li')}))}` + ) + // v-for with extra element + assertCodegen( + '

  • ', + `with(this){return _c('div',[_c('p'),_l((items),function(item){return _c('li')})],true)}` ) }) it('generate v-if directive', () => { assertCodegen( '

    hello

    ', - `with(this){return (show)?_h('p',["hello"]):_e()}` + `with(this){return (show)?_c('p',[_v("hello")]):_e()}` ) }) it('generate v-else directive', () => { assertCodegen( '

    hello

    world

    ', - `with(this){return _h('div',[(show)?_h('p',["hello"]):_h('p',["world"])])}` + `with(this){return _c('div',[(show)?_c('p',[_v("hello")]):_c('p',[_v("world")])])}` ) }) it('generate v-else-if directive', () => { assertCodegen( '

    hello

    world

    ', - `with(this){return _h('div',[(show)?_h('p',["hello"]):(hide)?_h('p',["world"]):_e()])}` + `with(this){return _c('div',[(show)?_c('p',[_v("hello")]):(hide)?_c('p',[_v("world")]):_e()])}` ) }) it('generate v-else-if with v-else directive', () => { assertCodegen( '

    hello

    world

    bye

    ', - `with(this){return _h('div',[(show)?_h('p',["hello"]):(hide)?_h('p',["world"]):_h('p',["bye"])])}` + `with(this){return _c('div',[(show)?_c('p',[_v("hello")]):(hide)?_c('p',[_v("world")]):_c('p',[_v("bye")])])}` ) }) it('generate mutli v-else-if with v-else directive', () => { assertCodegen( '

    hello

    world

    elseif

    bye

    ', - `with(this){return _h('div',[(show)?_h('p',["hello"]):(hide)?_h('p',["world"]):(3)?_h('p',["elseif"]):_h('p',["bye"])])}` + `with(this){return _c('div',[(show)?_c('p',[_v("hello")]):(hide)?_c('p',[_v("world")]):(3)?_c('p',[_v("elseif")]):_c('p',[_v("bye")])])}` ) }) it('generate ref', () => { assertCodegen( '

    ', - `with(this){return _h('p',{ref:"component1"})}` + `with(this){return _c('p',{ref:"component1"})}` ) }) it('generate ref on v-for', () => { assertCodegen( '
    ', - `with(this){return _h('ul',[_l((items),function(item){return _h('li',{ref:"component1",refInFor:true})})])}` + `with(this){return _c('ul',_l((items),function(item){return _c('li',{ref:"component1",refInFor:true})}))}` ) }) it('generate v-bind directive', () => { assertCodegen( '

    ', - `with(this){return _h('p',_b({},'p',test))}` + `with(this){return _c('p',_b({},'p',test))}` ) }) it('generate template tag', () => { assertCodegen( '
    ', - `with(this){return _h('div',[[_h('p',[_s(hello)])]])}` + `with(this){return _c('div',[[_c('p',[_v(_s(hello))])]],true)}` ) }) it('generate single slot', () => { assertCodegen( '
    ', - `with(this){return _h('div',[_t("default")])}` + `with(this){return _c('div',[_t("default")],true)}` ) }) it('generate named slot', () => { assertCodegen( '
    ', - `with(this){return _h('div',[_t("one")])}` + `with(this){return _c('div',[_t("one")],true)}` ) }) it('generate slot fallback content', () => { assertCodegen( '
    hi
    ', - `with(this){return _h('div',[_t("default",[_h('div',["hi"])])])}` + `with(this){return _c('div',[_t("default",[_c('div',[_v("hi")])])],true)}` ) }) it('generate slot target', () => { assertCodegen( '

    hello world

    ', - `with(this){return _h('p',{slot:"one"},["hello world"])}` + `with(this){return _c('p',{slot:"one"},[_v("hello world")])}` ) }) @@ -164,26 +169,26 @@ describe('codegen', () => { // static assertCodegen( '

    hello world

    ', - `with(this){return _h('p',{staticClass:"class1"},["hello world"])}`, + `with(this){return _c('p',{staticClass:"class1"},[_v("hello world")])}`, ) // dynamic assertCodegen( '

    hello world

    ', - `with(this){return _h('p',{class:class1},["hello world"])}` + `with(this){return _c('p',{class:class1},[_v("hello world")])}` ) }) it('generate style binding', () => { assertCodegen( '

    hello world

    ', - `with(this){return _h('p',{style:(error)},["hello world"])}` + `with(this){return _c('p',{style:(error)},[_v("hello world")])}` ) }) it('generate v-show directive', () => { assertCodegen( '

    hello world

    ', - `with(this){return _h('p',{directives:[{name:"show",rawName:"v-show",value:(shown),expression:"shown"}]},["hello world"])}` + `with(this){return _c('p',{directives:[{name:"show",rawName:"v-show",value:(shown),expression:"shown"}]},[_v("hello world")])}` ) }) @@ -191,136 +196,136 @@ describe('codegen', () => { // input + value assertCodegen( '', - `with(this){return _h('input',{domProps:{"value":msg}})}` + `with(this){return _c('input',{domProps:{"value":msg}})}` ) // non input assertCodegen( '

    ', - `with(this){return _h('p',{attrs:{"value":msg}})}` + `with(this){return _c('p',{attrs:{"value":msg}})}` ) }) it('generate attrs with v-bind directive', () => { assertCodegen( '', - `with(this){return _h('input',{attrs:{"name":field1}})}` + `with(this){return _c('input',{attrs:{"name":field1}})}` ) }) it('generate static attrs', () => { assertCodegen( '', - `with(this){return _h('input',{attrs:{"name":"field1"}})}` + `with(this){return _c('input',{attrs:{"name":"field1"}})}` ) }) it('generate events with v-on directive', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":onInput}})}` + `with(this){return _c('input',{on:{"input":onInput}})}` ) }) it('generate events with keycode', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){if(_k($event.keyCode,"enter",13))return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){if(_k($event.keyCode,"enter",13))return;onInput($event)}}})}` ) // multiple keycodes (delete) assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){if(_k($event.keyCode,"delete",[8,46]))return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){if(_k($event.keyCode,"delete",[8,46]))return;onInput($event)}}})}` ) // multiple keycodes (chained) assertCodegen( '', - `with(this){return _h('input',{on:{"keydown":function($event){if(_k($event.keyCode,"enter",13)&&_k($event.keyCode,"delete",[8,46]))return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"keydown":function($event){if(_k($event.keyCode,"enter",13)&&_k($event.keyCode,"delete",[8,46]))return;onInput($event)}}})}` ) // number keycode assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){if($event.keyCode!==13)return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){if($event.keyCode!==13)return;onInput($event)}}})}` ) // custom keycode assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){if(_k($event.keyCode,"custom"))return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){if(_k($event.keyCode,"custom"))return;onInput($event)}}})}` ) }) it('generate events with generic modifiers', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){$event.stopPropagation();onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){$event.stopPropagation();onInput($event)}}})}` ) assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){$event.preventDefault();onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){$event.preventDefault();onInput($event)}}})}` ) assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){if($event.target !== $event.currentTarget)return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){if($event.target !== $event.currentTarget)return;onInput($event)}}})}` ) }) it('generate events with mouse event modifiers', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"click":function($event){if(!$event.ctrlKey)return;onClick($event)}}})}` + `with(this){return _c('input',{on:{"click":function($event){if(!$event.ctrlKey)return;onClick($event)}}})}` ) assertCodegen( '', - `with(this){return _h('input',{on:{"click":function($event){if(!$event.shiftKey)return;onClick($event)}}})}` + `with(this){return _c('input',{on:{"click":function($event){if(!$event.shiftKey)return;onClick($event)}}})}` ) assertCodegen( '', - `with(this){return _h('input',{on:{"click":function($event){if(!$event.altKey)return;onClick($event)}}})}` + `with(this){return _c('input',{on:{"click":function($event){if(!$event.altKey)return;onClick($event)}}})}` ) assertCodegen( '', - `with(this){return _h('input',{on:{"click":function($event){if(!$event.metaKey)return;onClick($event)}}})}` + `with(this){return _c('input',{on:{"click":function($event){if(!$event.metaKey)return;onClick($event)}}})}` ) }) it('generate events with multiple modifers', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){$event.stopPropagation();$event.preventDefault();if($event.target !== $event.currentTarget)return;onInput($event)}}})}` + `with(this){return _c('input',{on:{"input":function($event){$event.stopPropagation();$event.preventDefault();if($event.target !== $event.currentTarget)return;onInput($event)}}})}` ) }) it('generate events with capture modifier', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"!input":function($event){onInput($event)}}})}` + `with(this){return _c('input',{on:{"!input":function($event){onInput($event)}}})}` ) }) it('generate events with once modifier', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"~input":function($event){onInput($event)}}})}` + `with(this){return _c('input',{on:{"~input":function($event){onInput($event)}}})}` ) }) it('generate events with capture and once modifier', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"~!input":function($event){onInput($event)}}})}` + `with(this){return _c('input',{on:{"~!input":function($event){onInput($event)}}})}` ) }) it('generate events with once and capture modifier', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"~!input":function($event){onInput($event)}}})}` + `with(this){return _c('input',{on:{"~!input":function($event){onInput($event)}}})}` ) }) it('generate events with inline statement', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":function($event){curent++}}})}` + `with(this){return _c('input',{on:{"input":function($event){curent++}}})}` ) }) @@ -328,32 +333,32 @@ describe('codegen', () => { // normal function assertCodegen( '', - `with(this){return _h('input',{on:{"input":function () { current++ }}})}` + `with(this){return _c('input',{on:{"input":function () { current++ }}})}` ) // arrow with no args assertCodegen( '', - `with(this){return _h('input',{on:{"input":()=>current++}})}` + `with(this){return _c('input',{on:{"input":()=>current++}})}` ) // arrow with parens, single arg assertCodegen( '', - `with(this){return _h('input',{on:{"input":(e) => current++}})}` + `with(this){return _c('input',{on:{"input":(e) => current++}})}` ) // arrow with parens, multi args assertCodegen( '', - `with(this){return _h('input',{on:{"input":(a, b, c) => current++}})}` + `with(this){return _c('input',{on:{"input":(a, b, c) => current++}})}` ) // arrow with destructuring assertCodegen( '', - `with(this){return _h('input',{on:{"input":({ a, b }) => current++}})}` + `with(this){return _c('input',{on:{"input":({ a, b }) => current++}})}` ) // arrow single arg no parens assertCodegen( '', - `with(this){return _h('input',{on:{"input":e=>current++}})}` + `with(this){return _c('input',{on:{"input":e=>current++}})}` ) }) @@ -361,14 +366,14 @@ describe('codegen', () => { it('should not treat handler with unexpected whitespace as inline statement', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input": onInput }})}` + `with(this){return _c('input',{on:{"input": onInput }})}` ) }) it('generate unhandled events', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":function(){}}})}`, + `with(this){return _c('input',{on:{"input":function(){}}})}`, ast => { ast.events.input = undefined } @@ -378,32 +383,32 @@ describe('codegen', () => { it('generate multiple event handlers', () => { assertCodegen( '', - `with(this){return _h('input',{on:{"input":[function($event){curent++},function($event){$event.stopPropagation();onInput($event)}]}})}` + `with(this){return _c('input',{on:{"input":[function($event){curent++},function($event){$event.stopPropagation();onInput($event)}]}})}` ) }) it('generate component', () => { assertCodegen( '

    hi
    ', - `with(this){return _h('my-component',{attrs:{"name":"mycomponent1","msg":msg},on:{"notify":onNotify}},[_h('div',["hi"])])}` + `with(this){return _c('my-component',{attrs:{"name":"mycomponent1","msg":msg},on:{"notify":onNotify}},[_c('div',[_v("hi")])])}` ) }) it('generate svg component with children', () => { assertCodegen( '', - `with(this){return _h('svg',[_h('my-comp',[_h('circle',{attrs:{"r":10}})])])}` + `with(this){return _c('svg',[_c('my-comp',[_c('circle',{attrs:{"r":10}})])])}` ) }) it('generate is attribute', () => { assertCodegen( '
    ', - `with(this){return _h("component1",{tag:"div"})}` + `with(this){return _c("component1",{tag:"div"})}` ) assertCodegen( '
    ', - `with(this){return _h(component1,{tag:"div"})}` + `with(this){return _c(component1,{tag:"div"})}` ) }) @@ -411,12 +416,12 @@ describe('codegen', () => { // have "inline-template'" assertCodegen( '

    hello world

    ', - `with(this){return _h('my-component',{inlineTemplate:{render:function(){with(this){return _m(0)}},staticRenderFns:[function(){with(this){return _h('p',[_h('span',["hello world"])])}}]}})}` + `with(this){return _c('my-component',{inlineTemplate:{render:function(){with(this){return _m(0)}},staticRenderFns:[function(){with(this){return _c('p',[_c('span',[_v("hello world")])])}}]}})}` ) // "have inline-template attrs, but not having extactly one child element assertCodegen( '

    ', - `with(this){return _h('my-component',{inlineTemplate:{render:function(){with(this){return _h('hr')}},staticRenderFns:[]}})}` + `with(this){return _c('my-component',{inlineTemplate:{render:function(){with(this){return _c('hr')}},staticRenderFns:[]}})}` ) expect('Inline-template components must have exactly one child element.').toHaveBeenWarned() }) @@ -424,21 +429,21 @@ describe('codegen', () => { it('generate static trees inside v-for', () => { assertCodegen( `

    `, - `with(this){return _h('div',[_l((10),function(i){return _h('div',[_m(0,true)])})])}`, - [`with(this){return _h('p',[_h('span')])}`] + `with(this){return _c('div',_l((10),function(i){return _c('div',[_m(0,true)])}))}`, + [`with(this){return _c('p',[_c('span')])}`] ) }) it('not specified ast type', () => { const res = generate(null, baseOptions) - expect(res.render).toBe(`with(this){return _h("div")}`) + expect(res.render).toBe(`with(this){return _c("div")}`) expect(res.staticRenderFns).toEqual([]) }) it('not specified directives option', () => { assertCodegen( '

    hello world

    ', - `with(this){return (show)?_h('p',["hello world"]):_e()}`, + `with(this){return (show)?_c('p',[_v("hello world")]):_e()}`, { isReservedTag } ) }) diff --git a/test/unit/modules/compiler/compiler-options.spec.js b/test/unit/modules/compiler/compiler-options.spec.js index 405458cc3df..e5017f22f84 100644 --- a/test/unit/modules/compiler/compiler-options.spec.js +++ b/test/unit/modules/compiler/compiler-options.spec.js @@ -51,7 +51,7 @@ describe('compile options', () => { result[validator.name] = null }) // generate code - return `_h('validate',{props:{ + return `_c('validate',{props:{ field:${JSON.stringify(el.validate.field)}, groups:${JSON.stringify(el.validate.groups)}, validators:${JSON.stringify(el.validators)}, diff --git a/test/unit/modules/vdom/create-element.spec.js b/test/unit/modules/vdom/create-element.spec.js index 52450b8a842..79a9813a2ce 100644 --- a/test/unit/modules/vdom/create-element.spec.js +++ b/test/unit/modules/vdom/create-element.spec.js @@ -1,14 +1,12 @@ import Vue from 'vue' -import { createElement } from 'core/vdom/create-element' -import { emptyVNode } from 'core/vdom/vnode' -import { bind } from 'shared/util' +import { createEmptyVNode } from 'core/vdom/vnode' describe('create-element', () => { it('render vnode with basic reserved tag using createElement', () => { const vm = new Vue({ data: { msg: 'hello world' } }) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h('p', {}) expect(vnode.tag).toBe('p') expect(vnode.data).toEqual({}) @@ -28,7 +26,7 @@ describe('create-element', () => { } } }) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h('my-component', { props: { msg: vm.message }}) expect(vnode.tag).toMatch(/vue-component-[0-9]+/) expect(vnode.componentOptions.propsData).toEqual({ msg: vm.message }) @@ -43,7 +41,7 @@ describe('create-element', () => { const vm = new Vue({ data: { msg: 'hello world' } }) - const h = bind(createElement, vm) + const h = vm.$createElement const tag = 'custom-tag' const vnode = h(tag, {}) expect(vnode.tag).toBe('custom-tag') @@ -60,16 +58,16 @@ describe('create-element', () => { const vm = new Vue({ data: { msg: 'hello world' } }) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h(null, {}) - expect(vnode).toEqual(emptyVNode()) + expect(vnode).toEqual(createEmptyVNode()) }) it('render vnode with not string tag using createElement', () => { const vm = new Vue({ data: { msg: 'hello world' } }) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h(Vue.extend({ // Component class props: ['msg'] }), { props: { msg: vm.message }}) @@ -84,7 +82,7 @@ describe('create-element', () => { it('render vnode with createElement with children', () => { const vm = new Vue({}) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h('p', void 0, [h('br'), 'hello world', h('br')]) expect(vnode.children[0].tag).toBe('br') expect(vnode.children[1].text).toBe('hello world') @@ -93,7 +91,7 @@ describe('create-element', () => { it('render vnode with children, omitting data', () => { const vm = new Vue({}) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h('p', [h('br'), 'hello world', h('br')]) expect(vnode.children[0].tag).toBe('br') expect(vnode.children[1].text).toBe('hello world') @@ -102,7 +100,7 @@ describe('create-element', () => { it('render svg elements with correct namespace', () => { const vm = new Vue({}) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h('svg', [h('a', [h('foo', [h('bar')])])]) expect(vnode.ns).toBe('svg') // should apply ns to children recursively @@ -113,7 +111,7 @@ describe('create-element', () => { it('render MathML elements with correct namespace', () => { const vm = new Vue({}) - const h = bind(createElement, vm) + const h = vm.$createElement const vnode = h('math', [h('matrix')]) expect(vnode.ns).toBe('math') // should apply ns to children diff --git a/test/unit/modules/vdom/modules/directive.spec.js b/test/unit/modules/vdom/modules/directive.spec.js index f9e780c4c2f..f77d120b8b3 100644 --- a/test/unit/modules/vdom/modules/directive.spec.js +++ b/test/unit/modules/vdom/modules/directive.spec.js @@ -16,7 +16,7 @@ describe('vdom directive module', () => { directives: [{ name: 'directive1', value: 'hello', arg: 'arg1', modifiers: { modifire1: true } }] - }, undefined, 'hello world', undefined, undefined, vm) + }, undefined, 'hello world', undefined, vm) ]) patch(null, vnode1) expect(directive1.bind).toHaveBeenCalled() @@ -26,7 +26,7 @@ describe('vdom directive module', () => { directives: [{ name: 'directive1', value: 'world', arg: 'arg1', modifiers: { modifire1: true } }] - }, undefined, 'hello world', undefined, undefined, vm) + }, undefined, 'hello world', undefined, vm) ]) patch(vnode1, vnode2) expect(directive1.update).toHaveBeenCalled() diff --git a/test/unit/modules/vdom/patch/element.spec.js b/test/unit/modules/vdom/patch/element.spec.js index 0894b0a4ebb..09bf3fa6ef8 100644 --- a/test/unit/modules/vdom/patch/element.spec.js +++ b/test/unit/modules/vdom/patch/element.spec.js @@ -11,7 +11,8 @@ describe('vdom patch: element', () => { }) it('should create an element which having the namespace', () => { - const vnode = new VNode('svg', {}, undefined, undefined, undefined, 'svg') + const vnode = new VNode('svg', {}) + vnode.ns = 'svg' const elm = patch(null, vnode) expect(elm.namespaceURI).toBe('http://www.w3.org/2000/svg') }) diff --git a/test/weex/compiler/compile.spec.js b/test/weex/compiler/compile.spec.js index a3603fcc785..5a900a230da 100644 --- a/test/weex/compiler/compile.spec.js +++ b/test/weex/compiler/compile.spec.js @@ -3,28 +3,28 @@ import { compile } from '../../../packages/weex-template-compiler' describe('compile basic', () => { it('should be compiled', () => { const { render, staticRenderFns, errors } = compile(`
    {{hi}}
    `) - expect(render).toEqual(`with(this){return _h('div',[_s(hi)])}`) + expect(render).toEqual(`with(this){return _c('div',[_v(_s(hi))])}`) expect(staticRenderFns.length).toBe(0) expect(errors).toEqual([]) }) it('should compile data bindings', () => { const { render, staticRenderFns, errors } = compile(`
    `) - expect(render).toEqual(`with(this){return _h('div',{attrs:{"a":b}})}`) + expect(render).toEqual(`with(this){return _c('div',{attrs:{"a":b}})}`) expect(staticRenderFns).toEqual([]) expect(errors).toEqual([]) }) it('should compile event bindings', () => { const { render, staticRenderFns, errors } = compile(`
    `) - expect(render).toEqual(`with(this){return _h('div',{on:{"click":x}})}`) + expect(render).toEqual(`with(this){return _c('div',{on:{"click":x}})}`) expect(staticRenderFns).toEqual([]) expect(errors).toEqual([]) }) it('should compile data bindings with children', () => { const { render, staticRenderFns, errors } = compile(`Hello`) - expect(render).toEqual(`with(this){return _h('foo',{attrs:{"a":b}},[_h('text',["Hello"])])}`) + expect(render).toEqual(`with(this){return _c('foo',{attrs:{"a":b}},[_c('text',[_v("Hello")])])}`) expect(staticRenderFns).toEqual([]) expect(errors).toEqual([]) }) @@ -38,7 +38,7 @@ describe('compile basic', () => { Load more... `) - expect(render).toEqual(`with(this){return _h('refresh',{staticClass:["refresh"],staticStyle:{flexDirection:"row"},attrs:{"display":displayRefresh},on:{"refresh":handleRefresh}},[_h('loading-indicator'),_h('text',{staticStyle:{marginLeft:"36px",color:"#eee"}},["Load more..."])])}`) + expect(render).toEqual(`with(this){return _c('refresh',{staticClass:["refresh"],staticStyle:{flexDirection:"row"},attrs:{"display":displayRefresh},on:{"refresh":handleRefresh}},[_c('loading-indicator'),_c('text',{staticStyle:{marginLeft:"36px",color:"#eee"}},[_v("Load more...")])])}`) expect(staticRenderFns).toEqual([]) expect(errors).toEqual([]) })