diff --git a/dist/vue.common.dev.js b/dist/vue.common.dev.js index 41f17e2f943..ca8e1e1ae3a 100644 --- a/dist/vue.common.dev.js +++ b/dist/vue.common.dev.js @@ -1,6 +1,6 @@ /*! - * Vue.js v2.6.12 - * (c) 2014-2020 Evan You + * Vue.js v2.6.13 + * (c) 2014-2021 Evan You * Released under the MIT License. */ 'use strict'; @@ -1700,13 +1700,14 @@ function assertProp ( type = [type]; } for (var i = 0; i < type.length && !valid; i++) { - var assertedType = assertType(value, type[i]); + var assertedType = assertType(value, type[i], vm); expectedTypes.push(assertedType.expectedType || ''); valid = assertedType.valid; } } - if (!valid) { + var haveExpectedTypes = expectedTypes.some(function (t) { return t; }); + if (!valid && haveExpectedTypes) { warn( getInvalidTypeMessage(name, value, expectedTypes), vm @@ -1724,9 +1725,9 @@ function assertProp ( } } -var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; +var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/; -function assertType (value, type) { +function assertType (value, type, vm) { var valid; var expectedType = getType(type); if (simpleCheckRE.test(expectedType)) { @@ -1741,7 +1742,12 @@ function assertType (value, type) { } else if (expectedType === 'Array') { valid = Array.isArray(value); } else { - valid = value instanceof type; + try { + valid = value instanceof type; + } catch (e) { + warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm); + valid = false; + } } return { valid: valid, @@ -1749,13 +1755,15 @@ function assertType (value, type) { } } +var functionTypeCheckRE = /^\s*function (\w+)/; + /** * Use function string name to check built-in types, * because a simple equality check will fail when running * across different vms / iframes. */ function getType (fn) { - var match = fn && fn.toString().match(/^\s*function (\w+)/); + var match = fn && fn.toString().match(functionTypeCheckRE); return match ? match[1] : '' } @@ -1780,18 +1788,19 @@ function getInvalidTypeMessage (name, value, expectedTypes) { " Expected " + (expectedTypes.map(capitalize).join(', ')); var expectedType = expectedTypes[0]; var receivedType = toRawType(value); - var expectedValue = styleValue(value, expectedType); - var receivedValue = styleValue(value, receivedType); // check if we need to specify expected value - if (expectedTypes.length === 1 && - isExplicable(expectedType) && - !isBoolean(expectedType, receivedType)) { - message += " with value " + expectedValue; + if ( + expectedTypes.length === 1 && + isExplicable(expectedType) && + isExplicable(typeof value) && + !isBoolean(expectedType, receivedType) + ) { + message += " with value " + (styleValue(value, expectedType)); } message += ", got " + receivedType + " "; // check if we need to specify received value if (isExplicable(receivedType)) { - message += "with value " + receivedValue + "."; + message += "with value " + (styleValue(value, receivedType)) + "."; } return message } @@ -1806,9 +1815,9 @@ function styleValue (value, type) { } } +var EXPLICABLE_TYPES = ['string', 'number', 'boolean']; function isExplicable (value) { - var explicitTypes = ['string', 'number', 'boolean']; - return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; }) + return EXPLICABLE_TYPES.some(function (elem) { return value.toLowerCase() === elem; }) } function isBoolean () { @@ -2035,7 +2044,7 @@ var initProxy; var allowedGlobals = makeMap( 'Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + - 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' + 'require' // for Webpack/Browserify ); @@ -2538,6 +2547,12 @@ function isWhitespace (node) { /* */ +function isAsyncPlaceholder (node) { + return node.isComment && node.asyncFactory +} + +/* */ + function normalizeScopedSlots ( slots, normalSlots, @@ -2594,9 +2609,10 @@ function normalizeScopedSlot(normalSlots, key, fn) { res = res && typeof res === 'object' && !Array.isArray(res) ? [res] // single vnode : normalizeChildren(res); + var vnode = res && res[0]; return res && ( - res.length === 0 || - (res.length === 1 && res[0].isComment) // #9658 + !vnode || + (vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391 ) ? undefined : res }; @@ -2669,26 +2685,28 @@ function renderList ( */ function renderSlot ( name, - fallback, + fallbackRender, props, bindObject ) { var scopedSlotFn = this.$scopedSlots[name]; var nodes; - if (scopedSlotFn) { // scoped slot + if (scopedSlotFn) { + // scoped slot props = props || {}; if (bindObject) { if (!isObject(bindObject)) { - warn( - 'slot v-bind without argument expects an Object', - this - ); + warn('slot v-bind without argument expects an Object', this); } props = extend(extend({}, bindObject), props); } - nodes = scopedSlotFn(props) || fallback; + nodes = + scopedSlotFn(props) || + (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender); } else { - nodes = this.$slots[name] || fallback; + nodes = + this.$slots[name] || + (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender); } var target = props && props.slot; @@ -2738,6 +2756,7 @@ function checkKeyCodes ( } else if (eventKeyName) { return hyphenate(eventKeyName) !== key } + return eventKeyCode === undefined } /* */ @@ -3269,8 +3288,10 @@ function createComponent ( } function createComponentInstanceForVnode ( - vnode, // we know it's MountedComponentVNode but flow doesn't - parent // activeInstance in lifecycle state + // we know it's MountedComponentVNode but flow doesn't + vnode, + // activeInstance in lifecycle state + parent ) { var options = { _isComponent: true, @@ -3409,7 +3430,7 @@ function _createElement ( ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag); if (config.isReservedTag(tag)) { // platform built-in elements - if (isDef(data) && isDef(data.nativeOn)) { + if (isDef(data) && isDef(data.nativeOn) && data.tag !== 'component') { warn( ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."), context @@ -3735,12 +3756,6 @@ function resolveAsyncComponent ( /* */ -function isAsyncPlaceholder (node) { - return node.isComment && node.asyncFactory -} - -/* */ - function getFirstComponentChild (children) { if (Array.isArray(children)) { for (var i = 0; i < children.length; i++) { @@ -4107,7 +4122,8 @@ function updateChildComponent ( var hasDynamicScopedSlot = !!( (newScopedSlots && !newScopedSlots.$stable) || (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) || - (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) + (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) || + (!newScopedSlots && vm.$scopedSlots.$key) ); // Any static slot children from the parent may have changed during parent's @@ -4559,11 +4575,8 @@ Watcher.prototype.run = function run () { var oldValue = this.value; this.value = value; if (this.user) { - try { - this.cb.call(this.vm, value, oldValue); - } catch (e) { - handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\"")); - } + var info = "callback for watcher \"" + (this.expression) + "\""; + invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info); } else { this.cb.call(this.vm, value, oldValue); } @@ -4785,6 +4798,8 @@ function initComputed (vm, computed) { warn(("The computed property \"" + key + "\" is already defined in data."), vm); } else if (vm.$options.props && key in vm.$options.props) { warn(("The computed property \"" + key + "\" is already defined as a prop."), vm); + } else if (vm.$options.methods && key in vm.$options.methods) { + warn(("The computed property \"" + key + "\" is already defined as a method."), vm); } } } @@ -4937,11 +4952,10 @@ function stateMixin (Vue) { options.user = true; var watcher = new Watcher(vm, expOrFn, cb, options); if (options.immediate) { - try { - cb.call(vm, watcher.value); - } catch (error) { - handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\"")); - } + var info = "callback for immediate watcher \"" + (watcher.expression) + "\""; + pushTarget(); + invokeWithErrorHandling(cb, vm, [watcher.value], vm, info); + popTarget(); } return function unwatchFn () { watcher.teardown(); @@ -5239,6 +5253,8 @@ function initAssetRegisters (Vue) { + + function getComponentName (opts) { return opts && (opts.Ctor.options.name || opts.tag) } @@ -5260,9 +5276,9 @@ function pruneCache (keepAliveInstance, filter) { var keys = keepAliveInstance.keys; var _vnode = keepAliveInstance._vnode; for (var key in cache) { - var cachedNode = cache[key]; - if (cachedNode) { - var name = getComponentName(cachedNode.componentOptions); + var entry = cache[key]; + if (entry) { + var name = entry.name; if (name && !filter(name)) { pruneCacheEntry(cache, key, keys, _vnode); } @@ -5276,9 +5292,9 @@ function pruneCacheEntry ( keys, current ) { - var cached$$1 = cache[key]; - if (cached$$1 && (!current || cached$$1.tag !== current.tag)) { - cached$$1.componentInstance.$destroy(); + var entry = cache[key]; + if (entry && (!current || entry.tag !== current.tag)) { + entry.componentInstance.$destroy(); } cache[key] = null; remove(keys, key); @@ -5296,6 +5312,32 @@ var KeepAlive = { max: [String, Number] }, + methods: { + cacheVNode: function cacheVNode() { + var ref = this; + var cache = ref.cache; + var keys = ref.keys; + var vnodeToCache = ref.vnodeToCache; + var keyToCache = ref.keyToCache; + if (vnodeToCache) { + var tag = vnodeToCache.tag; + var componentInstance = vnodeToCache.componentInstance; + var componentOptions = vnodeToCache.componentOptions; + cache[keyToCache] = { + name: getComponentName(componentOptions), + tag: tag, + componentInstance: componentInstance, + }; + keys.push(keyToCache); + // prune oldest entry + if (this.max && keys.length > parseInt(this.max)) { + pruneCacheEntry(cache, keys[0], keys, this._vnode); + } + this.vnodeToCache = null; + } + } + }, + created: function created () { this.cache = Object.create(null); this.keys = []; @@ -5310,6 +5352,7 @@ var KeepAlive = { mounted: function mounted () { var this$1 = this; + this.cacheVNode(); this.$watch('include', function (val) { pruneCache(this$1, function (name) { return matches(val, name); }); }); @@ -5318,6 +5361,10 @@ var KeepAlive = { }); }, + updated: function updated () { + this.cacheVNode(); + }, + render: function render () { var slot = this.$slots.default; var vnode = getFirstComponentChild(slot); @@ -5351,12 +5398,9 @@ var KeepAlive = { remove(keys, key); keys.push(key); } else { - cache[key] = vnode; - keys.push(key); - // prune oldest entry - if (this.max && keys.length > parseInt(this.max)) { - pruneCacheEntry(cache, keys[0], keys, this._vnode); - } + // delay setting the cache until update + this.vnodeToCache = vnode; + this.keyToCache = key; } vnode.data.keepAlive = true; @@ -5439,7 +5483,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', { value: FunctionalRenderContext }); -Vue.version = '2.6.12'; +Vue.version = '2.6.13'; /* */ @@ -5476,7 +5520,7 @@ var isBooleanAttr = makeMap( 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + - 'required,reversed,scoped,seamless,selected,sortable,translate,' + + 'required,reversed,scoped,seamless,selected,sortable,' + 'truespeed,typemustmatch,visible' ); @@ -5600,7 +5644,7 @@ var isHTMLTag = makeMap( // contain child elements. var isSVG = makeMap( 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + - 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + + 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true ); @@ -5805,7 +5849,8 @@ var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; function sameVnode (a, b) { return ( - a.key === b.key && ( + a.key === b.key && + a.asyncFactory === b.asyncFactory && ( ( a.tag === b.tag && a.isComment === b.isComment && @@ -5813,7 +5858,6 @@ function sameVnode (a, b) { sameInputType(a, b) ) || ( isTrue(a.isAsyncPlaceholder) && - a.asyncFactory === b.asyncFactory && isUndef(b.asyncFactory.error) ) ) @@ -6701,7 +6745,7 @@ function updateAttrs (oldVnode, vnode) { cur = attrs[key]; old = oldAttrs[key]; if (old !== cur) { - setAttr(elm, key, cur); + setAttr(elm, key, cur, vnode.data.pre); } } // #4391: in IE9, setting type can reset value for input[type=radio] @@ -6721,8 +6765,8 @@ function updateAttrs (oldVnode, vnode) { } } -function setAttr (el, key, value) { - if (el.tagName.indexOf('-') > -1) { +function setAttr (el, key, value, isInPre) { + if (isInPre || el.tagName.indexOf('-') > -1) { baseSetAttr(el, key, value); } else if (isBooleanAttr(key)) { // set attribute for blank value @@ -9243,7 +9287,7 @@ var isNonPhrasingTag = makeMap( // Regular Expressions for parsing tags and attributes var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; -var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; +var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*"; var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")"; var startTagOpen = new RegExp(("^<" + qnameCapture)); @@ -9548,7 +9592,7 @@ var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g; var slotRE = /^v-slot(:|$)|^#/; var lineBreakRE = /[\r\n]/; -var whitespaceRE$1 = /\s+/g; +var whitespaceRE$1 = /[ \f\t\r\n]+/g; var invalidAttributeRE = /[\s"'<>\/=]/; @@ -9596,8 +9640,12 @@ function parse ( platformMustUseProp = options.mustUseProp || no; platformGetTagNamespace = options.getTagNamespace || no; var isReservedTag = options.isReservedTag || no; - maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); }; - + maybeComponent = function (el) { return !!( + el.component || + el.attrsMap[':is'] || + el.attrsMap['v-bind:is'] || + !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)) + ); }; transforms = pluckModuleFunction(options.modules, 'transformNode'); preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); @@ -10846,9 +10894,9 @@ function genHandler (handler) { code += genModifierCode; } var handlerCode = isMethodPath - ? ("return " + (handler.value) + "($event)") + ? ("return " + (handler.value) + ".apply(null, arguments)") : isFunctionExpression - ? ("return (" + (handler.value) + ")($event)") + ? ("return (" + (handler.value) + ").apply(null, arguments)") : isFunctionInvocation ? ("return " + (handler.value)) : handler.value; @@ -10934,7 +10982,8 @@ function generate ( options ) { var state = new CodegenState(options); - var code = ast ? genElement(ast, state) : '_c("div")'; + // fix #11483, Root level