From c2ac97e9ab81609b628bc146b2e2c81cfa27054d Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 13 Jul 2017 13:41:30 +0800 Subject: [PATCH 0001/1224] update api docs for 2.4.0 --- src/v2/api/index.md | 77 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index e91e1660df..bffc7b524e 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -81,8 +81,28 @@ type: api > In 2.2.0, this hook also captures errors in component lifecycle hooks. Also, when this hook is `undefined`, captured errors will be logged with `console.error` instead of crashing the app. + > In 2.4.0 this hook also captures errors thrown inside Vue custom event handlers. + > [Sentry](https://sentry.io), an error tracking service, provides [official integration](https://sentry.io/for/vue/) using this option. +### warnHandler + +> New in 2.4.0 + +- **Type:** `Function` + +- **Default:** `undefined` + +- **Usage:** + + ``` js + Vue.config.warnHandler = function (msg, vm, trace) { + // trace is the component hierarchy trace + } + ``` + + Assign a custom handler for runtime Vue warnings. Note this only works during development and is ignored in production. + ### ignoredElements - **Type:** `Array` @@ -1009,7 +1029,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc - **Type:** `Array` -- **default:** `{% raw %}["{{", "}}"]{% endraw %}` +- **Default:** `{% raw %}["{{", "}}"]{% endraw %}` - **Details:** @@ -1080,6 +1100,30 @@ All lifecycle hooks automatically have their `this` context bound to the instanc ``` +### inheritAttrs + +> New in 2.4.0 + +- **Type:** `boolean` + +- **Default:** `true` + +- **Details:** + + By default, parent scope attribute bindings that are not recognized as props will "fallthrough" and be applied to the root element of the child component as normal HTML attributes. When authoring a component that wraps a target element or another component, this may not always be the desired behavior. By setting `inheritAttrs` to `false`, this default behavior can be disabled. The attributes are available via the `$attrs` instance property (also new in 2.4) and can be explicitly bound to a non-root element using `v-bind`. + +### comments + +> New in 2.4.0 + +- **Type:** `boolean` + +- **Default:** `false` + +- **Details:** + + When set to `true`, will preserve and render HTML comments found in templates. The default behavior is discarding them. + ## Instance Properties ### vm.$data @@ -1256,13 +1300,33 @@ All lifecycle hooks automatically have their `this` context bound to the instanc - **See also:** [Server-Side Rendering](../guide/ssr.html) +### vm.$attrs + +- **Type:** `{ [key: string]: string }` + +- **Read only** + +- **Details:** + + Contains parent-scope attribute bindings that are not recognized (and extracted) as props. When a component doesn't have any declared props, this essentially contains all parent-scope bindings except for `class` and `style`, and can be passed down to an inner component via `v-bind="$attrs"` - useful when creating higher-order components. + +### vm.$listeners + +- **Type:** `{ [key: string]: Function | Array }` + +- **Read only** + +- **Details:** + + Contains parent-scope `v-on` event listeners (without `.native` modifiers). This can be passed down to an inner component via `v-on="$listeners"` - useful when creating higher-order components. + ## Instance Methods / Data

vm.$watch( expOrFn, callback, [options] )

- **Arguments:** - `{string | Function} expOrFn` - - `{Function} callback` + - `{Function | Object} callback` - `{Object} [options]` - `{boolean} deep` - `{boolean} immediate` @@ -1658,9 +1722,9 @@ All lifecycle hooks automatically have their `this` context bound to the instanc - **Shorthand:** `@` -- **Expects:** `Function | Inline Statement` +- **Expects:** `Function | Inline Statement | Object` -- **Argument:** `event (required)` +- **Argument:** `event` - **Modifiers:** - `.stop` - call `event.stopPropagation()`. @@ -1679,6 +1743,8 @@ All lifecycle hooks automatically have their `this` context bound to the instanc Attaches an event listener to the element. The event type is denoted by the argument. The expression can either be a method name or an inline statement, or simply omitted when there are modifiers present. + Starting in `2.4.0`, `v-on` also supports binding to an object of event/listener pairs without an argument. Note when using the object syntax, it does not support any modifiers. + When used on a normal element, it listens to **native DOM events** only. When used on a custom element component, it also listens to **custom events** emitted on that child component. When listening to native DOM events, the method receives the native event as the only argument. If using inline statement, the statement has access to the special `$event` property: `v-on:click="handle('ok', $event)"`. @@ -1689,6 +1755,9 @@ All lifecycle hooks automatically have their `this` context bound to the instanc + + + From 29b9520e5dd1bdab72077e0ac6a8f2ffec8c3aad Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 13 Jul 2017 13:41:56 +0800 Subject: [PATCH 0002/1224] adjust size on index --- themes/vue/layout/index.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/vue/layout/index.ejs b/themes/vue/layout/index.ejs index 73ce22ab9f..24e5d1761c 100644 --- a/themes/vue/layout/index.ejs +++ b/themes/vue/layout/index.ejs @@ -38,7 +38,7 @@

Performant

- 19kb min+gzip Runtime
+ 20kb min+gzip Runtime
Blazing Fast Virtual DOM
Minimal Optimization Efforts

From aa38432422e8a994041eadfbbf9cab6c5f6a3a5c Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 13 Jul 2017 14:05:10 +0800 Subject: [PATCH 0003/1224] 2.4.0 --- src/v2/guide/installation.md | 10 +- themes/vue/_config.yml | 2 +- themes/vue/source/js/vue.js | 1702 +++++++++++++++++++------------ themes/vue/source/js/vue.min.js | 6 +- 4 files changed, 1081 insertions(+), 639 deletions(-) diff --git a/src/v2/guide/installation.md b/src/v2/guide/installation.md index 6308fd661b..e7430d2c7d 100644 --- a/src/v2/guide/installation.md +++ b/src/v2/guide/installation.md @@ -2,11 +2,11 @@ title: Installation type: guide order: 1 -vue_version: 2.3.0 -dev_size: "247.31" -min_size: "76.64" -gz_size: "28.03" -ro_gz_size: "19.54" +vue_version: 2.4.0 +dev_size: "257.91" +min_size: "79.71" +gz_size: "28.96" +ro_gz_size: "20.18" --- ### Compatibility Note diff --git a/themes/vue/_config.yml b/themes/vue/_config.yml index bd905b272b..a95fd93163 100644 --- a/themes/vue/_config.yml +++ b/themes/vue/_config.yml @@ -1,4 +1,4 @@ site_description: "Vue.js - The Progressive JavaScript Framework" google_analytics: UA-46852172-1 root_domain: vuejs.org -vue_version: 2.3.0 +vue_version: 2.4.0 diff --git a/themes/vue/source/js/vue.js b/themes/vue/source/js/vue.js index 510e4b563e..6ecd1b6912 100644 --- a/themes/vue/source/js/vue.js +++ b/themes/vue/source/js/vue.js @@ -1,5 +1,5 @@ /*! - * Vue.js v2.3.0 + * Vue.js v2.4.0 * (c) 2014-2017 Evan You * Released under the MIT License. */ @@ -25,6 +25,10 @@ function isTrue (v) { return v === true } +function isFalse (v) { + return v === false +} + /** * Check if value is primitive */ @@ -41,24 +45,32 @@ function isObject (obj) { return obj !== null && typeof obj === 'object' } -var toString = Object.prototype.toString; +var _toString = Object.prototype.toString; /** * Strict object type check. Only returns true * for plain JavaScript objects. */ function isPlainObject (obj) { - return toString.call(obj) === '[object Object]' + return _toString.call(obj) === '[object Object]' } function isRegExp (v) { - return toString.call(v) === '[object RegExp]' + return _toString.call(v) === '[object RegExp]' +} + +/** + * Check if val is a valid array index. + */ +function isValidArrayIndex (val) { + var n = parseFloat(val); + return n >= 0 && Math.floor(n) === n && isFinite(val) } /** * Convert a value to a string that is actually rendered. */ -function _toString (val) { +function toString (val) { return val == null ? '' : typeof val === 'object' @@ -98,6 +110,11 @@ function makeMap ( */ var isBuiltInTag = makeMap('slot,component', true); +/** + * Check if a attribute is a reserved attribute. + */ +var isReservedAttribute = makeMap('key,ref,slot,is'); + /** * Remove an item from an array */ @@ -210,13 +227,15 @@ function toObject (arr) { /** * Perform no operation. + * Stubbing args to make Flow happy without leaving useless transpiled code + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) */ -function noop () {} +function noop (a, b, c) {} /** * Always return false. */ -var no = function () { return false; }; +var no = function (a, b, c) { return false; }; /** * Return same value @@ -327,6 +346,11 @@ var config = ({ */ errorHandler: null, + /** + * Warn handler for watcher warns + */ + warnHandler: null, + /** * Ignore certain custom elements */ @@ -419,9 +443,11 @@ function parsePath (path) { } } +/* */ + var warn = noop; var tip = noop; -var formatComponentName; +var formatComponentName = (null); // work around flow check { var hasConsole = typeof console !== 'undefined'; @@ -431,10 +457,12 @@ var formatComponentName; .replace(/[-_]/g, ''); }; warn = function (msg, vm) { - if (hasConsole && (!config.silent)) { - console.error("[Vue warn]: " + msg + ( - vm ? generateComponentTrace(vm) : '' - )); + var trace = vm ? generateComponentTrace(vm) : ''; + + if (config.warnHandler) { + config.warnHandler.call(null, msg, vm, trace); + } else if (hasConsole && (!config.silent)) { + console.error(("[Vue warn]: " + msg + trace)); } }; @@ -510,6 +538,8 @@ var formatComponentName; }; } +/* */ + function handleError (err, vm, info) { if (config.errorHandler) { config.errorHandler.call(null, err, vm, info); @@ -542,6 +572,9 @@ var isAndroid = UA && UA.indexOf('android') > 0; var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; +// Firefix has a "watch" function on Object.prototype... +var nativeWatch = ({}).watch; + var supportsPassive = false; if (inBrowser) { try { @@ -551,7 +584,7 @@ if (inBrowser) { /* istanbul ignore next */ supportsPassive = true; } - } )); // https://github.com/facebook/flow/issues/285 + })); // https://github.com/facebook/flow/issues/285 window.addEventListener('test-passive', null, opts); } catch (e) {} } @@ -766,22 +799,14 @@ var arrayMethods = Object.create(arrayProto);[ // cache original method var original = arrayProto[method]; def(arrayMethods, method, function mutator () { - var arguments$1 = arguments; + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; - // avoid leaking arguments: - // http://jsperf.com/closure-with-arguments - var i = arguments.length; - var args = new Array(i); - while (i--) { - args[i] = arguments$1[i]; - } var result = original.apply(this, args); var ob = this.__ob__; var inserted; switch (method) { case 'push': - inserted = args; - break case 'unshift': inserted = args; break @@ -807,8 +832,7 @@ var arrayKeys = Object.getOwnPropertyNames(arrayMethods); * under a frozen data structure. Converting it would defeat the optimization. */ var observerState = { - shouldConvert: true, - isSettingProps: false + shouldConvert: true }; /** @@ -860,7 +884,7 @@ Observer.prototype.observeArray = function observeArray (items) { * Augment an target Object or Array by intercepting * the prototype chain using __proto__ */ -function protoAugment (target, src) { +function protoAugment (target, src, keys) { /* eslint-disable no-proto */ target.__proto__ = src; /* eslint-enable no-proto */ @@ -912,7 +936,8 @@ function defineReactive$$1 ( obj, key, val, - customSetter + customSetter, + shallow ) { var dep = new Dep(); @@ -925,7 +950,7 @@ function defineReactive$$1 ( var getter = property && property.get; var setter = property && property.set; - var childOb = observe(val); + var childOb = !shallow && observe(val); Object.defineProperty(obj, key, { enumerable: true, configurable: true, @@ -957,7 +982,7 @@ function defineReactive$$1 ( } else { val = newVal; } - childOb = observe(newVal); + childOb = !shallow && observe(newVal); dep.notify(); } }); @@ -969,7 +994,7 @@ function defineReactive$$1 ( * already exist. */ function set (target, key, val) { - if (Array.isArray(target) && typeof key === 'number') { + if (Array.isArray(target) && isValidArrayIndex(key)) { target.length = Math.max(target.length, key); target.splice(key, 1, val); return val @@ -978,7 +1003,7 @@ function set (target, key, val) { target[key] = val; return val } - var ob = (target ).__ob__; + var ob = (target).__ob__; if (target._isVue || (ob && ob.vmCount)) { "development" !== 'production' && warn( 'Avoid adding reactive properties to a Vue instance or its root $data ' + @@ -999,11 +1024,11 @@ function set (target, key, val) { * Delete a property and trigger change if necessary. */ function del (target, key) { - if (Array.isArray(target) && typeof key === 'number') { + if (Array.isArray(target) && isValidArrayIndex(key)) { target.splice(key, 1); return } - var ob = (target ).__ob__; + var ob = (target).__ob__; if (target._isVue || (ob && ob.vmCount)) { "development" !== 'production' && warn( 'Avoid deleting properties on a Vue instance or its root $data ' + @@ -1082,7 +1107,7 @@ function mergeData (to, from) { /** * Data */ -strats.data = function ( +function mergeDataOrFn ( parentVal, childVal, vm @@ -1092,15 +1117,6 @@ strats.data = function ( if (!childVal) { return parentVal } - if (typeof childVal !== 'function') { - "development" !== 'production' && warn( - 'The "data" option should be a function ' + - 'that returns a per-instance value in component ' + - 'definitions.', - vm - ); - return parentVal - } if (!parentVal) { return childVal } @@ -1111,7 +1127,7 @@ strats.data = function ( // it has to be a function to pass previous merges. return function mergedDataFn () { return mergeData( - childVal.call(this), + typeof childVal === 'function' ? childVal.call(this) : childVal, parentVal.call(this) ) } @@ -1131,6 +1147,28 @@ strats.data = function ( } } } +} + +strats.data = function ( + parentVal, + childVal, + vm +) { + if (!vm) { + if (childVal && typeof childVal !== 'function') { + "development" !== 'production' && warn( + 'The "data" option should be a function ' + + 'that returns a per-instance value in component ' + + 'definitions.', + vm + ); + + return parentVal + } + return mergeDataOrFn.call(this, parentVal, childVal) + } + + return mergeDataOrFn(parentVal, childVal, vm) }; /** @@ -1178,6 +1216,9 @@ ASSET_TYPES.forEach(function (type) { * another, so we merge them as arrays. */ strats.watch = function (parentVal, childVal) { + // work around Firefox's Object.prototype.watch... + if (parentVal === nativeWatch) { parentVal = undefined; } + if (childVal === nativeWatch) { childVal = undefined; } /* istanbul ignore if */ if (!childVal) { return Object.create(parentVal || null) } if (!parentVal) { return childVal } @@ -1191,7 +1232,7 @@ strats.watch = function (parentVal, childVal) { } ret[key] = parent ? parent.concat(child) - : [child]; + : Array.isArray(child) ? child : [child]; } return ret }; @@ -1201,6 +1242,7 @@ strats.watch = function (parentVal, childVal) { */ strats.props = strats.methods = +strats.inject = strats.computed = function (parentVal, childVal) { if (!childVal) { return Object.create(parentVal || null) } if (!parentVal) { return childVal } @@ -1209,6 +1251,7 @@ strats.computed = function (parentVal, childVal) { extend(ret, childVal); return ret }; +strats.provide = mergeDataOrFn; /** * Default strategy. @@ -1266,6 +1309,19 @@ function normalizeProps (options) { options.props = res; } +/** + * Normalize all injections into Object-based format + */ +function normalizeInject (options) { + var inject = options.inject; + if (Array.isArray(inject)) { + var normalized = options.inject = {}; + for (var i = 0; i < inject.length; i++) { + normalized[inject[i]] = inject[i]; + } + } +} + /** * Normalize raw function directives into object format. */ @@ -1299,6 +1355,7 @@ function mergeOptions ( } normalizeProps(child); + normalizeInject(child); normalizeDirectives(child); var extendsFrom = child.extends; if (extendsFrom) { @@ -1416,7 +1473,8 @@ function getPropDefaultValue (vm, prop, key) { // return previous default value to avoid unnecessary watcher trigger if (vm && vm.$options.propsData && vm.$options.propsData[key] === undefined && - vm._props[key] !== undefined) { + vm._props[key] !== undefined + ) { return vm._props[key] } // call factory function for non-Function types @@ -1522,6 +1580,8 @@ function isType (type, fn) { return false } +/* */ + var mark; var measure; @@ -1628,7 +1688,8 @@ var VNode = function VNode ( text, elm, context, - componentOptions + componentOptions, + asyncFactory ) { this.tag = tag; this.data = data; @@ -1648,6 +1709,9 @@ var VNode = function VNode ( this.isComment = false; this.isCloned = false; this.isOnce = false; + this.asyncFactory = asyncFactory; + this.asyncMeta = undefined; + this.isAsyncPlaceholder = false; }; var prototypeAccessors = { child: {} }; @@ -1660,9 +1724,11 @@ prototypeAccessors.child.get = function () { Object.defineProperties( VNode.prototype, prototypeAccessors ); -var createEmptyVNode = function () { +var createEmptyVNode = function (text) { + if ( text === void 0 ) text = ''; + var node = new VNode(); - node.text = ''; + node.text = text; node.isComment = true; return node }; @@ -1683,11 +1749,13 @@ function cloneVNode (vnode) { vnode.text, vnode.elm, vnode.context, - vnode.componentOptions + vnode.componentOptions, + vnode.asyncFactory ); cloned.ns = vnode.ns; cloned.isStatic = vnode.isStatic; cloned.key = vnode.key; + cloned.isComment = vnode.isComment; cloned.isCloned = true; return cloned } @@ -1724,8 +1792,9 @@ function createFnInvoker (fns) { var fns = invoker.fns; if (Array.isArray(fns)) { - for (var i = 0; i < fns.length; i++) { - fns[i].apply(null, arguments$1); + var cloned = fns.slice(); + for (var i = 0; i < cloned.length; i++) { + cloned[i].apply(null, arguments$1); } } else { // return handler return value for single handlers @@ -1906,6 +1975,10 @@ function normalizeChildren (children) { : undefined } +function isTextNode (node) { + return isDef(node) && isDef(node.text) && isFalse(node.isComment) +} + function normalizeArrayChildren (children, nestedIndex) { var res = []; var i, c, last; @@ -1917,19 +1990,26 @@ function normalizeArrayChildren (children, nestedIndex) { if (Array.isArray(c)) { res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i))); } else if (isPrimitive(c)) { - if (isDef(last) && isDef(last.text)) { + if (isTextNode(last)) { + // merge adjacent text nodes + // this is necessary for SSR hydration because text nodes are + // essentially merged when rendered to HTML strings (last).text += String(c); } else if (c !== '') { // convert primitive to vnode res.push(createTextVNode(c)); } } else { - if (isDef(c.text) && isDef(last) && isDef(last.text)) { + if (isTextNode(c) && isTextNode(last)) { + // merge adjacent text nodes res[res.length - 1] = createTextVNode(last.text + c.text); } else { // default key for nested array children (likely generated by v-for) - if (isDef(c.tag) && isUndef(c.key) && isDef(nestedIndex)) { - c.key = "__vlist" + ((nestedIndex)) + "_" + i + "__"; + if (isTrue(children._isVList) && + isDef(c.tag) && + isUndef(c.key) && + isDef(nestedIndex)) { + c.key = "__vlist" + nestedIndex + "_" + i + "__"; } res.push(c); } @@ -1941,11 +2021,27 @@ function normalizeArrayChildren (children, nestedIndex) { /* */ function ensureCtor (comp, base) { + if (comp.__esModule && comp.default) { + comp = comp.default; + } return isObject(comp) ? base.extend(comp) : comp } +function createAsyncPlaceholder ( + factory, + data, + context, + children, + tag +) { + var node = createEmptyVNode(); + node.asyncFactory = factory; + node.asyncMeta = { data: data, context: context, children: children, tag: tag }; + return node +} + function resolveAsyncComponent ( factory, baseCtor, @@ -2028,9 +2124,11 @@ function resolveAsyncComponent ( if (isDef(res.timeout)) { setTimeout(function () { - reject( - "timeout (" + (res.timeout) + "ms)" - ); + if (isUndef(factory.resolved)) { + reject( + "timeout (" + (res.timeout) + "ms)" + ); + } }, res.timeout); } } @@ -2183,7 +2281,11 @@ function eventsMixin (Vue) { cbs = cbs.length > 1 ? toArray(cbs) : cbs; var args = toArray(arguments, 1); for (var i = 0, l = cbs.length; i < l; i++) { - cbs[i].apply(vm, args); + try { + cbs[i].apply(vm, args); + } catch (e) { + handleError(e, vm, ("event handler for \"" + event + "\"")); + } } } return vm @@ -2209,7 +2311,8 @@ function resolveSlots ( // named slots should only be respected if the vnode was rendered in the // same context. if ((child.context === context || child.functionalContext === context) && - child.data && child.data.slot != null) { + child.data && child.data.slot != null + ) { var name = child.data.slot; var slot = (slots[name] || (slots[name] = [])); if (child.tag === 'template') { @@ -2233,11 +2336,16 @@ function isWhitespace (node) { } function resolveScopedSlots ( - fns + fns, // see flow/vnode + res ) { - var res = {}; + res = res || {}; for (var i = 0; i < fns.length; i++) { - res[fns[i][0]] = fns[i][1]; + if (Array.isArray(fns[i])) { + resolveScopedSlots(fns[i], res); + } else { + res[fns[i].key] = fns[i].fn; + } } return res } @@ -2245,6 +2353,7 @@ function resolveScopedSlots ( /* */ var activeInstance = null; +var isUpdatingChildComponent = false; function initLifecycle (vm) { var options = vm.$options; @@ -2292,6 +2401,9 @@ function lifecycleMixin (Vue) { vm.$options._parentElm, vm.$options._refElm ); + // no need for the ref nodes after initial patch + // this prevents keeping a detached DOM tree in memory (#5851) + vm.$options._parentElm = vm.$options._refElm = null; } else { // updates vm.$el = vm.__patch__(prevVnode, vnode); @@ -2356,8 +2468,6 @@ function lifecycleMixin (Vue) { if (vm.$el) { vm.$el.__vue__ = null; } - // remove reference to DOM nodes (prevents leak) - vm.$options._parentElm = vm.$options._refElm = null; }; } @@ -2433,6 +2543,10 @@ function updateChildComponent ( parentVnode, renderChildren ) { + { + isUpdatingChildComponent = true; + } + // determine whether component has slot children // we need to do this before overwriting $options._renderChildren var hasChildren = !!( @@ -2444,17 +2558,21 @@ function updateChildComponent ( vm.$options._parentVnode = parentVnode; vm.$vnode = parentVnode; // update vm's placeholder node without re-render + if (vm._vnode) { // update child tree's parent vm._vnode.parent = parentVnode; } vm.$options._renderChildren = renderChildren; + // update $attrs and $listensers hash + // these are also reactive so they may trigger child update if the child + // used them during render + vm.$attrs = parentVnode.data && parentVnode.data.attrs; + vm.$listeners = listeners; + // update props if (propsData && vm.$options.props) { observerState.shouldConvert = false; - { - observerState.isSettingProps = true; - } var props = vm._props; var propKeys = vm.$options._propKeys || []; for (var i = 0; i < propKeys.length; i++) { @@ -2462,12 +2580,10 @@ function updateChildComponent ( props[key] = validateProp(key, vm.$options.props, propsData, vm); } observerState.shouldConvert = true; - { - observerState.isSettingProps = false; - } // keep a copy of raw propsData vm.$options.propsData = propsData; } + // update listeners if (listeners) { var oldListeners = vm.$options._parentListeners; @@ -2479,6 +2595,10 @@ function updateChildComponent ( vm.$slots = resolveSlots(renderChildren, parentVnode.context); vm.$forceUpdate(); } + + { + isUpdatingChildComponent = false; + } } function isInInactiveTree (vm) { @@ -2555,7 +2675,7 @@ var index = 0; * Reset the scheduler's state. */ function resetSchedulerState () { - queue.length = activatedChildren.length = 0; + index = queue.length = activatedChildren.length = 0; has = {}; { circular = {}; @@ -2612,7 +2732,7 @@ function flushSchedulerQueue () { // call component updated and activated hooks callActivatedHooks(activatedQueue); - callUpdateHooks(updatedQueue); + callUpdatedHooks(updatedQueue); // devtool hook /* istanbul ignore if */ @@ -2621,7 +2741,7 @@ function flushSchedulerQueue () { } } -function callUpdateHooks (queue) { +function callUpdatedHooks (queue) { var i = queue.length; while (i--) { var watcher = queue[i]; @@ -2665,10 +2785,10 @@ function queueWatcher (watcher) { // if already flushing, splice the watcher based on its id // if already past its id, it will be run next immediately. var i = queue.length - 1; - while (i >= 0 && queue[i].id > watcher.id) { + while (i > index && queue[i].id > watcher.id) { i--; } - queue.splice(Math.max(i, index) + 1, 0, watcher); + queue.splice(i + 1, 0, watcher); } // queue the flush if (!waiting) { @@ -2740,22 +2860,23 @@ Watcher.prototype.get = function get () { pushTarget(this); var value; var vm = this.vm; - if (this.user) { - try { - value = this.getter.call(vm, vm); - } catch (e) { + try { + value = this.getter.call(vm, vm); + } catch (e) { + if (this.user) { handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\"")); + } else { + throw e } - } else { - value = this.getter.call(vm, vm); - } - // "touch" every property so they are all tracked as - // dependencies for deep watching - if (this.deep) { - traverse(value); + } finally { + // "touch" every property so they are all tracked as + // dependencies for deep watching + if (this.deep) { + traverse(value); + } + popTarget(); + this.cleanupDeps(); } - popTarget(); - this.cleanupDeps(); return value }; @@ -2948,14 +3069,20 @@ function initState (vm) { observe(vm._data = {}, true /* asRootData */); } if (opts.computed) { initComputed(vm, opts.computed); } - if (opts.watch) { initWatch(vm, opts.watch); } + if (opts.watch && opts.watch !== nativeWatch) { + initWatch(vm, opts.watch); + } } -var isReservedProp = { - key: 1, - ref: 1, - slot: 1 -}; +function checkOptionType (vm, name) { + var option = vm.$options[name]; + if (!isPlainObject(option)) { + warn( + ("component option \"" + name + "\" should be an object."), + vm + ); + } +} function initProps (vm, propsOptions) { var propsData = vm.$options.propsData || {}; @@ -2971,14 +3098,14 @@ function initProps (vm, propsOptions) { var value = validateProp(key, propsOptions, propsData, vm); /* istanbul ignore else */ { - if (isReservedProp[key] || config.isReservedAttr(key)) { + if (isReservedAttribute(key) || config.isReservedAttr(key)) { warn( ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."), vm ); } defineReactive$$1(props, key, value, function () { - if (vm.$parent && !observerState.isSettingProps) { + if (vm.$parent && !isUpdatingChildComponent) { warn( "Avoid mutating a prop directly since the value will be " + "overwritten whenever the parent component re-renders. " + @@ -3017,16 +3144,26 @@ function initData (vm) { // proxy data on instance var keys = Object.keys(data); var props = vm.$options.props; + var methods = vm.$options.methods; var i = keys.length; while (i--) { - if (props && hasOwn(props, keys[i])) { + var key = keys[i]; + { + if (methods && hasOwn(methods, key)) { + warn( + ("method \"" + key + "\" has already been defined as a data property."), + vm + ); + } + } + if (props && hasOwn(props, key)) { "development" !== 'production' && warn( - "The data property \"" + (keys[i]) + "\" is already declared as a prop. " + + "The data property \"" + key + "\" is already declared as a prop. " + "Use prop default value instead.", vm ); - } else if (!isReserved(keys[i])) { - proxy(vm, "_data", keys[i]); + } else if (!isReserved(key)) { + proxy(vm, "_data", key); } } // observe data @@ -3045,6 +3182,7 @@ function getData (data, vm) { var computedWatcherOptions = { lazy: true }; function initComputed (vm, computed) { + "development" !== 'production' && checkOptionType(vm, 'computed'); var watchers = vm._computedWatchers = Object.create(null); for (var key in computed) { @@ -3110,6 +3248,7 @@ function createComputedGetter (key) { } function initMethods (vm, methods) { + "development" !== 'production' && checkOptionType(vm, 'methods'); var props = vm.$options.props; for (var key in methods) { vm[key] = methods[key] == null ? noop : bind(methods[key], vm); @@ -3132,6 +3271,7 @@ function initMethods (vm, methods) { } function initWatch (vm, watch) { + "development" !== 'production' && checkOptionType(vm, 'watch'); for (var key in watch) { var handler = watch[key]; if (Array.isArray(handler)) { @@ -3144,8 +3284,12 @@ function initWatch (vm, watch) { } } -function createWatcher (vm, key, handler) { - var options; +function createWatcher ( + vm, + keyOrFn, + handler, + options +) { if (isPlainObject(handler)) { options = handler; handler = handler.handler; @@ -3153,7 +3297,7 @@ function createWatcher (vm, key, handler) { if (typeof handler === 'string') { handler = vm[handler]; } - vm.$watch(key, handler, options); + return vm.$watch(keyOrFn, handler, options) } function stateMixin (Vue) { @@ -3188,6 +3332,9 @@ function stateMixin (Vue) { options ) { var vm = this; + if (isPlainObject(cb)) { + return createWatcher(vm, expOrFn, cb, options) + } options = options || {}; options.user = true; var watcher = new Watcher(vm, expOrFn, cb, options); @@ -3214,6 +3361,7 @@ function initProvide (vm) { function initInjections (vm) { var result = resolveInject(vm.$options.inject, vm); if (result) { + observerState.shouldConvert = false; Object.keys(result).forEach(function (key) { /* istanbul ignore else */ { @@ -3227,24 +3375,21 @@ function initInjections (vm) { }); } }); + observerState.shouldConvert = true; } } function resolveInject (inject, vm) { if (inject) { // inject is :any because flow is not smart enough to figure out cached - // isArray here - var isArray = Array.isArray(inject); var result = Object.create(null); - var keys = isArray - ? inject - : hasSymbol + var keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject); for (var i = 0; i < keys.length; i++) { var key = keys[i]; - var provideKey = isArray ? key : inject[key]; + var provideKey = inject[key]; var source = vm; while (source) { if (source._provided && provideKey in source._provided) { @@ -3253,6 +3398,9 @@ function resolveInject (inject, vm) { } source = source.$parent; } + if ("development" !== 'production' && !hasOwn(result, key)) { + warn(("Injection \"" + key + "\" not found"), vm); + } } return result } @@ -3271,7 +3419,7 @@ function createFunctionalComponent ( var propOptions = Ctor.options.props; if (isDef(propOptions)) { for (var key in propOptions) { - props[key] = validateProp(key, propOptions, propsData); + props[key] = validateProp(key, propOptions, propsData || {}); } } else { if (isDef(data.attrs)) { mergeProps(props, data.attrs); } @@ -3292,6 +3440,7 @@ function createFunctionalComponent ( }); if (vnode instanceof VNode) { vnode.functionalContext = context; + vnode.functionalOptions = Ctor.options; if (data.slot) { (vnode.data || (vnode.data = {})).slot = data.slot; } @@ -3405,21 +3554,30 @@ function createComponent ( } // async component + var asyncFactory; if (isUndef(Ctor.cid)) { - Ctor = resolveAsyncComponent(Ctor, baseCtor, context); + asyncFactory = Ctor; + Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context); if (Ctor === undefined) { - // return nothing if this is indeed an async component - // wait for the callback to trigger parent update. - return + // return a placeholder node for async component, which is rendered + // as a comment node but preserves all the raw information for the node. + // the information will be used for async server-rendering and hydration. + return createAsyncPlaceholder( + asyncFactory, + data, + context, + children, + tag + ) } } + data = data || {}; + // resolve constructor options in case global mixins are applied after // component constructor creation resolveConstructorOptions(Ctor); - data = data || {}; - // transform component v-model data into props & events if (isDef(data.model)) { transformModel(Ctor.options, data); @@ -3433,16 +3591,19 @@ function createComponent ( return createFunctionalComponent(Ctor, propsData, data, context, children) } - // extract listeners, since these needs to be treated as - // child component listeners instead of DOM listeners + // keep listeners var listeners = data.on; - // replace with listeners with .native modifier - data.on = data.nativeOn; if (isTrue(Ctor.options.abstract)) { // abstract components do not keep anything - // other than props & listeners + // other than props & listeners & slot + + // work around flow + var slot = data.slot; data = {}; + if (slot) { + data.slot = slot; + } } // merge component management hooks onto the placeholder node @@ -3453,7 +3614,8 @@ function createComponent ( var vnode = new VNode( ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), data, undefined, undefined, undefined, context, - { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children } + { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }, + asyncFactory ); return vnode } @@ -3558,13 +3720,28 @@ function _createElement ( ); return createEmptyVNode() } + // object syntax in v-bind + if (isDef(data) && isDef(data.is)) { + tag = data.is; + } if (!tag) { // in case of component :is set to falsy value return createEmptyVNode() } + // warn against non-primitive key + if ("development" !== 'production' && + isDef(data) && isDef(data.key) && !isPrimitive(data.key) + ) { + warn( + 'Avoid using non-primitive value as key, ' + + 'use string/number value instead.', + context + ); + } // support single function children as default scoped slot if (Array.isArray(children) && - typeof children[0] === 'function') { + typeof children[0] === 'function' + ) { data = data || {}; data.scopedSlots = { default: children[0] }; children.length = 0; @@ -3600,7 +3777,7 @@ function _createElement ( // direct component options / constructor vnode = createComponent(tag, data, context, children); } - if (vnode !== undefined) { + if (isDef(vnode)) { if (ns) { applyNS(vnode, ns); } return vnode } else { @@ -3614,7 +3791,7 @@ function applyNS (vnode, ns) { // use default namespace inside foreignObject return } - if (Array.isArray(vnode.children)) { + if (isDef(vnode.children)) { for (var i = 0, l = vnode.children.length; i < l; i++) { var child = vnode.children[i]; if (isDef(child.tag) && isUndef(child.ns)) { @@ -3652,6 +3829,9 @@ function renderList ( ret[i] = render(val[key], key, i); } } + if (isDef(ret)) { + (ret)._isVList = true; + } return ret } @@ -3670,7 +3850,7 @@ function renderSlot ( if (scopedSlotFn) { // scoped slot props = props || {}; if (bindObject) { - extend(props, bindObject); + props = extend(extend({}, bindObject), props); } return scopedSlotFn(props) || fallback } else { @@ -3724,7 +3904,8 @@ function bindObjectProps ( data, tag, value, - asProp + asProp, + isSync ) { if (value) { if (!isObject(value)) { @@ -3737,8 +3918,12 @@ function bindObjectProps ( value = toObject(value); } var hash; - for (var key in value) { - if (key === 'class' || key === 'style') { + var loop = function ( key ) { + if ( + key === 'class' || + key === 'style' || + isReservedAttribute(key) + ) { hash = data; } else { var type = data.attrs && data.attrs.type; @@ -3748,8 +3933,17 @@ function bindObjectProps ( } if (!(key in hash)) { hash[key] = value[key]; + + if (isSync) { + var on = data.on || (data.on = {}); + on[("update:" + key)] = function ($event) { + value[key] = $event; + }; + } } - } + }; + + for (var key in value) loop( key ); } } return data @@ -3816,6 +4010,27 @@ function markStaticNode (node, key, isOnce) { /* */ +function bindObjectListeners (data, value) { + if (value) { + if (!isPlainObject(value)) { + "development" !== 'production' && warn( + 'v-on without argument expects an Object value', + this + ); + } else { + var on = data.on = data.on ? extend({}, data.on) : {}; + for (var key in value) { + var existing = on[key]; + var ours = value[key]; + on[key] = existing ? [].concat(ours, existing) : ours; + } + } + } + return data +} + +/* */ + function initRender (vm) { vm._vnode = null; // the root of the child tree vm._staticTrees = null; @@ -3831,6 +4046,19 @@ function initRender (vm) { // 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); }; + + // $attrs & $listeners are exposed for easier HOC creation. + // they need to be reactive so that HOCs using them are always updated + var parentData = parentVnode && parentVnode.data; + /* istanbul ignore else */ + { + defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () { + !isUpdatingChildComponent && warn("$attrs is readonly.", vm); + }, true); + defineReactive$$1(vm, '$listeners', parentData && parentData.on, function () { + !isUpdatingChildComponent && warn("$listeners is readonly.", vm); + }, true); + } } function renderMixin (Vue) { @@ -3896,7 +4124,7 @@ function renderMixin (Vue) { // code size. Vue.prototype._o = markOnce; Vue.prototype._n = toNumber; - Vue.prototype._s = _toString; + Vue.prototype._s = toString; Vue.prototype._l = renderList; Vue.prototype._t = renderSlot; Vue.prototype._q = looseEqual; @@ -3908,6 +4136,7 @@ function renderMixin (Vue) { Vue.prototype._v = createTextVNode; Vue.prototype._e = createEmptyVNode; Vue.prototype._u = resolveScopedSlots; + Vue.prototype._g = bindObjectListeners; } /* */ @@ -4047,7 +4276,8 @@ function dedupe (latest, extended, sealed) { function Vue$3 (options) { if ("development" !== 'production' && - !(this instanceof Vue$3)) { + !(this instanceof Vue$3) + ) { warn('Vue is a constructor and should be called with the `new` keyword'); } this._init(options); @@ -4063,10 +4293,11 @@ renderMixin(Vue$3); function initUse (Vue) { Vue.use = function (plugin) { - /* istanbul ignore if */ - if (plugin.installed) { - return + var installedPlugins = (this._installedPlugins || (this._installedPlugins = [])); + if (installedPlugins.indexOf(plugin) > -1) { + return this } + // additional parameters var args = toArray(arguments, 1); args.unshift(this); @@ -4075,7 +4306,7 @@ function initUse (Vue) { } else if (typeof plugin === 'function') { plugin.apply(null, args); } - plugin.installed = true; + installedPlugins.push(plugin); return this }; } @@ -4085,6 +4316,7 @@ function initUse (Vue) { function initMixin$1 (Vue) { Vue.mixin = function (mixin) { this.options = mergeOptions(this.options, mixin); + return this }; } @@ -4225,14 +4457,16 @@ function initAssetRegisters (Vue) { /* */ -var patternTypes = [String, RegExp]; +var patternTypes = [String, RegExp, Array]; function getComponentName (opts) { return opts && (opts.Ctor.options.name || opts.tag) } function matches (pattern, name) { - if (typeof pattern === 'string') { + if (Array.isArray(pattern)) { + return pattern.indexOf(name) > -1 + } else if (typeof pattern === 'string') { return pattern.split(',').indexOf(name) > -1 } else if (isRegExp(pattern)) { return pattern.test(name) @@ -4376,7 +4610,14 @@ Object.defineProperty(Vue$3.prototype, '$isServer', { get: isServerRendering }); -Vue$3.version = '2.3.0'; +Object.defineProperty(Vue$3.prototype, '$ssrContext', { + get: function get () { + /* istanbul ignore next */ + return this.$vnode && this.$vnode.ssrContext + } +}); + +Vue$3.version = '2.4.0'; /* */ @@ -4437,7 +4678,7 @@ function genClassForVnode (vnode) { data = mergeClassData(data, parentNode.data); } } - return genClassFromData(data) + return renderClass(data.staticClass, data.class) } function mergeClassData (child, parent) { @@ -4449,9 +4690,10 @@ function mergeClassData (child, parent) { } } -function genClassFromData (data) { - var dynamicClass = data.class; - var staticClass = data.staticClass; +function renderClass ( + staticClass, + dynamicClass +) { if (isDef(staticClass) || isDef(dynamicClass)) { return concat(staticClass, stringifyClass(dynamicClass)) } @@ -4464,31 +4706,39 @@ function concat (a, b) { } function stringifyClass (value) { - if (isUndef(value)) { - return '' + if (Array.isArray(value)) { + return stringifyArray(value) + } + if (isObject(value)) { + return stringifyObject(value) } if (typeof value === 'string') { return value } + /* istanbul ignore next */ + return '' +} + +function stringifyArray (value) { var res = ''; - if (Array.isArray(value)) { - var stringified; - for (var i = 0, l = value.length; i < l; i++) { - if (isDef(value[i])) { - if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') { - res += stringified + ' '; - } - } + var stringified; + for (var i = 0, l = value.length; i < l; i++) { + if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') { + if (res) { res += ' '; } + res += stringified; } - return res.slice(0, -1) } - if (isObject(value)) { - for (var key in value) { - if (value[key]) { res += key + ' '; } + return res +} + +function stringifyObject (value) { + var res = ''; + for (var key in value) { + if (value[key]) { + if (res) { res += ' '; } + res += key; } - return res.slice(0, -1) } - /* istanbul ignore next */ return res } @@ -4502,7 +4752,7 @@ var namespaceMap = { var isHTMLTag = makeMap( 'html,body,base,head,link,meta,style,title,' + 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + - 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' + + 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' + 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 'embed,object,param,source,canvas,script,noscript,del,ins,' + @@ -4510,7 +4760,7 @@ var isHTMLTag = makeMap( 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 'output,progress,select,textarea,' + 'details,dialog,menu,menuitem,summary,' + - 'content,element,shadow,template' + 'content,element,shadow,template,blockquote,iframe,tfoot' ); // this map is intentionally selective, only covering SVG elements that may @@ -4691,10 +4941,11 @@ function registerRef (vnode, isRemoval) { } } else { if (vnode.data.refInFor) { - if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) { - refs[key].push(ref); - } else { + if (!Array.isArray(refs[key])) { refs[key] = [ref]; + } else if (refs[key].indexOf(ref) < 0) { + // $flow-disable-line + refs[key].push(ref); } } else { refs[key] = ref; @@ -4722,11 +4973,18 @@ var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; function sameVnode (a, b) { return ( - a.key === b.key && - a.tag === b.tag && - a.isComment === b.isComment && - isDef(a.data) === isDef(b.data) && - sameInputType(a, b) + a.key === b.key && ( + ( + a.tag === b.tag && + a.isComment === b.isComment && + isDef(a.data) === isDef(b.data) && + sameInputType(a, b) + ) || ( + isTrue(a.isAsyncPlaceholder) && + a.asyncFactory === b.asyncFactory && + isUndef(b.asyncFactory.error) + ) + ) ) } @@ -4867,6 +5125,7 @@ function createPatchFunction (backend) { function initComponent (vnode, insertedVnodeQueue) { if (isDef(vnode.data.pendingInsert)) { insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); + vnode.data.pendingInsert = null; } vnode.elm = vnode.componentInstance.$el; if (isPatchable(vnode)) { @@ -4903,11 +5162,11 @@ function createPatchFunction (backend) { insert(parentElm, vnode.elm, refElm); } - function insert (parent, elm, ref) { + function insert (parent, elm, ref$$1) { if (isDef(parent)) { - if (isDef(ref)) { - if (ref.parentNode === parent) { - nodeOps.insertBefore(parent, elm, ref); + if (isDef(ref$$1)) { + if (ref$$1.parentNode === parent) { + nodeOps.insertBefore(parent, elm, ref$$1); } } else { nodeOps.appendChild(parent, elm); @@ -4957,8 +5216,9 @@ function createPatchFunction (backend) { } // for slot content they should also get the scopeId from the host instance. if (isDef(i = activeInstance) && - i !== vnode.context && - isDef(i = i.$options._scopeId)) { + i !== vnode.context && + isDef(i = i.$options._scopeId) + ) { nodeOps.setAttribute(vnode.elm, i, ''); } } @@ -5083,7 +5343,7 @@ function createPatchFunction (backend) { if (sameVnode(elmToMove, newStartVnode)) { patchVnode(elmToMove, newStartVnode, insertedVnodeQueue); oldCh[idxInOld] = undefined; - canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm); + canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm); newStartVnode = newCh[++newStartIdx]; } else { // same key but different element. treat as new element @@ -5105,24 +5365,37 @@ function createPatchFunction (backend) { if (oldVnode === vnode) { return } + + var elm = vnode.elm = oldVnode.elm; + + if (isTrue(oldVnode.isAsyncPlaceholder)) { + if (isDef(vnode.asyncFactory.resolved)) { + hydrate(oldVnode.elm, vnode, insertedVnodeQueue); + } else { + vnode.isAsyncPlaceholder = true; + } + return + } + // reuse element for static trees. // note we only do this if the vnode is cloned - // if the new node is not cloned it means the render functions have been // reset by the hot-reload-api and we need to do a proper re-render. if (isTrue(vnode.isStatic) && - isTrue(oldVnode.isStatic) && - vnode.key === oldVnode.key && - (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) { - vnode.elm = oldVnode.elm; + isTrue(oldVnode.isStatic) && + vnode.key === oldVnode.key && + (isTrue(vnode.isCloned) || isTrue(vnode.isOnce)) + ) { vnode.componentInstance = oldVnode.componentInstance; return } + var i; var data = vnode.data; if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) { i(oldVnode, vnode); } - var elm = vnode.elm = oldVnode.elm; + var oldCh = oldVnode.children; var ch = vnode.children; if (isDef(data) && isPatchable(vnode)) { @@ -5167,6 +5440,11 @@ function createPatchFunction (backend) { // Note: this is a browser-only function so we can assume elms are DOM nodes. function hydrate (elm, vnode, insertedVnodeQueue) { + if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) { + vnode.elm = elm; + vnode.isAsyncPlaceholder = true; + return true + } { if (!assertNodeMatch(elm, vnode)) { return false @@ -5203,8 +5481,9 @@ function createPatchFunction (backend) { // longer than the virtual children list. if (!childrenMatch || childNode) { if ("development" !== 'production' && - typeof console !== 'undefined' && - !bailed) { + typeof console !== 'undefined' && + !bailed + ) { bailed = true; console.warn('Parent: ', elm); console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); @@ -5445,6 +5724,10 @@ var baseModules = [ /* */ function updateAttrs (oldVnode, vnode) { + var opts = vnode.componentOptions; + if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) { + return + } if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) { return } @@ -5810,10 +6093,7 @@ function genAssignmentCode ( if (modelRs.idx === null) { return (value + "=" + assignment) } else { - return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" + - "if (!Array.isArray($$exp)){" + - value + "=" + assignment + "}" + - "else{$$exp.splice($$idx, 1, " + assignment + ")}" + return ("$set(" + (modelRs.exp) + ", " + (modelRs.idx) + ", " + assignment + ")") } } @@ -5944,7 +6224,11 @@ function model ( } } - if (tag === 'select') { + if (el.component) { + genComponentModel(el, value, modifiers); + // component v-model doesn't need extra runtime + return false + } else if (tag === 'select') { genSelect(el, value, modifiers); } else if (tag === 'input' && type === 'checkbox') { genCheckboxModel(el, value, modifiers); @@ -6061,7 +6345,7 @@ function genDefaultModel ( addProp(el, 'value', ("(" + value + ")")); addHandler(el, event, code, null, true); - if (trim || number || type === 'number') { + if (trim || number) { addHandler(el, 'blur', '$forceUpdate()'); } } @@ -6129,11 +6413,14 @@ function remove$2 ( } function updateDOMListeners (oldVnode, vnode) { - if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) { + var isComponentRoot = isDef(vnode.componentOptions); + var oldOn = isComponentRoot ? oldVnode.data.nativeOn : oldVnode.data.on; + var on = isComponentRoot ? vnode.data.nativeOn : vnode.data.on; + if (isUndef(oldOn) && isUndef(on)) { return } - var on = vnode.data.on || {}; - var oldOn = oldVnode.data.on || {}; + on = on || {}; + oldOn = oldOn || {}; target$1 = vnode.elm; normalizeEvents(on); updateListeners(on, oldOn, add$1, remove$2, vnode.context); @@ -6179,7 +6466,7 @@ function updateDOMProps (oldVnode, vnode) { // non-string values will be stringified elm._value = cur; // avoid resetting cursor position when value is the same - var strCur = cur == null ? '' : String(cur); + var strCur = isUndef(cur) ? '' : String(cur); if (shouldUpdateValue(elm, vnode, strCur)) { elm.value = strCur; } @@ -6205,14 +6492,15 @@ function shouldUpdateValue ( } function isDirty (elm, checkVal) { - // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value + // return true when textbox (.number and .trim) loses focus and its value is + // not equal to the updated value return document.activeElement !== elm && elm.value !== checkVal } function isInputChanged (elm, newVal) { var value = elm.value; var modifiers = elm._vModifiers; // injected by v-model runtime - if ((isDef(modifiers) && modifiers.number) || elm.type === 'number') { + if (isDef(modifiers) && modifiers.number) { return toNumber(value) !== toNumber(newVal) } if (isDef(modifiers) && modifiers.trim) { @@ -6318,20 +6606,20 @@ var setProp = function (el, name, val) { } }; -var prefixes = ['Webkit', 'Moz', 'ms']; +var vendorNames = ['Webkit', 'Moz', 'ms']; -var testEl; +var emptyStyle; var normalize = cached(function (prop) { - testEl = testEl || document.createElement('div'); + emptyStyle = emptyStyle || document.createElement('div').style; prop = camelize(prop); - if (prop !== 'filter' && (prop in testEl.style)) { + if (prop !== 'filter' && (prop in emptyStyle)) { return prop } - var upper = prop.charAt(0).toUpperCase() + prop.slice(1); - for (var i = 0; i < prefixes.length; i++) { - var prefixed = prefixes[i] + upper; - if (prefixed in testEl.style) { - return prefixed + var capName = prop.charAt(0).toUpperCase() + prop.slice(1); + for (var i = 0; i < vendorNames.length; i++) { + var name = vendorNames[i] + capName; + if (name in emptyStyle) { + return name } } }); @@ -6341,7 +6629,8 @@ function updateStyle (oldVnode, vnode) { var oldData = oldVnode.data; if (isUndef(data.staticStyle) && isUndef(data.style) && - isUndef(oldData.staticStyle) && isUndef(oldData.style)) { + isUndef(oldData.staticStyle) && isUndef(oldData.style) + ) { return } @@ -6427,13 +6716,21 @@ function removeClass (el, cls) { } else { el.classList.remove(cls); } + if (!el.classList.length) { + el.removeAttribute('class'); + } } else { var cur = " " + (el.getAttribute('class') || '') + " "; var tar = ' ' + cls + ' '; while (cur.indexOf(tar) >= 0) { cur = cur.replace(tar, ' '); } - el.setAttribute('class', cur.trim()); + cur = cur.trim(); + if (cur) { + el.setAttribute('class', cur); + } else { + el.removeAttribute('class'); + } } } @@ -6479,12 +6776,14 @@ var animationEndEvent = 'animationend'; if (hasTransition) { /* istanbul ignore if */ if (window.ontransitionend === undefined && - window.onwebkittransitionend !== undefined) { + window.onwebkittransitionend !== undefined + ) { transitionProp = 'WebkitTransition'; transitionEndEvent = 'webkitTransitionEnd'; } if (window.onanimationend === undefined && - window.onwebkitanimationend !== undefined) { + window.onwebkitanimationend !== undefined + ) { animationProp = 'WebkitAnimation'; animationEndEvent = 'webkitAnimationEnd'; } @@ -6502,8 +6801,11 @@ function nextFrame (fn) { } function addTransitionClass (el, cls) { - (el._transitionClasses || (el._transitionClasses = [])).push(cls); - addClass(el, cls); + var transitionClasses = el._transitionClasses || (el._transitionClasses = []); + if (transitionClasses.indexOf(cls) < 0) { + transitionClasses.push(cls); + addClass(el, cls); + } } function removeTransitionClass (el, cls) { @@ -6631,24 +6933,23 @@ function enter (vnode, toggleDisplay) { return } - var ref = (data); - var css = ref.css; - var type = ref.type; - var enterClass = ref.enterClass; - var enterToClass = ref.enterToClass; - var enterActiveClass = ref.enterActiveClass; - var appearClass = ref.appearClass; - var appearToClass = ref.appearToClass; - var appearActiveClass = ref.appearActiveClass; - var beforeEnter = ref.beforeEnter; - var enter = ref.enter; - var afterEnter = ref.afterEnter; - var enterCancelled = ref.enterCancelled; - var beforeAppear = ref.beforeAppear; - var appear = ref.appear; - var afterAppear = ref.afterAppear; - var appearCancelled = ref.appearCancelled; - var duration = ref.duration; + var css = data.css; + var type = data.type; + var enterClass = data.enterClass; + var enterToClass = data.enterToClass; + var enterActiveClass = data.enterActiveClass; + var appearClass = data.appearClass; + var appearToClass = data.appearToClass; + var appearActiveClass = data.appearActiveClass; + var beforeEnter = data.beforeEnter; + var enter = data.enter; + var afterEnter = data.afterEnter; + var enterCancelled = data.enterCancelled; + var beforeAppear = data.beforeAppear; + var appear = data.appear; + var afterAppear = data.afterAppear; + var appearCancelled = data.appearCancelled; + var duration = data.duration; // activeInstance will always be the component managing this // transition. One edge case to check is when the is placed @@ -6725,8 +7026,9 @@ function enter (vnode, toggleDisplay) { var parent = el.parentNode; var pendingNode = parent && parent._pending && parent._pending[vnode.key]; if (pendingNode && - pendingNode.tag === vnode.tag && - pendingNode.elm._leaveCb) { + pendingNode.tag === vnode.tag && + pendingNode.elm._leaveCb + ) { pendingNode.elm._leaveCb(); } enterHook && enterHook(el, cb); @@ -6780,18 +7082,17 @@ function leave (vnode, rm) { return } - var ref = (data); - var css = ref.css; - var type = ref.type; - var leaveClass = ref.leaveClass; - var leaveToClass = ref.leaveToClass; - var leaveActiveClass = ref.leaveActiveClass; - var beforeLeave = ref.beforeLeave; - var leave = ref.leave; - var afterLeave = ref.afterLeave; - var leaveCancelled = ref.leaveCancelled; - var delayLeave = ref.delayLeave; - var duration = ref.duration; + var css = data.css; + var type = data.type; + var leaveClass = data.leaveClass; + var leaveToClass = data.leaveToClass; + var leaveActiveClass = data.leaveActiveClass; + var beforeLeave = data.beforeLeave; + var leave = data.leave; + var afterLeave = data.afterLeave; + var leaveCancelled = data.leaveCancelled; + var delayLeave = data.delayLeave; + var duration = data.duration; var expectsCSS = css !== false && !isIE9; var userWantsControl = getHookArgumentsLength(leave); @@ -6802,7 +7103,7 @@ function leave (vnode, rm) { : duration ); - if ("development" !== 'production' && explicitLeaveDuration != null) { + if ("development" !== 'production' && isDef(explicitLeaveDuration)) { checkDuration(explicitLeaveDuration, 'leave', vnode); } @@ -6839,7 +7140,7 @@ function leave (vnode, rm) { } // record leaving element if (!vnode.data.show) { - (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode; + (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode; } beforeLeave && beforeLeave(el); if (expectsCSS) { @@ -6949,6 +7250,8 @@ var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules }); * properties to Elements. */ +var isTextInputType = makeMap('text,number,password,search,email,tel,url'); + /* istanbul ignore if */ if (isIE9) { // http://www.matts411.com/post/internet-explorer-9-oninput/ @@ -6971,7 +7274,7 @@ var model$1 = { if (isIE || isEdge) { setTimeout(cb, 0); } - } else if (vnode.tag === 'textarea' || el.type === 'text' || el.type === 'password') { + } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) { el._vModifiers = binding.modifiers; if (!binding.modifiers.lazy) { // Safari < 10.2 & UIWebView doesn't fire compositionend when @@ -7060,6 +7363,8 @@ function onCompositionStart (e) { } function onCompositionEnd (e) { + // prevent triggering an input event for no reason + if (!e.target.composing) { return } e.target.composing = false; trigger(e.target, 'input'); } @@ -7084,10 +7389,10 @@ var show = { var value = ref.value; vnode = locateNode(vnode); - var transition = vnode.data && vnode.data.transition; + var transition$$1 = vnode.data && vnode.data.transition; var originalDisplay = el.__vOriginalDisplay = el.style.display === 'none' ? '' : el.style.display; - if (value && transition && !isIE9) { + if (value && transition$$1 && !isIE9) { vnode.data.show = true; enter(vnode, function () { el.style.display = originalDisplay; @@ -7104,8 +7409,8 @@ var show = { /* istanbul ignore if */ if (value === oldValue) { return } vnode = locateNode(vnode); - var transition = vnode.data && vnode.data.transition; - if (transition && !isIE9) { + var transition$$1 = vnode.data && vnode.data.transition; + if (transition$$1 && !isIE9) { vnode.data.show = true; if (value) { enter(vnode, function () { @@ -7209,6 +7514,10 @@ function isSameChild (child, oldChild) { return oldChild.key === child.key && oldChild.tag === child.tag } +function isAsyncPlaceholder (node) { + return node.isComment && node.asyncFactory +} + var Transition = { name: 'transition', props: transitionProps, @@ -7217,13 +7526,13 @@ var Transition = { render: function render (h) { var this$1 = this; - var children = this.$slots.default; + var children = this.$options._renderChildren; if (!children) { return } // filter out text nodes (possible whitespaces) - children = children.filter(function (c) { return c.tag; }); + children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); }); /* istanbul ignore if */ if (!children.length) { return @@ -7242,7 +7551,8 @@ var Transition = { // warn invalid mode if ("development" !== 'production' && - mode && mode !== 'in-out' && mode !== 'out-in') { + mode && mode !== 'in-out' && mode !== 'out-in' + ) { warn( 'invalid mode: ' + mode, this.$parent @@ -7274,7 +7584,9 @@ var Transition = { // during entering. var id = "__transition-" + (this._uid) + "-"; child.key = child.key == null - ? id + child.tag + ? child.isComment + ? id + 'comment' + : id + child.tag : isPrimitive(child.key) ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key) : child.key; @@ -7289,7 +7601,12 @@ var Transition = { child.data.show = true; } - if (oldChild && oldChild.data && !isSameChild(child, oldChild)) { + if ( + oldChild && + oldChild.data && + !isSameChild(child, oldChild) && + !isAsyncPlaceholder(oldChild) + ) { // replace old child transition data with fresh one // important for dynamic transitions! var oldData = oldChild && (oldChild.data.transition = extend({}, data)); @@ -7303,6 +7620,9 @@ var Transition = { }); return placeholder(h, rawChild) } else if (mode === 'in-out') { + if (isAsyncPlaceholder(child)) { + return oldRawChild + } var delayedLeave; var performLeave = function () { delayedLeave(); }; mergeVNodeHook(data, 'afterEnter', performLeave); @@ -7432,7 +7752,8 @@ var TransitionGroup = { if (!hasTransition) { return false } - if (this._hasMove != null) { + /* istanbul ignore if */ + if (this._hasMove) { return this._hasMove } // Detect whether an element with the move class applied has @@ -7526,8 +7847,9 @@ setTimeout(function () { } } if ("development" !== 'production' && - config.productionTip !== false && - inBrowser && typeof console !== 'undefined') { + config.productionTip !== false && + inBrowser && typeof console !== 'undefined' + ) { console[console.info ? 'info' : 'log']( "You are running Vue in development mode.\n" + "Make sure to turn on production mode when deploying for production.\n" + @@ -7541,7 +7863,7 @@ setTimeout(function () { // check whether current browser encodes a char inside attribute values function shouldDecode (content, encoded) { var div = document.createElement('div'); - div.innerHTML = "
"; + div.innerHTML = "
"; return div.innerHTML.indexOf(encoded) > 0 } @@ -7551,15 +7873,167 @@ var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', ' ') : false; /* */ -var isUnaryTag = makeMap( - 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + - 'link,meta,param,source,track,wbr' -); +var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; +var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; -// Elements that you can, intentionally, leave open -// (and which close themselves) -var canBeLeftOpenTag = makeMap( - 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' +var buildRegex = cached(function (delimiters) { + var open = delimiters[0].replace(regexEscapeRE, '\\$&'); + var close = delimiters[1].replace(regexEscapeRE, '\\$&'); + return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') +}); + +function parseText ( + text, + delimiters +) { + var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; + if (!tagRE.test(text)) { + return + } + var tokens = []; + var lastIndex = tagRE.lastIndex = 0; + var match, index; + while ((match = tagRE.exec(text))) { + index = match.index; + // push text token + if (index > lastIndex) { + tokens.push(JSON.stringify(text.slice(lastIndex, index))); + } + // tag token + var exp = parseFilters(match[1].trim()); + tokens.push(("_s(" + exp + ")")); + lastIndex = index + match[0].length; + } + if (lastIndex < text.length) { + tokens.push(JSON.stringify(text.slice(lastIndex))); + } + return tokens.join('+') +} + +/* */ + +function transformNode (el, options) { + var warn = options.warn || baseWarn; + var staticClass = getAndRemoveAttr(el, 'class'); + if ("development" !== 'production' && staticClass) { + var expression = parseText(staticClass, options.delimiters); + if (expression) { + warn( + "class=\"" + staticClass + "\": " + + 'Interpolation inside attributes has been removed. ' + + 'Use v-bind or the colon shorthand instead. For example, ' + + 'instead of
, use
.' + ); + } + } + if (staticClass) { + el.staticClass = JSON.stringify(staticClass); + } + var classBinding = getBindingAttr(el, 'class', false /* getStatic */); + if (classBinding) { + el.classBinding = classBinding; + } +} + +function genData (el) { + var data = ''; + if (el.staticClass) { + data += "staticClass:" + (el.staticClass) + ","; + } + if (el.classBinding) { + data += "class:" + (el.classBinding) + ","; + } + return data +} + +var klass$1 = { + staticKeys: ['staticClass'], + transformNode: transformNode, + genData: genData +}; + +/* */ + +function transformNode$1 (el, options) { + var warn = options.warn || baseWarn; + var staticStyle = getAndRemoveAttr(el, 'style'); + if (staticStyle) { + /* istanbul ignore if */ + { + var expression = parseText(staticStyle, options.delimiters); + if (expression) { + warn( + "style=\"" + staticStyle + "\": " + + 'Interpolation inside attributes has been removed. ' + + 'Use v-bind or the colon shorthand instead. For example, ' + + 'instead of
, use
.' + ); + } + } + el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); + } + + var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); + if (styleBinding) { + el.styleBinding = styleBinding; + } +} + +function genData$1 (el) { + var data = ''; + if (el.staticStyle) { + data += "staticStyle:" + (el.staticStyle) + ","; + } + if (el.styleBinding) { + data += "style:(" + (el.styleBinding) + "),"; + } + return data +} + +var style$1 = { + staticKeys: ['staticStyle'], + transformNode: transformNode$1, + genData: genData$1 +}; + +var modules$1 = [ + klass$1, + style$1 +]; + +/* */ + +function text (el, dir) { + if (dir.value) { + addProp(el, 'textContent', ("_s(" + (dir.value) + ")")); + } +} + +/* */ + +function html (el, dir) { + if (dir.value) { + addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")")); + } +} + +var directives$1 = { + model: model, + text: text, + html: html +}; + +/* */ + +var isUnaryTag = makeMap( + 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + + 'link,meta,param,source,track,wbr' +); + +// Elements that you can, intentionally, leave open +// (and which close themselves) +var canBeLeftOpenTag = makeMap( + 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' ); // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 @@ -7574,13 +8048,30 @@ var isNonPhrasingTag = makeMap( /* */ +var baseOptions = { + expectHTML: true, + modules: modules$1, + directives: directives$1, + isPreTag: isPreTag, + isUnaryTag: isUnaryTag, + mustUseProp: mustUseProp, + canBeLeftOpenTag: canBeLeftOpenTag, + isReservedTag: isReservedTag, + getTagNamespace: getTagNamespace, + staticKeys: genStaticKeys(modules$1) +}; + +/* */ + var decoder; -function decode (html) { - decoder = decoder || document.createElement('div'); - decoder.innerHTML = html; - return decoder.textContent -} +var he = { + decode: function decode (html) { + decoder = decoder || document.createElement('div'); + decoder.innerHTML = html; + return decoder.textContent + } +}; /** * Not type-checking this file because it's mostly vendor code. @@ -7640,6 +8131,10 @@ var decodingMap = { var encodedAttr = /&(?:lt|gt|quot|amp);/g; var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g; +// #5992 +var isIgnoreNewlineTag = makeMap('pre,textarea', true); +var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; }; + function decodeAttr (value, shouldDecodeNewlines) { var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; return value.replace(re, function (match) { return decodingMap[match]; }) @@ -7656,6 +8151,9 @@ function parseHTML (html, options) { last = html; // Make sure we're not in a plaintext content element like script/style if (!lastTag || !isPlainTextElement(lastTag)) { + if (shouldIgnoreFirstNewline(lastTag, html)) { + advance(1); + } var textEnd = html.indexOf('<'); if (textEnd === 0) { // Comment: @@ -7663,6 +8161,9 @@ function parseHTML (html, options) { var commentEnd = html.indexOf('-->'); if (commentEnd >= 0) { + if (options.shouldKeepComment) { + options.comment(html.substring(4, commentEnd)); + } advance(commentEnd + 3); continue } @@ -7702,20 +8203,20 @@ function parseHTML (html, options) { } } - var text = (void 0), rest$1 = (void 0), next = (void 0); + var text = (void 0), rest = (void 0), next = (void 0); if (textEnd >= 0) { - rest$1 = html.slice(textEnd); + rest = html.slice(textEnd); while ( - !endTag.test(rest$1) && - !startTagOpen.test(rest$1) && - !comment.test(rest$1) && - !conditionalComment.test(rest$1) + !endTag.test(rest) && + !startTagOpen.test(rest) && + !comment.test(rest) && + !conditionalComment.test(rest) ) { // < in plain text, be forgiving and treat it as text - next = rest$1.indexOf('<', 1); + next = rest.indexOf('<', 1); if (next < 0) { break } textEnd += next; - rest$1 = html.slice(textEnd); + rest = html.slice(textEnd); } text = html.substring(0, textEnd); advance(textEnd); @@ -7730,23 +8231,26 @@ function parseHTML (html, options) { options.chars(text); } } else { + var endTagLength = 0; var stackedTag = lastTag.toLowerCase(); var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(]*>)', 'i')); - var endTagLength = 0; - var rest = html.replace(reStackedTag, function (all, text, endTag) { + var rest$1 = html.replace(reStackedTag, function (all, text, endTag) { endTagLength = endTag.length; if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { text = text .replace(//g, '$1') .replace(//g, '$1'); } + if (shouldIgnoreFirstNewline(stackedTag, text)) { + text = text.slice(1); + } if (options.chars) { options.chars(text); } return '' }); - index += html.length - rest.length; - html = rest; + index += html.length - rest$1.length; + html = rest$1; parseEndTag(stackedTag, index - endTagLength, index); } @@ -7803,7 +8307,7 @@ function parseHTML (html, options) { } } - var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash; + var unary = isUnaryTag$$1(tagName) || !!unarySlash; var l = match.attrs.length; var attrs = new Array(l); @@ -7860,8 +8364,9 @@ function parseHTML (html, options) { // Close all the open elements, up the stack for (var i = stack.length - 1; i >= pos; i--) { if ("development" !== 'production' && - (i > pos || !tagName) && - options.warn) { + (i > pos || !tagName) && + options.warn + ) { options.warn( ("tag <" + (stack[i].tag) + "> has no matching end tag.") ); @@ -7891,45 +8396,6 @@ function parseHTML (html, options) { /* */ -var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; -var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; - -var buildRegex = cached(function (delimiters) { - var open = delimiters[0].replace(regexEscapeRE, '\\$&'); - var close = delimiters[1].replace(regexEscapeRE, '\\$&'); - return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') -}); - -function parseText ( - text, - delimiters -) { - var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; - if (!tagRE.test(text)) { - return - } - var tokens = []; - var lastIndex = tagRE.lastIndex = 0; - var match, index; - while ((match = tagRE.exec(text))) { - index = match.index; - // push text token - if (index > lastIndex) { - tokens.push(JSON.stringify(text.slice(lastIndex, index))); - } - // tag token - var exp = parseFilters(match[1].trim()); - tokens.push(("_s(" + exp + ")")); - lastIndex = index + match[0].length; - } - if (lastIndex < text.length) { - tokens.push(JSON.stringify(text.slice(lastIndex))); - } - return tokens.join('+') -} - -/* */ - var onRE = /^@|^v-on:/; var dirRE = /^v-|^@|^:/; var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/; @@ -7939,7 +8405,7 @@ var argRE = /:(.*)$/; var bindRE = /^:|^v-bind:/; var modifierRE = /\.[^.]+/g; -var decodeHTMLCached = cached(decode); +var decodeHTMLCached = cached(he.decode); // configurable state var warn$2; @@ -7959,12 +8425,15 @@ function parse ( options ) { warn$2 = options.warn || baseWarn; - platformGetTagNamespace = options.getTagNamespace || no; - platformMustUseProp = options.mustUseProp || no; + platformIsPreTag = options.isPreTag || no; - preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); + platformMustUseProp = options.mustUseProp || no; + platformGetTagNamespace = options.getTagNamespace || no; + transforms = pluckModuleFunction(options.modules, 'transformNode'); + preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); + delimiters = options.delimiters; var stack = []; @@ -7998,6 +8467,7 @@ function parse ( isUnaryTag: options.isUnaryTag, canBeLeftOpenTag: options.canBeLeftOpenTag, shouldDecodeNewlines: options.shouldDecodeNewlines, + shouldKeepComment: options.comments, start: function start (tag, attrs, unary) { // check namespace. // inherit parent ns if there is one @@ -8156,8 +8626,9 @@ function parse ( // IE textarea placeholder bug /* istanbul ignore if */ if (isIE && - currentParent.tag === 'textarea' && - currentParent.attrsMap.placeholder === text) { + currentParent.tag === 'textarea' && + currentParent.attrsMap.placeholder === text + ) { return } var children = currentParent.children; @@ -8180,6 +8651,13 @@ function parse ( }); } } + }, + comment: function comment (text) { + currentParent.children.push({ + type: 3, + text: text, + isComment: true + }); } }); return root @@ -8381,7 +8859,9 @@ function processAttrs (el) { ); } } - if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) { + if (!el.component && ( + isProp || platformMustUseProp(el.tag, el.attrsMap.type, name) + )) { addProp(el, name, value); } else { addAttr(el, name, value); @@ -8556,6 +9036,15 @@ function markStatic$1 (node) { node.static = false; } } + if (node.ifConditions) { + for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { + var block = node.ifConditions[i$1].block; + markStatic$1(block); + if (!block.static) { + node.static = false; + } + } + } } } @@ -8582,17 +9071,13 @@ function markStaticRoots (node, isInFor) { } } if (node.ifConditions) { - walkThroughConditionsBlocks(node.ifConditions, isInFor); + for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { + markStaticRoots(node.ifConditions[i$1].block, isInFor); + } } } } -function walkThroughConditionsBlocks (conditionBlocks, isInFor) { - for (var i = 1, len = conditionBlocks.length; i < len; i++) { - markStaticRoots(conditionBlocks[i].block, isInFor); - } -} - function isStatic (node) { if (node.type === 2) { // expression return false @@ -8661,17 +9146,17 @@ var modifierCode = { function genHandlers ( events, - native, + isNative, warn ) { - var res = native ? 'nativeOn:{' : 'on:{'; + var res = isNative ? 'nativeOn:{' : 'on:{'; for (var name in events) { var handler = events[name]; // #5330: warn click.right, since right clicks do not actually fire click events. if ("development" !== 'production' && - name === 'click' && - handler && handler.modifiers && handler.modifiers.right - ) { + name === 'click' && + handler && handler.modifiers && handler.modifiers.right + ) { warn( "Use \"contextmenu\" instead of \"click.right\" since right clicks " + "do not actually fire \"click\" events." @@ -8747,99 +9232,101 @@ function genFilterCode (key) { /* */ +function on (el, dir) { + if ("development" !== 'production' && dir.modifiers) { + warn("v-on without argument does not support modifiers."); + } + el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); }; +} + +/* */ + function bind$1 (el, dir) { el.wrapData = function (code) { - return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")") + return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")") }; } /* */ var baseDirectives = { + on: on, bind: bind$1, cloak: noop }; /* */ -// configurable state -var warn$3; -var transforms$1; -var dataGenFns; -var platformDirectives$1; -var isPlatformReservedTag$1; -var staticRenderFns; -var onceCount; -var currentOptions; +var CodegenState = function CodegenState (options) { + this.options = options; + this.warn = options.warn || baseWarn; + this.transforms = pluckModuleFunction(options.modules, 'transformCode'); + this.dataGenFns = pluckModuleFunction(options.modules, 'genData'); + this.directives = extend(extend({}, baseDirectives), options.directives); + var isReservedTag = options.isReservedTag || no; + this.maybeComponent = function (el) { return !isReservedTag(el.tag); }; + this.onceId = 0; + this.staticRenderFns = []; +}; + + function generate ( ast, options ) { - // save previous staticRenderFns so generate calls can be nested - var prevStaticRenderFns = staticRenderFns; - var currentStaticRenderFns = staticRenderFns = []; - var prevOnceCount = onceCount; - onceCount = 0; - currentOptions = options; - warn$3 = options.warn || baseWarn; - transforms$1 = pluckModuleFunction(options.modules, 'transformCode'); - dataGenFns = pluckModuleFunction(options.modules, 'genData'); - platformDirectives$1 = options.directives || {}; - isPlatformReservedTag$1 = options.isReservedTag || no; - var code = ast ? genElement(ast) : '_c("div")'; - staticRenderFns = prevStaticRenderFns; - onceCount = prevOnceCount; + var state = new CodegenState(options); + var code = ast ? genElement(ast, state) : '_c("div")'; return { render: ("with(this){return " + code + "}"), - staticRenderFns: currentStaticRenderFns + staticRenderFns: state.staticRenderFns } } -function genElement (el) { +function genElement (el, state) { if (el.staticRoot && !el.staticProcessed) { - return genStatic(el) + return genStatic(el, state) } else if (el.once && !el.onceProcessed) { - return genOnce(el) + return genOnce(el, state) } else if (el.for && !el.forProcessed) { - return genFor(el) + return genFor(el, state) } else if (el.if && !el.ifProcessed) { - return genIf(el) + return genIf(el, state) } else if (el.tag === 'template' && !el.slotTarget) { - return genChildren(el) || 'void 0' + return genChildren(el, state) || 'void 0' } else if (el.tag === 'slot') { - return genSlot(el) + return genSlot(el, state) } else { // component or element var code; if (el.component) { - code = genComponent(el.component, el); + code = genComponent(el.component, el, state); } else { - var data = el.plain ? undefined : genData(el); + var data = el.plain ? undefined : genData$2(el, state); - var children = el.inlineTemplate ? null : genChildren(el, true); + var children = el.inlineTemplate ? null : genChildren(el, state, true); code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; } // module transforms - for (var i = 0; i < transforms$1.length; i++) { - code = transforms$1[i](el, code); + for (var i = 0; i < state.transforms.length; i++) { + code = state.transforms[i](el, code); } return code } } // hoist static sub-trees out -function genStatic (el) { +function genStatic (el, state) { el.staticProcessed = true; - staticRenderFns.push(("with(this){return " + (genElement(el)) + "}")); - return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") + state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}")); + return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") } // v-once -function genOnce (el) { +function genOnce (el, state) { el.onceProcessed = true; if (el.if && !el.ifProcessed) { - return genIf(el) + return genIf(el, state) } else if (el.staticInFor) { var key = ''; var parent = el.parent; @@ -8851,51 +9338,72 @@ function genOnce (el) { parent = parent.parent; } if (!key) { - "development" !== 'production' && warn$3( + "development" !== 'production' && state.warn( "v-once can only be used inside v-for that is keyed. " ); - return genElement(el) + return genElement(el, state) } - return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")") + return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")") } else { - return genStatic(el) + return genStatic(el, state) } } -function genIf (el) { +function genIf ( + el, + state, + altGen, + altEmpty +) { el.ifProcessed = true; // avoid recursion - return genIfConditions(el.ifConditions.slice()) + return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty) } -function genIfConditions (conditions) { +function genIfConditions ( + conditions, + state, + altGen, + altEmpty +) { if (!conditions.length) { - return '_e()' + return altEmpty || '_e()' } var condition = conditions.shift(); if (condition.exp) { - return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions))) + return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty))) } else { return ("" + (genTernaryExp(condition.block))) } // v-if with v-once should generate code like (a)?_m(0):_m(1) function genTernaryExp (el) { - return el.once ? genOnce(el) : genElement(el) + return altGen + ? altGen(el, state) + : el.once + ? genOnce(el, state) + : genElement(el, state) } } -function genFor (el) { +function genFor ( + el, + state, + altGen, + altHelper +) { var exp = el.for; var alias = el.alias; var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; - if ( - "development" !== 'production' && - maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key + if ("development" !== 'production' && + state.maybeComponent(el) && + el.tag !== 'slot' && + el.tag !== 'template' && + !el.key ) { - warn$3( + state.warn( "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " + "v-for should have explicit keys. " + "See https://vuejs.org/guide/list.html#key for more info.", @@ -8904,18 +9412,18 @@ function genFor (el) { } el.forProcessed = true; // avoid recursion - return "_l((" + exp + ")," + + return (altHelper || '_l') + "((" + exp + ")," + "function(" + alias + iterator1 + iterator2 + "){" + - "return " + (genElement(el)) + + "return " + ((altGen || genElement)(el, state)) + '})' } -function genData (el) { +function genData$2 (el, state) { var data = '{'; // directives first. // directives may mutate the el's other properties before they are generated. - var dirs = genDirectives(el); + var dirs = genDirectives(el, state); if (dirs) { data += dirs + ','; } // key @@ -8938,8 +9446,8 @@ function genData (el) { data += "tag:\"" + (el.tag) + "\","; } // module data generation functions - for (var i = 0; i < dataGenFns.length; i++) { - data += dataGenFns[i](el); + for (var i = 0; i < state.dataGenFns.length; i++) { + data += state.dataGenFns[i](el); } // attributes if (el.attrs) { @@ -8951,10 +9459,10 @@ function genData (el) { } // event handlers if (el.events) { - data += (genHandlers(el.events, false, warn$3)) + ","; + data += (genHandlers(el.events, false, state.warn)) + ","; } if (el.nativeEvents) { - data += (genHandlers(el.nativeEvents, true, warn$3)) + ","; + data += (genHandlers(el.nativeEvents, true, state.warn)) + ","; } // slot target if (el.slotTarget) { @@ -8962,7 +9470,7 @@ function genData (el) { } // scoped slots if (el.scopedSlots) { - data += (genScopedSlots(el.scopedSlots)) + ","; + data += (genScopedSlots(el.scopedSlots, state)) + ","; } // component v-model if (el.model) { @@ -8970,7 +9478,7 @@ function genData (el) { } // inline-template if (el.inlineTemplate) { - var inlineTemplate = genInlineTemplate(el); + var inlineTemplate = genInlineTemplate(el, state); if (inlineTemplate) { data += inlineTemplate + ","; } @@ -8980,10 +9488,14 @@ function genData (el) { if (el.wrapData) { data = el.wrapData(data); } + // v-on data wrap + if (el.wrapListeners) { + data = el.wrapListeners(data); + } return data } -function genDirectives (el) { +function genDirectives (el, state) { var dirs = el.directives; if (!dirs) { return } var res = 'directives:['; @@ -8992,11 +9504,11 @@ function genDirectives (el) { for (i = 0, l = dirs.length; i < l; i++) { dir = dirs[i]; needRuntime = true; - var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name]; + var gen = state.directives[dir.name]; if (gen) { // compile-time directive that manipulates AST. // returns true if it also needs a runtime counterpart. - needRuntime = !!gen(el, dir, warn$3); + needRuntime = !!gen(el, dir, state.warn); } if (needRuntime) { hasRuntime = true; @@ -9008,43 +9520,81 @@ function genDirectives (el) { } } -function genInlineTemplate (el) { +function genInlineTemplate (el, state) { var ast = el.children[0]; if ("development" !== 'production' && ( el.children.length > 1 || ast.type !== 1 )) { - warn$3('Inline-template components must have exactly one child element.'); + state.warn('Inline-template components must have exactly one child element.'); } if (ast.type === 1) { - var inlineRenderFns = generate(ast, currentOptions); + var inlineRenderFns = generate(ast, state.options); return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}") } } -function genScopedSlots (slots) { - return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])") +function genScopedSlots ( + slots, + state +) { + return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { + return genScopedSlot(key, slots[key], state) + }).join(',')) + "])") } -function genScopedSlot (key, el) { - return "[" + key + ",function(" + (String(el.attrsMap.scope)) + "){" + +function genScopedSlot ( + key, + el, + state +) { + if (el.for && !el.forProcessed) { + return genForScopedSlot(key, el, state) + } + return "{key:" + key + ",fn:function(" + (String(el.attrsMap.scope)) + "){" + "return " + (el.tag === 'template' - ? genChildren(el) || 'void 0' - : genElement(el)) + "}]" + ? genChildren(el, state) || 'void 0' + : genElement(el, state)) + "}}" } -function genChildren (el, checkSkip) { +function genForScopedSlot ( + key, + el, + state +) { + var exp = el.for; + var alias = el.alias; + var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; + var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; + el.forProcessed = true; // avoid recursion + return "_l((" + exp + ")," + + "function(" + alias + iterator1 + iterator2 + "){" + + "return " + (genScopedSlot(key, el, state)) + + '})' +} + +function genChildren ( + el, + state, + checkSkip, + altGenElement, + altGenNode +) { 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) + el$1.for && + el$1.tag !== 'template' && + el$1.tag !== 'slot' + ) { + return (altGenElement || genElement)(el$1, state) } - var normalizationType = checkSkip ? getNormalizationType(children) : 0; - return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) + var normalizationType = checkSkip + ? getNormalizationType(children, state.maybeComponent) + : 0; + var gen = altGenNode || genNode; + return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) } } @@ -9052,7 +9602,10 @@ function genChildren (el, checkSkip) { // 0: no normalization needed // 1: simple normalization needed (possible 1-level deep nested array) // 2: full normalization needed -function getNormalizationType (children) { +function getNormalizationType ( + children, + maybeComponent +) { var res = 0; for (var i = 0; i < children.length; i++) { var el = children[i]; @@ -9076,13 +9629,11 @@ function needsNormalization (el) { return el.for !== undefined || el.tag === 'template' || el.tag === 'slot' } -function maybeComponent (el) { - return !isPlatformReservedTag$1(el.tag) -} - -function genNode (node) { +function genNode (node, state) { if (node.type === 1) { - return genElement(node) + return genElement(node, state) + } if (node.type === 3 && node.isComment) { + return genComment(node) } else { return genText(node) } @@ -9094,9 +9645,13 @@ function genText (text) { : transformSpecialNewlines(JSON.stringify(text.text))) + ")") } -function genSlot (el) { +function genComment (comment) { + return ("_e('" + (comment.text) + "')") +} + +function genSlot (el, state) { var slotName = el.slotName || '"default"'; - var children = genChildren(el); + var children = genChildren(el, state); var res = "_t(" + slotName + (children ? ("," + children) : ''); var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}"); var bind$$1 = el.attrsMap['v-bind']; @@ -9113,9 +9668,13 @@ 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, true); - return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") +function genComponent ( + componentName, + el, + state +) { + var children = el.inlineTemplate ? null : genChildren(el, state, true); + return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")") } function genProps (props) { @@ -9233,21 +9792,7 @@ function checkExpression (exp, text, errors) { /* */ -function baseCompile ( - template, - options -) { - var ast = parse(template.trim(), options); - optimize(ast, options); - var code = generate(ast, options); - return { - ast: ast, - render: code.render, - staticRenderFns: code.staticRenderFns - } -} - -function makeFunction (code, errors) { +function createFunction (code, errors) { try { return new Function(code) } catch (err) { @@ -9256,50 +9801,10 @@ function makeFunction (code, errors) { } } -function createCompiler (baseOptions) { - var functionCompileCache = Object.create(null); - - function compile ( - template, - options - ) { - var finalOptions = Object.create(baseOptions); - var errors = []; - var tips = []; - finalOptions.warn = function (msg, tip$$1) { - (tip$$1 ? tips : errors).push(msg); - }; - - if (options) { - // merge custom modules - if (options.modules) { - finalOptions.modules = (baseOptions.modules || []).concat(options.modules); - } - // merge custom directives - if (options.directives) { - finalOptions.directives = extend( - Object.create(baseOptions.directives), - options.directives - ); - } - // copy other options - for (var key in options) { - if (key !== 'modules' && key !== 'directives') { - finalOptions[key] = options[key]; - } - } - } - - var compiled = baseCompile(template, finalOptions); - { - errors.push.apply(errors, detectErrors(compiled.ast)); - } - compiled.errors = errors; - compiled.tips = tips; - return compiled - } +function createCompileToFunctionFn (compile) { + var cache = Object.create(null); - function compileToFunctions ( + return function compileToFunctions ( template, options, vm @@ -9328,8 +9833,8 @@ function createCompiler (baseOptions) { var key = options.delimiters ? String(options.delimiters) + template : template; - if (functionCompileCache[key]) { - return functionCompileCache[key] + if (cache[key]) { + return cache[key] } // compile @@ -9352,12 +9857,10 @@ function createCompiler (baseOptions) { // turn code into functions var res = {}; var fnGenErrors = []; - res.render = makeFunction(compiled.render, fnGenErrors); - var l = compiled.staticRenderFns.length; - res.staticRenderFns = new Array(l); - for (var i = 0; i < l; i++) { - res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors); - } + res.render = createFunction(compiled.render, fnGenErrors); + res.staticRenderFns = compiled.staticRenderFns.map(function (code) { + return createFunction(code, fnGenErrors) + }); // check function generation errors. // this should only happen if there is a bug in the compiler itself. @@ -9378,143 +9881,83 @@ function createCompiler (baseOptions) { } } - return (functionCompileCache[key] = res) - } - - return { - compile: compile, - compileToFunctions: compileToFunctions + return (cache[key] = res) } } /* */ -function transformNode (el, options) { - var warn = options.warn || baseWarn; - var staticClass = getAndRemoveAttr(el, 'class'); - if ("development" !== 'production' && staticClass) { - var expression = parseText(staticClass, options.delimiters); - if (expression) { - warn( - "class=\"" + staticClass + "\": " + - 'Interpolation inside attributes has been removed. ' + - 'Use v-bind or the colon shorthand instead. For example, ' + - 'instead of
, use
.' - ); - } - } - if (staticClass) { - el.staticClass = JSON.stringify(staticClass); - } - var classBinding = getBindingAttr(el, 'class', false /* getStatic */); - if (classBinding) { - el.classBinding = classBinding; - } -} - -function genData$1 (el) { - var data = ''; - if (el.staticClass) { - data += "staticClass:" + (el.staticClass) + ","; - } - if (el.classBinding) { - data += "class:" + (el.classBinding) + ","; - } - return data -} - -var klass$1 = { - staticKeys: ['staticClass'], - transformNode: transformNode, - genData: genData$1 -}; +function createCompilerCreator (baseCompile) { + return function createCompiler (baseOptions) { + function compile ( + template, + options + ) { + var finalOptions = Object.create(baseOptions); + var errors = []; + var tips = []; + finalOptions.warn = function (msg, tip) { + (tip ? tips : errors).push(msg); + }; -/* */ + if (options) { + // merge custom modules + if (options.modules) { + finalOptions.modules = + (baseOptions.modules || []).concat(options.modules); + } + // merge custom directives + if (options.directives) { + finalOptions.directives = extend( + Object.create(baseOptions.directives), + options.directives + ); + } + // copy other options + for (var key in options) { + if (key !== 'modules' && key !== 'directives') { + finalOptions[key] = options[key]; + } + } + } -function transformNode$1 (el, options) { - var warn = options.warn || baseWarn; - var staticStyle = getAndRemoveAttr(el, 'style'); - if (staticStyle) { - /* istanbul ignore if */ - { - var expression = parseText(staticStyle, options.delimiters); - if (expression) { - warn( - "style=\"" + staticStyle + "\": " + - 'Interpolation inside attributes has been removed. ' + - 'Use v-bind or the colon shorthand instead. For example, ' + - 'instead of
, use
.' - ); + var compiled = baseCompile(template, finalOptions); + { + errors.push.apply(errors, detectErrors(compiled.ast)); } + compiled.errors = errors; + compiled.tips = tips; + return compiled } - el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); - } - - var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); - if (styleBinding) { - el.styleBinding = styleBinding; - } -} -function genData$2 (el) { - var data = ''; - if (el.staticStyle) { - data += "staticStyle:" + (el.staticStyle) + ","; - } - if (el.styleBinding) { - data += "style:(" + (el.styleBinding) + "),"; - } - return data -} - -var style$1 = { - staticKeys: ['staticStyle'], - transformNode: transformNode$1, - genData: genData$2 -}; - -var modules$1 = [ - klass$1, - style$1 -]; - -/* */ - -function text (el, dir) { - if (dir.value) { - addProp(el, 'textContent', ("_s(" + (dir.value) + ")")); + return { + compile: compile, + compileToFunctions: createCompileToFunctionFn(compile) + } } } /* */ -function html (el, dir) { - if (dir.value) { - addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")")); +// `createCompilerCreator` allows creating compilers that use alternative +// parser/optimizer/codegen, e.g the SSR optimizing compiler. +// Here we just export a default compiler using the default parts. +var createCompiler = createCompilerCreator(function baseCompile ( + template, + options +) { + var ast = parse(template.trim(), options); + optimize(ast, options); + var code = generate(ast, options); + return { + ast: ast, + render: code.render, + staticRenderFns: code.staticRenderFns } -} - -var directives$1 = { - model: model, - text: text, - html: html -}; +}); /* */ -var baseOptions = { - expectHTML: true, - modules: modules$1, - directives: directives$1, - isPreTag: isPreTag, - isUnaryTag: isUnaryTag, - mustUseProp: mustUseProp, - canBeLeftOpenTag: canBeLeftOpenTag, - isReservedTag: isReservedTag, - getTagNamespace: getTagNamespace, - staticKeys: genStaticKeys(modules$1) -}; - var ref$1 = createCompiler(baseOptions); var compileToFunctions = ref$1.compileToFunctions; @@ -9575,7 +10018,8 @@ Vue$3.prototype.$mount = function ( var ref = compileToFunctions(template, { shouldDecodeNewlines: shouldDecodeNewlines, - delimiters: options.delimiters + delimiters: options.delimiters, + comments: options.comments }, this); var render = ref.render; var staticRenderFns = ref.staticRenderFns; diff --git a/themes/vue/source/js/vue.min.js b/themes/vue/source/js/vue.min.js index 97ac4cf973..55568b332f 100644 --- a/themes/vue/source/js/vue.min.js +++ b/themes/vue/source/js/vue.min.js @@ -1,8 +1,6 @@ /*! - * Vue.js v2.3.0 + * Vue.js v2.4.0 * (c) 2014-2017 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 void 0===e||null===e}function t(e){return void 0!==e&&null!==e}function n(e){return!0===e}function r(e){return"string"==typeof e||"number"==typeof e}function i(e){return null!==e&&"object"==typeof e}function o(e){return"[object Object]"===Ai.call(e)}function a(e){return"[object RegExp]"===Ai.call(e)}function s(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function c(e){var t=parseFloat(e);return isNaN(t)?e:t}function u(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}function f(e,t){return Si.call(e,t)}function p(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}function d(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 v(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function h(e,t){for(var n in t)e[n]=t[n];return e}function m(e){for(var t={},n=0;n=0&&$o[n].id>e.id;)n--;$o.splice(Math.max(n,Ao)+1,0,e)}else $o.push(e);Co||(Co=!0,ro($e))}}function Ae(e){To.clear(),Oe(e,To)}function Oe(e,t){var n,r,o=Array.isArray(e);if((o||i(e))&&Object.isExtensible(e)){if(e.__ob__){var a=e.__ob__.dep.id;if(t.has(a))return;t.add(a)}if(o)for(n=e.length;n--;)Oe(e[n],t);else for(r=Object.keys(e),n=r.length;n--;)Oe(e[r[n]],t)}}function Se(e,t,n){Eo.get=function(){return this[t][n]},Eo.set=function(e){this[t][n]=e},Object.defineProperty(e,n,Eo)}function Te(e){e._watchers=[];var t=e.$options;t.props&&Ee(e,t.props),t.methods&&Me(e,t.methods),t.data?je(e):E(e._data={},!0),t.computed&&Le(e,t.computed),t.watch&&Pe(e,t.watch)}function Ee(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[],o=!e.$parent;lo.shouldConvert=o;for(var a in t)!function(o){i.push(o);var a=U(o,t,n,e);j(r,o,a),o in e||Se(e,"_props",o)}(a);lo.shouldConvert=!0}function je(e){var t=e.$options.data;t=e._data="function"==typeof t?Ne(t,e):t||{},o(t)||(t={});for(var n=Object.keys(t),r=e.$options.props,i=n.length;i--;)r&&f(r,n[i])||$(n[i])||Se(e,"_data",n[i]);E(t,!0)}function Ne(e,t){try{return e.call(t)}catch(e){return C(e,t,"data()"),{}}}function Le(e,t){var n=e._computedWatchers=Object.create(null);for(var r in t){var i=t[r],o="function"==typeof i?i:i.get;n[r]=new So(e,o,g,jo),r in e||Ie(e,r,i)}}function Ie(e,t,n){"function"==typeof n?(Eo.get=De(t),Eo.set=g):(Eo.get=n.get?!1!==n.cache?De(t):n.get:g,Eo.set=n.set?n.set:g),Object.defineProperty(e,t,Eo)}function De(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),oo.target&&t.depend(),t.value}}function Me(e,t){e.$options.props;for(var n in t)e[n]=null==t[n]?g:d(t[n],e)}function Pe(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i=0||n.indexOf(e[i])<0)&&r.push(e[i]);return r}return e}function pt(e){this._init(e)}function dt(e){e.use=function(e){if(!e.installed){var t=v(arguments,1);return t.unshift(this),"function"==typeof e.install?e.install.apply(e,t):"function"==typeof e&&e.apply(null,t),e.installed=!0,this}}}function vt(e){e.mixin=function(e){this.options=B(this.options,e)}}function ht(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r=n.cid,i=e._Ctor||(e._Ctor={});if(i[r])return i[r];var o=e.name||n.options.name,a=function(e){this._init(e)};return a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.cid=t++,a.options=B(n.options,e),a.super=n,a.options.props&&mt(a),a.options.computed&>(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,Di.forEach(function(e){a[e]=n[e]}),o&&(a.options.components[o]=a),a.superOptions=n.options,a.extendOptions=e,a.sealedOptions=h({},a.options),i[r]=a,a}}function mt(e){var t=e.options.props;for(var n in t)Se(e.prototype,"_props",n)}function gt(e){var t=e.options.computed;for(var n in t)Ie(e.prototype,n,t[n])}function yt(e){Di.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&o(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}function _t(e){return e&&(e.Ctor.options.name||e.tag)}function bt(e,t){return"string"==typeof e?e.split(",").indexOf(t)>-1:!!a(e)&&e.test(t)}function $t(e,t,n){for(var r in e){var i=e[r];if(i){var o=_t(i.componentOptions);o&&!n(o)&&(i!==t&&xt(i),e[r]=null)}}}function xt(e){e&&e.componentInstance.$destroy()}function wt(e){for(var n=e.data,r=e,i=e;t(i.componentInstance);)i=i.componentInstance._vnode,i.data&&(n=Ct(i.data,n));for(;t(r=r.parent);)r.data&&(n=Ct(n,r.data));return kt(n)}function Ct(e,n){return{staticClass:At(e.staticClass,n.staticClass),class:t(e.class)?[e.class,n.class]:n.class}}function kt(e){var n=e.class,r=e.staticClass;return t(r)||t(n)?At(r,Ot(n)):""}function At(e,t){return e?t?e+" "+t:e:t||""}function Ot(n){if(e(n))return"";if("string"==typeof n)return n;var r="";if(Array.isArray(n)){for(var o,a=0,s=n.length;a-1?ua[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:ua[e]=/HTMLUnknownElement/.test(t.toString())}function Et(e){if("string"==typeof e){var t=document.querySelector(e);return t||document.createElement("div")}return e}function jt(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&void 0!==t.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)}function Nt(e,t){return document.createElementNS(ia[e],t)}function Lt(e){return document.createTextNode(e)}function It(e){return document.createComment(e)}function Dt(e,t,n){e.insertBefore(t,n)}function Mt(e,t){e.removeChild(t)}function Pt(e,t){e.appendChild(t)}function Rt(e){return e.parentNode}function Ft(e){return e.nextSibling}function Bt(e){return e.tagName}function Ht(e,t){e.textContent=t}function Ut(e,t,n){e.setAttribute(t,n)}function Vt(e,t){var n=e.data.ref;if(n){var r=e.context,i=e.componentInstance||e.elm,o=r.$refs;t?Array.isArray(o[n])?l(o[n],i):o[n]===i&&(o[n]=void 0):e.data.refInFor?Array.isArray(o[n])&&o[n].indexOf(i)<0?o[n].push(i):o[n]=[i]:o[n]=i}}function zt(e,n){return e.key===n.key&&e.tag===n.tag&&e.isComment===n.isComment&&t(e.data)===t(n.data)&&Jt(e,n)}function Jt(e,n){if("input"!==e.tag)return!0;var r;return(t(r=e.data)&&t(r=r.attrs)&&r.type)===(t(r=n.data)&&t(r=r.attrs)&&r.type)}function Kt(e,n,r){var i,o,a={};for(i=n;i<=r;++i)o=e[i].key,t(o)&&(a[o]=i);return a}function qt(e,t){(e.data.directives||t.data.directives)&&Wt(e,t)}function Wt(e,t){var n,r,i,o=e===pa,a=t===pa,s=Zt(e.data.directives,e.context),c=Zt(t.data.directives,t.context),u=[],l=[];for(n in c)r=s[n],i=c[n],r?(i.oldValue=r.value,Yt(i,"update",t,e),i.def&&i.def.componentUpdated&&l.push(i)):(Yt(i,"bind",t,e),i.def&&i.def.inserted&&u.push(i));if(u.length){var f=function(){for(var n=0;n=0&&" "===(m=e.charAt(h));h--);m&&_a.test(m)||(l=!0)}}else void 0===o?(v=i+1,o=e.slice(0,i).trim()):t();if(void 0===o?o=e.slice(0,i).trim():0!==v&&t(),a)for(i=0;i=Bo}function gn(e){return 34===e||39===e}function yn(e){var t=1;for(zo=Vo;!mn();)if(e=hn(),gn(e))_n(e);else if(91===e&&t++,93===e&&t--,0===t){Jo=Vo;break}}function _n(e){for(var t=e;!mn()&&(e=hn())!==t;);}function bn(e,t,n){Ko=n;var r=t.value,i=t.modifiers,o=e.tag,a=e.attrsMap.type;if("select"===o)wn(e,r,i);else if("input"===o&&"checkbox"===a)$n(e,r,i);else if("input"===o&&"radio"===a)xn(e,r,i);else if("input"===o||"textarea"===o)Cn(e,r,i);else if(!Pi.isReservedTag(o))return pn(e,r,i),!1;return!0}function $n(e,t,n){var r=n&&n.number,i=ln(e,"value")||"null",o=ln(e,"true-value")||"true",a=ln(e,"false-value")||"false";an(e,"checked","Array.isArray("+t+")?_i("+t+","+i+")>-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),un(e,$a,"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{"+dn(t,"$$c")+"}",null,!0)}function xn(e,t,n){var r=n&&n.number,i=ln(e,"value")||"null";i=r?"_n("+i+")":i,an(e,"checked","_q("+t+","+i+")"),un(e,$a,dn(t,i),null,!0)}function wn(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")+"})",o="var $$selectedVal = "+i+";";o=o+" "+dn(t,"$event.target.multiple ? $$selectedVal : $$selectedVal[0]"),un(e,"change",o,null,!0)}function Cn(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?ba:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=dn(t,l);c&&(f="if($event.target.composing)return;"+f),an(e,"value","("+t+")"),un(e,u,f,null,!0),(s||a||"number"===r)&&un(e,"blur","$forceUpdate()")}function kn(e){var n;t(e[ba])&&(n=zi?"change":"input",e[n]=[].concat(e[ba],e[n]||[]),delete e[ba]),t(e[$a])&&(n=Zi?"click":"change",e[n]=[].concat(e[$a],e[n]||[]),delete e[$a])}function An(e,t,n,r,i){if(n){var o=t,a=qo;t=function(n){null!==(1===arguments.length?o(n):o.apply(null,arguments))&&On(e,t,r,a)}}qo.addEventListener(e,t,Gi?{capture:r,passive:i}:r)}function On(e,t,n,r){(r||qo).removeEventListener(e,t,n)}function Sn(t,n){if(!e(t.data.on)||!e(n.data.on)){var r=n.data.on||{},i=t.data.on||{};qo=n.elm,kn(r),G(r,i,An,On,n.context)}}function Tn(n,r){if(!e(n.data.domProps)||!e(r.data.domProps)){var i,o,a=r.elm,s=n.data.domProps||{},c=r.data.domProps||{};t(c.__ob__)&&(c=r.data.domProps=h({},c));for(i in s)e(c[i])&&(a[i]="");for(i in c)if(o=c[i],"textContent"!==i&&"innerHTML"!==i||(r.children&&(r.children.length=0),o!==s[i]))if("value"===i){a._value=o;var u=null==o?"":String(o);En(a,r,u)&&(a.value=u)}else a[i]=o}}function En(e,t,n){return!e.composing&&("option"===t.tag||jn(e,n)||Nn(e,n))}function jn(e,t){return document.activeElement!==e&&e.value!==t}function Nn(e,n){var r=e.value,i=e._vModifiers;return t(i)&&i.number||"number"===e.type?c(r)!==c(n):t(i)&&i.trim?r.trim()!==n.trim():r!==n}function Ln(e){var t=In(e.style);return e.staticStyle?h(e.staticStyle,t):t}function In(e){return Array.isArray(e)?m(e):"string"==typeof e?Ca(e):e}function Dn(e,t){var n,r={};if(t)for(var i=e;i.componentInstance;)i=i.componentInstance._vnode,i.data&&(n=Ln(i.data))&&h(r,n);(n=Ln(e.data))&&h(r,n);for(var o=e;o=o.parent;)o.data&&(n=Ln(o.data))&&h(r,n);return r}function Mn(n,r){var i=r.data,o=n.data;if(!(e(i.staticStyle)&&e(i.style)&&e(o.staticStyle)&&e(o.style))){var a,s,c=r.elm,u=o.staticStyle,l=o.normalizedStyle||o.style||{},f=u||l,p=In(r.data.style)||{};r.data.normalizedStyle=t(p.__ob__)?h({},p):p;var d=Dn(r,!0);for(s in f)e(d[s])&&Oa(c,s,"");for(s in d)(a=d[s])!==f[s]&&Oa(c,s,null==a?"":a)}}function Pn(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-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 Rn(e,t){if(t&&(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 Fn(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&h(t,ja(e.name||"v")),h(t,e),t}return"string"==typeof e?ja(e):void 0}}function Bn(e){Fa(function(){Fa(e)})}function Hn(e,t){(e._transitionClasses||(e._transitionClasses=[])).push(t),Pn(e,t)}function Un(e,t){e._transitionClasses&&l(e._transitionClasses,t),Rn(e,t)}function Vn(e,t,n){var r=zn(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===La?Ma:Ra,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c0&&(n=La,l=a,f=o.length):t===Ia?u>0&&(n=Ia,l=u,f=c.length):(l=Math.max(a,u),n=l>0?a>u?La:Ia:null,f=n?n===La?o.length:c.length:0),{type:n,timeout:l,propCount:f,hasTransform:n===La&&Ba.test(r[Da+"Property"])}}function Jn(e,t){for(;e.length1}function Yn(e,t){!0!==t.data.show&&qn(t)}function Qn(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(y(er(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function Xn(e,t){for(var n=0,r=t.length;n=0&&a[i].lowerCasedTag!==s;i--);else i=0;if(i>=0){for(var c=a.length-1;c>=i;c--)t.end&&t.end(a[c].tag,n,r);a.length=i,o=i&&a[i-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,r):"p"===s&&(t.start&&t.start(e,[],!1,n,r),t.end&&t.end(e,n,r))}for(var i,o,a=[],s=t.expectHTML,c=t.isUnaryTag||Ni,u=t.canBeLeftOpenTag||Ni,l=0;e;){if(i=e,o&&Ns(o)){var f=o.toLowerCase(),p=Ls[f]||(Ls[f]=new RegExp("([\\s\\S]*?)(]*>)","i")),d=0,v=e.replace(p,function(e,n,r){return d=r.length,Ns(f)||"noscript"===f||(n=n.replace(//g,"$1").replace(//g,"$1")),t.chars&&t.chars(n),""});l+=e.length-v.length,e=v,r(f,l-d,l)}else{var h=e.indexOf("<");if(0===h){if(fs.test(e)){var m=e.indexOf("--\x3e");if(m>=0){n(m+3);continue}}if(ps.test(e)){var g=e.indexOf("]>");if(g>=0){n(g+2);continue}}var y=e.match(ls);if(y){n(y[0].length);continue}var _=e.match(us);if(_){var b=l;n(_[0].length),r(_[1],b,l);continue}var $=function(){var t=e.match(ss);if(t){var r={tagName:t[1],attrs:[],start:l};n(t[0].length);for(var i,o;!(i=e.match(cs))&&(o=e.match(os));)n(o[0].length),r.attrs.push(o);if(i)return r.unarySlash=i[1],n(i[0].length),r.end=l,r}}();if($){!function(e){var n=e.tagName,i=e.unarySlash;s&&("p"===o&&rs(n)&&r(o),u(n)&&o===n&&r(n));for(var l=c(n)||"html"===n&&"head"===o||!!i,f=e.attrs.length,p=new Array(f),d=0;d=0){for(w=e.slice(h);!(us.test(w)||ss.test(w)||fs.test(w)||ps.test(w)||(C=w.indexOf("<",1))<0);)h+=C,w=e.slice(h);x=e.substring(0,h),n(h)}h<0&&(x=e,e=""),t.chars&&x&&t.chars(x)}if(e===i){t.chars&&t.chars(e);break}}r()}function mr(e,t){var n=t?Rs(t):Ps;if(n.test(e)){for(var r,i,o=[],a=n.lastIndex=0;r=n.exec(e);){i=r.index,i>a&&o.push(JSON.stringify(e.slice(a,i)));var s=tn(r[1].trim());o.push("_s("+s+")"),a=i+r[0].length}return a0,Ki=Vi&&Vi.indexOf("edge/")>0,qi=Vi&&Vi.indexOf("android")>0,Wi=Vi&&/iphone|ipad|ipod|ios/.test(Vi),Zi=Vi&&/chrome\/\d+/.test(Vi)&&!Ki,Gi=!1;if(Ui)try{var Yi={};Object.defineProperty(Yi,"passive",{get:function(){Gi=!0}}),window.addEventListener("test-passive",null,Yi)}catch(e){}var Qi,Xi,eo=function(){return void 0===Qi&&(Qi=!Ui&&"undefined"!=typeof global&&"server"===global.process.env.VUE_ENV),Qi},to=Ui&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,no="undefined"!=typeof Symbol&&k(Symbol)&&"undefined"!=typeof Reflect&&k(Reflect.ownKeys),ro=function(){function e(){r=!1;var e=n.slice(0);n.length=0;for(var t=0;t1?v(n):n;for(var r=v(arguments,1),i=0,o=n.length;i1&&(t[n[0].trim()]=n[1].trim())}}),t}),ka=/^--/,Aa=/\s*!important$/,Oa=function(e,t,n){if(ka.test(t))e.style.setProperty(t,n);else if(Aa.test(n))e.style.setProperty(t,n.replace(Aa,""),"important");else{var r=Ta(t);if(Array.isArray(n))for(var i=0,o=n.length;iv?(f=e(i[g+1])?null:i[g+1].elm,y(n,f,i,d,g,o)):d>g&&b(n,r,p,v)}function w(r,i,o,a){if(r!==i){if(n(i.isStatic)&&n(r.isStatic)&&i.key===r.key&&(n(i.isCloned)||n(i.isOnce)))return i.elm=r.elm,void(i.componentInstance=r.componentInstance);var s,c=i.data;t(c)&&t(s=c.hook)&&t(s=s.prepatch)&&s(r,i);var u=i.elm=r.elm,l=r.children,f=i.children;if(t(c)&&h(i)){for(s=0;s',n.innerHTML.indexOf(t)>0}("\n"," "),ts=u("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),ns=u("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),rs=u("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),is=[/"([^"]*)"+/.source,/'([^']*)'+/.source,/([^\s"'=<>`]+)/.source],os=new RegExp("^\\s*"+/([^\s"'<>\/=]+)/.source+"(?:\\s*("+/(?:=)/.source+")\\s*(?:"+is.join("|")+"))?"),as="[a-zA-Z_][\\w\\-\\.]*",ss=new RegExp("^<((?:"+as+"\\:)?"+as+")"),cs=/^\s*(\/?)>/,us=new RegExp("^<\\/((?:"+as+"\\:)?"+as+")[^>]*>"),ls=/^]+>/i,fs=/^/g,"$1").replace(//g,"$1")),xs(p,n)&&(n=n.slice(1)),e.chars&&e.chars(n),""});l+=t.length-v.length,t=v,r(p,l-f,l)}else{xs(o,t)&&n(1);var h=t.indexOf("<");if(0===h){if(os.test(t)){var m=t.indexOf("--\x3e");if(m>=0){e.shouldKeepComment&&e.comment(t.substring(4,m)),n(m+3);continue}}if(as.test(t)){var y=t.indexOf("]>");if(y>=0){n(y+2);continue}}var g=t.match(is);if(g){n(g[0].length);continue}var _=t.match(rs);if(_){var b=l;n(_[0].length),r(_[1],b,l);continue}var $=function(){var e=t.match(es);if(e){var r={tagName:e[1],attrs:[],start:l};n(e[0].length);for(var i,o;!(i=t.match(ns))&&(o=t.match(Qa));)n(o[0].length),r.attrs.push(o);if(i)return r.unarySlash=i[1],n(i[0].length),r.end=l,r}}();if($){!function(t){var n=t.tagName,i=t.unarySlash;s&&("p"===o&&Ja(n)&&r(o),u(n)&&o===n&&r(n));for(var l=c(n)||!!i,f=t.attrs.length,p=new Array(f),d=0;d=0){for(w=t.slice(h);!(rs.test(w)||es.test(w)||os.test(w)||as.test(w)||(x=w.indexOf("<",1))<0);)h+=x,w=t.slice(h);C=t.substring(0,h),n(h)}h<0&&(C=t,t=""),e.chars&&C&&e.chars(C)}if(t===i){e.chars&&e.chars(t);break}}r()}function pr(t,e){function n(t){t.pre&&(s=!1),ds(t.tag)&&(c=!1)}cs=e.warn||Xe,ds=e.isPreTag||Ci,vs=e.mustUseProp||Ci,hs=e.getTagNamespace||Ci,ls=tn(e.modules,"transformNode"),fs=tn(e.modules,"preTransformNode"),ps=tn(e.modules,"postTransformNode"),us=e.delimiters;var r,i,o=[],a=!1!==e.preserveWhitespace,s=!1,c=!1;return fr(t,{warn:cs,expectHTML:e.expectHTML,isUnaryTag:e.isUnaryTag,canBeLeftOpenTag:e.canBeLeftOpenTag,shouldDecodeNewlines:e.shouldDecodeNewlines,shouldKeepComment:e.comments,start:function(t,a,u){function l(t){}var f=i&&i.ns||hs(t);Ii&&"svg"===f&&(a=jr(a));var p={type:1,tag:t,attrsList:a,attrsMap:Sr(a),parent:i,children:[]};f&&(p.ns=f),Er(p)&&!Ki()&&(p.forbidden=!0);for(var d=0;d0,Di=Li&&Li.indexOf("edge/")>0,Pi=Li&&Li.indexOf("android")>0,Fi=Li&&/iphone|ipad|ipod|ios/.test(Li),Ri=Li&&/chrome\/\d+/.test(Li)&&!Di,Hi={}.watch,Bi=!1;if(Ni)try{var Ui={};Object.defineProperty(Ui,"passive",{get:function(){Bi=!0}}),window.addEventListener("test-passive",null,Ui)}catch(t){}var Vi,zi,Ki=function(){return void 0===Vi&&(Vi=!Ni&&"undefined"!=typeof global&&"server"===global.process.env.VUE_ENV),Vi},Ji=Ni&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,qi="undefined"!=typeof Symbol&&O(Symbol)&&"undefined"!=typeof Reflect&&O(Reflect.ownKeys),Wi=function(){function t(){r=!1;var t=n.slice(0);n.length=0;for(var e=0;e1?m(n):n;for(var r=m(arguments,1),i=0,o=n.length;i1&&(e[n[0].trim()]=n[1].trim())}}),e}),va=/^--/,ha=/\s*!important$/,ma=function(t,e,n){if(va.test(e))t.style.setProperty(e,n);else if(ha.test(n))t.style.setProperty(e,n.replace(ha,""),"important");else{var r=ga(e);if(Array.isArray(n))for(var i=0,o=n.length;id?g(n,t(i[m+1])?null:i[m+1].elm,i,p,m,o):p>m&&b(n,r,f,d)}function w(r,i,o,a){if(r!==i){var s=i.elm=r.elm;if(n(r.isAsyncPlaceholder))e(i.asyncFactory.resolved)?A(r.elm,i,o):i.isAsyncPlaceholder=!0;else if(n(i.isStatic)&&n(r.isStatic)&&i.key===r.key&&(n(i.isCloned)||n(i.isOnce)))i.componentInstance=r.componentInstance;else{var c,u=i.data;e(u)&&e(c=u.hook)&&e(c=c.prepatch)&&c(r,i);var l=r.children,f=i.children;if(e(u)&&h(i)){for(c=0;c-1?Qo[t]=e.constructor===window.HTMLUnknownElement||e.constructor===window.HTMLElement:Qo[t]=/HTMLUnknownElement/.test(e.toString())},y(_e.options.directives,Na),y(_e.options.components,Da),_e.prototype.__patch__=Ni?Ea:_,_e.prototype.$mount=function(t,e){return t=t&&Ni?Fe(t):void 0,bt(this,t,e)},setTimeout(function(){Oi.devtools&&Ji&&Ji.emit("init",_e)},0);var Pa,Fa=!!Ni&&function(t,e){var n=document.createElement("div");return n.innerHTML='
',n.innerHTML.indexOf(e)>0}("\n"," "),Ra=/\{\{((?:.|\n)+?)\}\}/g,Ha=/[-.*+?^${}()|[\]\/\\]/g,Ba=v(function(t){var e=t[0].replace(Ha,"\\$&"),n=t[1].replace(Ha,"\\$&");return new RegExp(e+"((?:.|\\n)+?)"+n,"g")}),Ua=[{staticKeys:["staticClass"],transformNode:function(t,e){e.warn;var n=sn(t,"class");n&&(t.staticClass=JSON.stringify(n));var r=an(t,"class",!1);r&&(t.classBinding=r)},genData:function(t){var e="";return t.staticClass&&(e+="staticClass:"+t.staticClass+","),t.classBinding&&(e+="class:"+t.classBinding+","),e}},{staticKeys:["staticStyle"],transformNode:function(t,e){e.warn;var n=sn(t,"style");n&&(t.staticStyle=JSON.stringify(da(n)));var r=an(t,"style",!1);r&&(t.styleBinding=r)},genData:function(t){var e="";return t.staticStyle&&(e+="staticStyle:"+t.staticStyle+","),t.styleBinding&&(e+="style:("+t.styleBinding+"),"),e}}],Va={model:function(t,e,n){Do=n;var r=e.value,i=e.modifiers,o=t.tag,a=t.attrsMap.type;if(t.component)return cn(t,r,i),!1;if("select"===o)gn(t,r,i);else if("input"===o&&"checkbox"===a)mn(t,r,i);else if("input"===o&&"radio"===a)yn(t,r,i);else if("input"===o||"textarea"===o)_n(t,r,i);else if(!Oi.isReservedTag(o))return cn(t,r,i),!1;return!0},text:function(t,e){e.value&&en(t,"textContent","_s("+e.value+")")},html:function(t,e){e.value&&en(t,"innerHTML","_s("+e.value+")")}},za=f("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),Ka=f("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),Ja=f("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),qa={expectHTML:!0,modules:Ua,directives:Va,isPreTag:function(t){return"pre"===t},isUnaryTag:za,mustUseProp:Bo,canBeLeftOpenTag:Ka,isReservedTag:Yo,getTagNamespace:Pe,staticKeys:function(t){return t.reduce(function(t,e){return t.concat(e.staticKeys||[])},[]).join(",")}(Ua)},Wa={decode:function(t){return Pa=Pa||document.createElement("div"),Pa.innerHTML=t,Pa.textContent}},Ga=/([^\s"'<>/=]+)/,Za=/(?:=)/,Ya=[/"([^"]*)"+/.source,/'([^']*)'+/.source,/([^\s"'=<>`]+)/.source],Qa=new RegExp("^\\s*"+Ga.source+"(?:\\s*("+Za.source+")\\s*(?:"+Ya.join("|")+"))?"),Xa="[a-zA-Z_][\\w\\-\\.]*",ts="((?:"+Xa+"\\:)?"+Xa+")",es=new RegExp("^<"+ts),ns=/^\s*(\/?)>/,rs=new RegExp("^<\\/"+ts+"[^>]*>"),is=/^]+>/i,os=/^ @@ -270,7 +270,7 @@ For example: ### Mouse Button Modifiers -> New in 2.2.0 +> New in 2.2.0+ - `.left` - `.right` diff --git a/src/v2/guide/render-function.md b/src/v2/guide/render-function.md index af637da36b..5bd2ce9d3f 100644 --- a/src/v2/guide/render-function.md +++ b/src/v2/guide/render-function.md @@ -468,7 +468,7 @@ Vue.component('my-component', { }) ``` -> Note: in versions <=2.3.0, the `props` option is required if you wish to accept props in a functional component. In 2.3.0+ you can omit the `props` option and all attributes found on the component node will be implicitly extracted as props. +> Note: in versions before 2.3.0, the `props` option is required if you wish to accept props in a functional component. In 2.3.0+ you can omit the `props` option and all attributes found on the component node will be implicitly extracted as props. Everything the component needs is passed through `context`, which is an object containing: diff --git a/src/v2/guide/syntax.md b/src/v2/guide/syntax.md index 7a3e515b36..bb8bbe89c6 100644 --- a/src/v2/guide/syntax.md +++ b/src/v2/guide/syntax.md @@ -130,7 +130,7 @@ Vue.js allows you to define filters that can be used to apply common text format
``` -

Vue 2.x filters can only be used inside mustache interpolations and `v-bind` expressions (the latter supported since 2.1.0), because filters are primarily designed for text transformation purposes. For more complex data transforms in other directives, you should use [Computed properties](computed.html) instead.

+

Vue 2.x filters can only be used inside mustache interpolations and `v-bind` expressions (the latter supported in 2.1.0+), because filters are primarily designed for text transformation purposes. For more complex data transforms in other directives, you should use [Computed properties](computed.html) instead.

The filter function always receives the expression's value as the first argument. diff --git a/src/v2/guide/transitions.md b/src/v2/guide/transitions.md index 2573fe3f98..a74e3080b5 100644 --- a/src/v2/guide/transitions.md +++ b/src/v2/guide/transitions.md @@ -50,7 +50,7 @@ new Vue({ .fade-enter-active, .fade-leave-active { transition: opacity .5s } -.fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ { +.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ { opacity: 0 } ``` @@ -98,13 +98,13 @@ There are six classes applied for enter/leave transitions. 2. `v-enter-active`: Active state for enter. Applied during the entire entering phase. Added before element is inserted, removed when transition/animation finishes. This class can be used to define the duration, delay and easing curve for the entering transition. -3. `v-enter-to`: **Only available in versions >=2.1.8.** Ending state for enter. Added one frame after element is inserted (at the same time `v-enter` is removed), removed when transition/animation finishes. +3. `v-enter-to`: **Only available in versions 2.1.8+.** Ending state for enter. Added one frame after element is inserted (at the same time `v-enter` is removed), removed when transition/animation finishes. 4. `v-leave`: Starting state for leave. Added immediately when a leaving transition is triggered, removed after one frame. 5. `v-leave-active`: Active state for leave. Applied during the entire leaving phase. Added immediately when leave transition is triggered, removed when the transition/animation finishes. This class can be used to define the duration, delay and easing curve for the leaving transition. -6. `v-leave-to`: **Only available in versions >=2.1.8.** Ending state for leave. Added one frame after a leaving transition is triggered (at the same time `v-leave` is removed), removed when the transition/animation finishes. +6. `v-leave-to`: **Only available in versions 2.1.8+.** Ending state for leave. Added one frame after a leaving transition is triggered (at the same time `v-leave` is removed), removed when the transition/animation finishes. ![Transition Diagram](/images/transition.png) @@ -146,7 +146,7 @@ new Vue({ transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0); } .slide-fade-enter, .slide-fade-leave-to -/* .slide-fade-leave-active for <2.1.8 */ { +/* .slide-fade-leave-active below version 2.1.8 */ { transform: translateX(10px); opacity: 0; } @@ -289,10 +289,10 @@ You can also specify custom transition classes by providing the following attrib - `enter-class` - `enter-active-class` -- `enter-to-class` (>= 2.1.8 only) +- `enter-to-class` (2.1.8+) - `leave-class` - `leave-active-class` -- `leave-to-class` (>= 2.1.8 only) +- `leave-to-class` (2.1.8+) These will override the conventional class names. This is especially useful when you want to combine Vue's transition system with an existing CSS animation library, such as [Animate.css](https://daneden.github.io/animate.css/). @@ -356,7 +356,7 @@ However, in some cases you may want to have both on the same element, for exampl ### Explicit Transition Durations -> New in 2.2.0 +> New in 2.2.0+ In most cases, Vue can automatically figure out when the transition has finished. By default, Vue waits for the first `transitionend` or `animationend` event on the root transition element. However, this may not always be desired - for example, we may have a choreographed transition sequence where some nested inner elements have a delayed transition or a longer transition duration than the root transition element. @@ -560,7 +560,7 @@ By default, this will use the transitions specified for entering and leaving. If = 2.1.8 only) + appear-to-class="custom-appear-to-class" (2.1.8+) appear-active-class="custom-appear-active-class" > @@ -906,7 +906,7 @@ new Vue({ transition: opacity .3s ease; } .component-fade-enter, .component-fade-leave-to -/* .component-fade-leave-active for <2.1.8 */ { +/* .component-fade-leave-active below version 2.1.8 */ { opacity: 0; } ``` @@ -1002,7 +1002,7 @@ new Vue({ .list-enter-active, .list-leave-active { transition: all 1s; } -.list-enter, .list-leave-to /* .list-leave-active for <2.1.8 */ { +.list-enter, .list-leave-to /* .list-leave-active below version 2.1.8 */ { opacity: 0; transform: translateY(30px); } @@ -1178,7 +1178,7 @@ new Vue({ margin-right: 10px; } .list-complete-enter, .list-complete-leave-to -/* .list-complete-leave-active for <2.1.8 */ { +/* .list-complete-leave-active below version 2.1.8 */ { opacity: 0; transform: translateY(30px); } diff --git a/src/v2/guide/typescript.md b/src/v2/guide/typescript.md index 7e0d378353..4dd07c5486 100644 --- a/src/v2/guide/typescript.md +++ b/src/v2/guide/typescript.md @@ -4,9 +4,9 @@ type: guide order: 25 --- -## Important 2.2 Change Notice for TS + webpack 2 users +## Important 2.2.0+ Change Notice for TS + webpack 2 users -In Vue 2.2 we introduced dist files exposed as ES modules, which will be used by default by webpack 2. Unfortunately, this introduced an unintentional breaking change because with TypeScript + webpack 2, `import Vue = require('vue')` will now return a synthetic ES module object instead of Vue itself. +In Vue 2.2.0+ we introduced dist files exposed as ES modules, which will be used by default by webpack 2. Unfortunately, this introduced an unintentional breaking change because with TypeScript + webpack 2, `import Vue = require('vue')` will now return a synthetic ES module object instead of Vue itself. We plan to move all official declarations to use ES-style exports in the future. Please see [Recommended Configuration](#Recommended-Configuration) below on a future-proof setup. From 844cb43cf7cc1eaba6a13c76851fb213c2ecb4cf Mon Sep 17 00:00:00 2001 From: Alexander Sokolov Date: Fri, 21 Jul 2017 01:17:17 +0300 Subject: [PATCH 0024/1224] Update index.md (#1036) --- src/v2/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index ac10d7249c..8892dc6e8b 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -705,7 +705,7 @@ if (version === 2) { ## Options / Lifecycle Hooks -All lifecycle hooks automatically have their `this` context bound to the instance, so that you can access data, computed properties, and methods. This means __you should not use an arrow function to define a lifecycle method__ (e.g. `created: () => this.fetchTodos()`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.fetchTodos` will be undefined. +

All lifecycle hooks automatically have their `this` context bound to the instance, so that you can access data, computed properties, and methods. This means __you should not use an arrow function to define a lifecycle method__ (e.g. `created: () => this.fetchTodos()`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.fetchTodos` will be undefined.

### beforeCreate From f5b6092b7b952575a316a2a1c8c5b58b62c9fb0b Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 21 Jul 2017 00:04:26 -0400 Subject: [PATCH 0025/1224] clarify that comments option is only available for in-browser compilation --- src/v2/api/index.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index 8892dc6e8b..3df8926285 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -1031,9 +1031,11 @@ if (version === 2) { - **Default:** `{% raw %}["{{", "}}"]{% endraw %}` +- **Restrictions:** This option is only available in the full build, with in-browser compilation. + - **Details:** - Change the plain text interpolation delimiters. **This option is only available in the full build.** + Change the plain text interpolation delimiters. - **Example:** @@ -1120,6 +1122,8 @@ if (version === 2) { - **Default:** `false` +- **Restrictions:** This option is only available in the full build, with in-browser compilation. + - **Details:** When set to `true`, will preserve and render HTML comments found in templates. The default behavior is discarding them. From b359d4e3368555635447aa6696bde78a0006f4f7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 21 Jul 2017 00:07:05 -0400 Subject: [PATCH 0026/1224] make inheritAttrs and $attrs exception for class and style more prominent --- src/v2/api/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index 3df8926285..de6f0051c9 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -1114,6 +1114,8 @@ if (version === 2) { By default, parent scope attribute bindings that are not recognized as props will "fallthrough" and be applied to the root element of the child component as normal HTML attributes. When authoring a component that wraps a target element or another component, this may not always be the desired behavior. By setting `inheritAttrs` to `false`, this default behavior can be disabled. The attributes are available via the `$attrs` instance property (also new in 2.4) and can be explicitly bound to a non-root element using `v-bind`. + Note: this option does **not** affect `class` and `style` bindings. + ### comments > New in 2.4.0+ @@ -1312,7 +1314,7 @@ if (version === 2) { - **Details:** - Contains parent-scope attribute bindings that are not recognized (and extracted) as props. When a component doesn't have any declared props, this essentially contains all parent-scope bindings except for `class` and `style`, and can be passed down to an inner component via `v-bind="$attrs"` - useful when creating higher-order components. + Contains parent-scope attribute bindings (except for `class` and `style`) that are not recognized (and extracted) as props. When a component doesn't have any declared props, this essentially contains all parent-scope bindings (except for `class` and `style`), and can be passed down to an inner component via `v-bind="$attrs"` - useful when creating higher-order components. ### vm.$listeners From 24877c92fdc1baa880e21987b823e3ce53092e9c Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Thu, 20 Jul 2017 18:38:13 -0400 Subject: [PATCH 0027/1224] add github for gebilaoxiong --- src/v2/guide/team.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/v2/guide/team.md b/src/v2/guide/team.md index 1137bf3d16..4beb65dcc4 100644 --- a/src/v2/guide/team.md +++ b/src/v2/guide/team.md @@ -526,6 +526,7 @@ order: 31 title: 'Issue Annihilator', city: 'Chongqing, China', languages: ['zh', 'en'], + github: 'gebilaoxiong', work: { org: 'zbj.com', orgUrl: 'http://www.zbj.com/' From 8c328dad6a8c247e5b9fc693a5f24be499d29ea0 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Fri, 21 Jul 2017 11:46:33 -0400 Subject: [PATCH 0028/1224] add atomaka to team page --- src/v2/guide/team.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/v2/guide/team.md b/src/v2/guide/team.md index 4beb65dcc4..5171eda0a9 100644 --- a/src/v2/guide/team.md +++ b/src/v2/guide/team.md @@ -200,6 +200,7 @@ order: 31 'Chongqing, China': [29.431586, 106.912251], 'Denver, CO, USA': [39.739236, -104.990251], 'Dubna, Russia': [56.732020, 37.166897], + 'East Lansing, MI, USA': [42.736979, -84.483865], 'Hangzhou, China': [30.274084, 120.155070], 'Jersey City, NJ, USA': [40.728157, -74.558716], 'Kingston, Jamaica': [18.017874, -76.809904], @@ -534,6 +535,24 @@ order: 31 reposOfficial: [ 'vue' ] + }, + { + name: 'Andrew Tomaka', + title: 'The Server Server', + city: 'East Lansing, MI, USA', + languages: ['en'], + github: 'atomaka', + twitter: 'atomaka', + reposOfficial: [ + 'vuejs/*' + ], + work: { + org: 'Michigan State University', + orgUrl: 'https://msu.edu/' + }, + links: [ + 'https://atomaka.com/' + ] } ])) From 330267d477a56e640b5cb2e2e9d04aa810442445 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Mon, 24 Jul 2017 02:16:43 -0400 Subject: [PATCH 0029/1224] default to english when extrapolating user language on team page --- src/v2/guide/team.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/v2/guide/team.md b/src/v2/guide/team.md index 5171eda0a9..8e606d42c8 100644 --- a/src/v2/guide/team.md +++ b/src/v2/guide/team.md @@ -864,7 +864,9 @@ order: 31 // The system language in IE nav.userLanguage || // The language in the current page - nav.language + nav.language || + // Default to English if none found + 'en' ) return ( '
  • ' + From b1afd5dfc69ef3edc7ae2c39a4ba6b1658b94ab1 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Mon, 24 Jul 2017 02:27:42 -0400 Subject: [PATCH 0030/1224] check if preferred language exists on team page --- src/v2/guide/team.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/v2/guide/team.md b/src/v2/guide/team.md index 8e606d42c8..3c6942dcde 100644 --- a/src/v2/guide/team.md +++ b/src/v2/guide/team.md @@ -864,9 +864,7 @@ order: 31 // The system language in IE nav.userLanguage || // The language in the current page - nav.language || - // Default to English if none found - 'en' + nav.language ) return ( '
    • ' + @@ -874,6 +872,7 @@ order: 31 var language = languageNameFor[languageCode] if ( languageCode !== 'en' && + preferredLanguageCode && languageCode === preferredLanguageCode.slice(0, 2) ) { return ( From a6fd29e615fbc6dd73e336544083f32a93f44b21 Mon Sep 17 00:00:00 2001 From: lizhihua <275091674@qq.com> Date: Tue, 25 Jul 2017 03:33:51 +0800 Subject: [PATCH 0031/1224] Update index.md (#1041) --- src/v2/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index de6f0051c9..bf437c24b0 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -673,7 +673,7 @@ if (version === 2) {

      The `render` function has priority over the render function compiled from `template` option or in-DOM HTML template of the mounting element which is specified by the `el` option.

      - **See also:** - - [Render Functions](../guide/render-function) + - [Render Functions](../guide/render-function.html) ### renderError From f654de4214310314c83e60728bcd6b0b87081c0d Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Mon, 24 Jul 2017 15:35:01 -0400 Subject: [PATCH 0032/1224] fix broken api link to render functions guide --- src/v2/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index bf437c24b0..fd37743dbd 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -701,7 +701,7 @@ if (version === 2) { ``` - **See also:** - - [Render Functions](../guide/render-function) + - [Render Functions](../guide/render-function.html) ## Options / Lifecycle Hooks From 5dce96603c8c415447af659b3824aa01a950e53a Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Mon, 24 Jul 2017 15:44:22 -0400 Subject: [PATCH 0033/1224] link translations to page corresponding to current, fixes #1037 --- themes/vue/layout/partials/language_dropdown.ejs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/themes/vue/layout/partials/language_dropdown.ejs b/themes/vue/layout/partials/language_dropdown.ejs index 94aa4f69a8..29674ffcc1 100644 --- a/themes/vue/layout/partials/language_dropdown.ejs +++ b/themes/vue/layout/partials/language_dropdown.ejs @@ -1,11 +1,11 @@
    • From d4d678f861565acad402ffc4d23df7f4273077e0 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Tue, 25 Jul 2017 11:59:54 -0400 Subject: [PATCH 0034/1224] Add "Bringing Designs to Life" section to state transitions guide (#1043) --- src/v2/guide/transitioning-state.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/v2/guide/transitioning-state.md b/src/v2/guide/transitioning-state.md index b15f872ac8..76cc29653c 100644 --- a/src/v2/guide/transitioning-state.md +++ b/src/v2/guide/transitioning-state.md @@ -140,11 +140,11 @@ new Vue({ requestAnimationFrame(animate) } } - + new TWEEN.Tween(this.tweenedColor) .to(this.color, 750) .start() - + animate() } }, @@ -216,11 +216,11 @@ new Vue({ requestAnimationFrame(animate) } } - + new TWEEN.Tween(this.tweenedColor) .to(this.color, 750) .start() - + animate() } }, @@ -442,14 +442,14 @@ Vue.component('animated-integer', { requestAnimationFrame(animate) } } - + new TWEEN.Tween({ tweeningValue: startValue }) .to({ tweeningValue: endValue }, 500) .onUpdate(function () { vm.tweeningValue = this.tweeningValue.toFixed(0) }) .start() - + animate() } } @@ -512,14 +512,14 @@ Vue.component('animated-integer', { requestAnimationFrame(animate) } } - + new TWEEN.Tween({ tweeningValue: startValue }) .to({ tweeningValue: endValue }, 500) .onUpdate(function () { vm.tweeningValue = this.tweeningValue.toFixed(0) }) .start() - + animate() } } @@ -540,3 +540,16 @@ new Vue({ {% endraw %} Within child components, we can use any combination of transition strategies that have been covered on this page, along with those offered by Vue's [built-in transition system](transitions.html). Together, there are very few limits to what can be accomplished. + +## Bringing Designs to Life + +To animate, by one definition, means to bring to life. Unfortunately, when designers create icons, logos, and mascots, they're usually delivered as images or static SVGs. So although GitHub's octocat, Twitter's bird, and many other logos resemble living creatures, they don't really seem alive. + +Vue can help. Since SVGs are just data, we only need examples of what these creatures look like when excited, thinking, or alarmed. Then Vue can help transition between these states, making your welcome pages, loading indicators, and notifications more emotionally compelling. + +Sarah Drasner demonstrates this in the demo below, using a combination of timed and interactivity-driven state changes: + +

      See the Pen Vue-controlled Wall-E by Sarah Drasner (@sdras) on CodePen.

      + + + From 9f4f756d98a7a482f4d323d551035230ef23a75f Mon Sep 17 00:00:00 2001 From: pashute Date: Tue, 25 Jul 2017 19:03:35 +0300 Subject: [PATCH 0035/1224] syntax.md - first argument in filter chaining (#1045) extended and clarified the explanation --- src/v2/guide/syntax.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/v2/guide/syntax.md b/src/v2/guide/syntax.md index bb8bbe89c6..bd007defb1 100644 --- a/src/v2/guide/syntax.md +++ b/src/v2/guide/syntax.md @@ -132,7 +132,7 @@ Vue.js allows you to define filters that can be used to apply common text format

      Vue 2.x filters can only be used inside mustache interpolations and `v-bind` expressions (the latter supported in 2.1.0+), because filters are primarily designed for text transformation purposes. For more complex data transforms in other directives, you should use [Computed properties](computed.html) instead.

      -The filter function always receives the expression's value as the first argument. +The filter function always receives the expression's value (the result of the former chain) as its first argument. In this example, the `capitalize` filter function will receive the value of `message` as its argument. ``` js new Vue({ @@ -153,13 +153,16 @@ Filters can be chained: {{ message | filterA | filterB }} ``` +In this case, `filterA`, defined with a single argument, will recieve the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument. + + Filters are JavaScript functions, therefore they can take arguments: ``` html {{ message | filterA('arg1', arg2) }} ``` -Here, the plain string `'arg1'` will be passed into the filter as the second argument, and the value of expression `arg2` will be evaluated and passed in as the third argument. +Here `filterA` is defined as a function taking three arguments. The value of message will be passed into the first argument. The plain string `'arg1'` will be passed into the `filterA` as its second argument, and the value of expression `arg2` will be evaluated and passed in as the third argument.   ## Shorthands From d7b1cc3631b1cea02da8ebfbc5f624b26d04939a Mon Sep 17 00:00:00 2001 From: katashin Date: Wed, 26 Jul 2017 01:11:47 +0900 Subject: [PATCH 0036/1224] add a guide how to declare plugin typings (#1042) * add a guide how to declare plugin typings * improve wording * Slight tweak to working for declaring typescript types for plugins --- src/v2/guide/typescript.md | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/v2/guide/typescript.md b/src/v2/guide/typescript.md index 4dd07c5486..b6179ef6c3 100644 --- a/src/v2/guide/typescript.md +++ b/src/v2/guide/typescript.md @@ -137,3 +137,63 @@ export default class MyComponent extends Vue { ``` With this syntax alternative, our component definition is not only shorter, but TypeScript can also infer the types of `message` and `onClick` without explicit interface declarations. This strategy even allows you to handle types for computed properties, lifecycle hooks, and render functions. For full usage details, see [the vue-class-component docs](https://github.com/vuejs/vue-class-component#vue-class-component). + +## Declaring Types of Vue Plugins + +Plugins may add to Vue's global/instance properties and component options. In these cases, type declarations are needed to make plugins compile in TypeScript. Fortunately, there's a TypeScript feature to augment existing types called [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation). + +For example, to declare an instance property `$myProperty` with type `string`: + +``` ts +// 1. Make sure to import 'vue' before declaring augmented types +import Vue from 'vue' + +// 2. Specify a file with the types you want to augment +// Vue has the constructor type in types/vue.d.ts +declare module 'vue/types/vue' { + // 3. Declare augmentation for Vue + interface Vue { + $myProperty: string + } +} +``` + +After including the above code as a declaration file (like `my-property.d.ts`) in your project, you can use `$myProperty` on a Vue instance. + +```ts +var vm = new Vue() +console.log(vm.$myProperty) // This will be successfully compiled +``` + +You can also declare additional global properties and component options: + +```ts +import Vue from 'vue' + +declare module 'vue/types/vue' { + // Global properties can be declared + // by using `namespace` instead of `interface` + namespace Vue { + const $myGlobal: string + } +} + +// ComponentOptions is declared in types/options.d.ts +declare module 'vue/types/options' { + interface ComponentOptions { + myOption?: string + } +} +``` + +The above declarations allow the following code to be compiled: + +```ts +// Global property +console.log(Vue.$myGlobal) + +// Additional component option +var vm = new Vue({ + myOption: 'Hello' +}) +``` From 9bd9e0eea3e46bd868f79f22ff30b04e62b2a459 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Tue, 25 Jul 2017 12:16:09 -0400 Subject: [PATCH 0037/1224] clarify directive updates, fixes #1044 --- src/v2/guide/custom-directive.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v2/guide/custom-directive.md b/src/v2/guide/custom-directive.md index c776331c6c..ab28646e5c 100644 --- a/src/v2/guide/custom-directive.md +++ b/src/v2/guide/custom-directive.md @@ -61,9 +61,9 @@ A directive definition object can provide several hook functions (all optional): - `inserted`: called when the bound element has been inserted into its parent node (this only guarantees parent node presence, not necessarily in-document). -- `update`: called after the containing component has updated, __but possibly before its children have updated__. The directive's value may or may not have changed, but you can skip unnecessary updates by comparing the binding's current and old values (see below on hook arguments). +- `update`: called after the containing component's VNode has updated, __but possibly before its children have updated__. The directive's value may or may not have changed, but you can skip unnecessary updates by comparing the binding's current and old values (see below on hook arguments). -- `componentUpdated`: called after the containing component __and its children__ have updated. +- `componentUpdated`: called after the containing component's VNode __and the VNodes of its children__ have updated. - `unbind`: called only once, when the directive is unbound from the element. From 4dd4a4a7451ff8ec3e030b94fa7a7fd8e89d2b90 Mon Sep 17 00:00:00 2001 From: Alexander Sokolov Date: Wed, 26 Jul 2017 19:19:48 +0300 Subject: [PATCH 0038/1224] Update syntax.md (#1048) * Update syntax.md * Update syntax.md --- src/v2/guide/syntax.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/v2/guide/syntax.md b/src/v2/guide/syntax.md index bd007defb1..e555533b4e 100644 --- a/src/v2/guide/syntax.md +++ b/src/v2/guide/syntax.md @@ -153,8 +153,7 @@ Filters can be chained: {{ message | filterA | filterB }} ``` -In this case, `filterA`, defined with a single argument, will recieve the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument. - +In this case, `filterA`, defined with a single argument, will recieve the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument. Filters are JavaScript functions, therefore they can take arguments: @@ -162,7 +161,7 @@ Filters are JavaScript functions, therefore they can take arguments: {{ message | filterA('arg1', arg2) }} ``` -Here `filterA` is defined as a function taking three arguments. The value of message will be passed into the first argument. The plain string `'arg1'` will be passed into the `filterA` as its second argument, and the value of expression `arg2` will be evaluated and passed in as the third argument.   +Here `filterA` is defined as a function taking three arguments. The value of `message` will be passed into the first argument. The plain string `'arg1'` will be passed into the `filterA` as its second argument, and the value of expression `arg2` will be evaluated and passed in as the third argument. ## Shorthands From 1d1e2a5e24478274bdd5697ac8f8084aa5b4d9d6 Mon Sep 17 00:00:00 2001 From: johncg182 Date: Sun, 30 Jul 2017 13:29:23 -0500 Subject: [PATCH 0039/1224] recieve spelling (#1050) recieve to receive --- src/v2/guide/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/guide/syntax.md b/src/v2/guide/syntax.md index e555533b4e..508f2bce2f 100644 --- a/src/v2/guide/syntax.md +++ b/src/v2/guide/syntax.md @@ -153,7 +153,7 @@ Filters can be chained: {{ message | filterA | filterB }} ``` -In this case, `filterA`, defined with a single argument, will recieve the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument. +In this case, `filterA`, defined with a single argument, will receive the value of `message`, and then the `filterB` function will be called with the result of `filterA` passed into `filterB`'s single argument. Filters are JavaScript functions, therefore they can take arguments: From c0fe2e29f06b16c8c4c8eef327d90aab76963dd7 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Sun, 30 Jul 2017 14:44:06 -0400 Subject: [PATCH 0040/1224] clarify naming in counter event components example, fixes #1051 --- src/v2/guide/components.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/v2/guide/components.md b/src/v2/guide/components.md index 74fc50f6db..25b5021b1c 100644 --- a/src/v2/guide/components.md +++ b/src/v2/guide/components.md @@ -501,14 +501,14 @@ Here's an example: ``` js Vue.component('button-counter', { - template: '', + template: '', data: function () { return { counter: 0 } }, methods: { - increment: function () { + incrementCounter: function () { this.counter += 1 this.$emit('increment') } @@ -536,14 +536,14 @@ new Vue({
-
+
Fade In: Fade Out:

hello

- + +
``` @@ -1543,7 +1550,7 @@ new Vue({ fadeInDuration: 1000, fadeOutDuration: 1000, maxFadeDuration: 1500, - stop: false + stop: true }, mounted: function () { this.show = false @@ -1595,7 +1602,14 @@ new Vue({ >

hello

- + +
From 89150cc47347ee5442b7b3ea98353834ca82099d Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Mon, 14 Aug 2017 15:38:09 +0200 Subject: [PATCH 0057/1224] [Doc EN]: API Consistency (#1078) * Set correct API link for FR documentation Signed-off-by: Bruno Lesieur * Line spacing consistency Signed-off-by: Bruno Lesieur * New API adding Signed-off-by: Bruno Lesieur --- src/v2/api/index.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index 19ace2c31f..70ddcf7919 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -97,7 +97,7 @@ type: api ``` js Vue.config.warnHandler = function (msg, vm, trace) { - // trace is the component hierarchy trace + // `trace` is the component hierarchy trace } ``` @@ -134,7 +134,7 @@ type: api // camelCase won`t work mediaPlayPause: 179, // instead you can use kebab-case with double quotation marks - "media-play-pause" : 179, + "media-play-pause": 179, up: [38, 87] } ``` @@ -143,7 +143,7 @@ type: api ``` - Define custom key alias(es) for v-on. + Define custom key alias(es) for `v-on`. ### performance @@ -913,7 +913,7 @@ if (version === 2) { ``` js var CompA = { ... } - // extend CompA without having to call Vue.extend on either + // extend CompA without having to call `Vue.extend` on either var CompB = { extends: CompA, ... @@ -1386,7 +1386,7 @@ if (version === 2) { vm.$watch('a', callback, { immediate: true }) - // callback is fired immediately with current value of `a` + // `callback` is fired immediately with current value of `a` ```

vm.$set( target, key, value )

@@ -1601,6 +1601,7 @@ if (version === 2) { ```html
``` + - **See also:** [Data Binding Syntax - Interpolations](../guide/syntax.html#Raw-HTML) ### v-show @@ -1811,7 +1812,6 @@ if (version === 2) { - **Modifiers:** - `.prop` - Bind as a DOM property instead of an attribute ([what's the difference?](http://stackoverflow.com/questions/6003819/properties-and-attributes-in-html#answer-6004028)). If the tag is a component then `.prop` will set the property on the component's `$el`. - - `.camel` - (2.1.0+) transform the kebab-case attribute name into camelCase. - `.sync` - (2.3.0+) a syntax sugar that expands into a `v-on` handler for updating the bound value. @@ -1954,7 +1954,7 @@ if (version === 2) {
- +
  • {{i}}
@@ -2039,8 +2039,8 @@ if (version === 2) { - - + +
@@ -2200,7 +2200,7 @@ if (version === 2) { - + @@ -2210,7 +2210,6 @@ if (version === 2) { Note, `` is designed for the case where it has one direct child component that is being toggled. It does not work if you have `v-for` inside it. When there are multiple conditional children, as above, `` requires that only one child is rendered at a time. - - **`include` and `exclude`** > New in 2.1.0+ @@ -2223,12 +2222,12 @@ if (version === 2) { - + - + From bb4e222ff9f4bdb3fae1f879f97c5802e9e6c172 Mon Sep 17 00:00:00 2001 From: Juan Eugenio Abadie Date: Tue, 15 Aug 2017 19:28:43 -0300 Subject: [PATCH 0058/1224] Missing letter (#1081) * Missing letter * Update separate to different for clarification --- src/v2/guide/components.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/guide/components.md b/src/v2/guide/components.md index cd0820ba65..4884a079c8 100644 --- a/src/v2/guide/components.md +++ b/src/v2/guide/components.md @@ -483,7 +483,7 @@ Every Vue instance implements an [events interface](../api/#Instance-Methods-Eve - Listen to an event using `$on(eventName)` - Trigger an event using `$emit(eventName)` -

Note that Vue's event system is separate from the browser's [EventTarget API](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). Though they work similarly, `$on` and `$emit` are __not__ aliases for `addEventListener` and `dispatchEvent`.

+

Note that Vue's event system is different from the browser's [EventTarget API](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). Though they work similarly, `$on` and `$emit` are __not__ aliases for `addEventListener` and `dispatchEvent`.

In addition, a parent component can listen to the events emitted from a child component using `v-on` directly in the template where the child component is used. From 878c9ab785adf8f98e251f4f2f5f2fff8fafe23b Mon Sep 17 00:00:00 2001 From: CHO Date: Wed, 16 Aug 2017 13:50:19 +0900 Subject: [PATCH 0059/1224] fix $off arguments description (#1083) add description about array since it is supported in v2.2.2+ accepted pull request: #5056 source code (v2.2.2); https://github.com/vuejs/vue/blob/v2.2.2/src/core/instance/events.js#L69 --- src/v2/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index 70ddcf7919..622b01122b 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -1451,7 +1451,7 @@ if (version === 2) {

vm.$off( [event, callback] )

- **Arguments:** - - `{string} [event]` + - `{string | Array} event` (array only supported in 2.2.2+) - `{Function} [callback]` - **Usage:** From da21c597f452c7b86f4828f0c42e68ffa59a65be Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Wed, 16 Aug 2017 09:38:59 -0400 Subject: [PATCH 0060/1224] update non-vue cdn links to jsdelivr --- src/v2/guide/comparison.md | 2 +- src/v2/guide/computed.md | 8 ++++---- src/v2/guide/installation.md | 2 +- src/v2/guide/transitioning-state.md | 16 ++++++++-------- src/v2/guide/transitions.md | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/v2/guide/comparison.md b/src/v2/guide/comparison.md index b3f5939385..5160c3f35a 100644 --- a/src/v2/guide/comparison.md +++ b/src/v2/guide/comparison.md @@ -111,7 +111,7 @@ React is renowned for its steep learning curve. Before you can really get starte While Vue scales up just as well as, if not better than React, it also scales down just as well as jQuery. That's right - all you have to do is drop a single script tag into a page: ``` html - + ``` Then you can start writing Vue code and even ship the minified version to production without feeling guilty or having to worry about performance problems. diff --git a/src/v2/guide/computed.md b/src/v2/guide/computed.md index 5d99cbc216..e65ddd82b3 100644 --- a/src/v2/guide/computed.md +++ b/src/v2/guide/computed.md @@ -202,8 +202,8 @@ For example: - - + + - + + +
@@ -57,7 +57,7 @@ new Vue({ ``` {% raw %} - +

{{ animatedNumber }}

@@ -96,8 +96,8 @@ new Vue({ When you update the number, the change is animated below the input. This makes for a nice demo, but what about something that isn't directly stored as a number, like any valid CSS color for example? Here's how we could accomplish this with the addition of [Color.js](https://github.com/brehaut/color-js): ``` html - - + +
- + +
+
+ @@ -471,7 +471,7 @@ new Vue({ ``` {% raw %} - +
+ = diff --git a/src/v2/guide/transitions.md b/src/v2/guide/transitions.md index fade5adca1..0801e3c26d 100644 --- a/src/v2/guide/transitions.md +++ b/src/v2/guide/transitions.md @@ -299,7 +299,7 @@ These will override the conventional class names. This is especially useful when Here's an example: ``` html - +