diff --git a/js/vue.js b/js/vue.js index e22cf13..d800532 100644 --- a/js/vue.js +++ b/js/vue.js @@ -1,6 +1,6 @@ /*! - * Vue.js v2.6.11 - * (c) 2014-2019 Evan You + * Vue.js v2.6.14 + * (c) 2014-2021 Evan You * Released under the MIT License. */ (function (global, factory) { @@ -1704,13 +1704,14 @@ 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 @@ -1728,9 +1729,9 @@ } } - 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)) { @@ -1745,7 +1746,12 @@ } 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, @@ -1753,13 +1759,15 @@ } } + 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] : '' } @@ -1784,18 +1792,19 @@ " 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 } @@ -1810,9 +1819,9 @@ } } + 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 () { @@ -2039,7 +2048,7 @@ 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 ); @@ -2542,6 +2551,12 @@ /* */ + function isAsyncPlaceholder (node) { + return node.isComment && node.asyncFactory + } + + /* */ + function normalizeScopedSlots ( slots, normalSlots, @@ -2598,9 +2613,10 @@ 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 || + (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391 ) ? undefined : res }; @@ -2673,26 +2689,28 @@ */ 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; @@ -2742,6 +2760,7 @@ } else if (eventKeyName) { return hyphenate(eventKeyName) !== key } + return eventKeyCode === undefined } /* */ @@ -3273,8 +3292,10 @@ } 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, @@ -3413,7 +3434,7 @@ 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 @@ -3739,12 +3760,6 @@ /* */ - function isAsyncPlaceholder (node) { - return node.isComment && node.asyncFactory - } - - /* */ - function getFirstComponentChild (children) { if (Array.isArray(children)) { for (var i = 0; i < children.length; i++) { @@ -4111,7 +4126,8 @@ 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 @@ -4563,11 +4579,8 @@ 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); } @@ -4789,6 +4802,8 @@ 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); } } } @@ -4941,11 +4956,10 @@ 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(); @@ -5243,6 +5257,8 @@ + + function getComponentName (opts) { return opts && (opts.Ctor.options.name || opts.tag) } @@ -5264,9 +5280,9 @@ 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); } @@ -5280,9 +5296,9 @@ 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); @@ -5300,6 +5316,32 @@ 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 = []; @@ -5314,6 +5356,7 @@ mounted: function mounted () { var this$1 = this; + this.cacheVNode(); this.$watch('include', function (val) { pruneCache(this$1, function (name) { return matches(val, name); }); }); @@ -5322,6 +5365,10 @@ }); }, + updated: function updated () { + this.cacheVNode(); + }, + render: function render () { var slot = this.$slots.default; var vnode = getFirstComponentChild(slot); @@ -5355,12 +5402,9 @@ 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; @@ -5443,7 +5487,7 @@ value: FunctionalRenderContext }); - Vue.version = '2.6.11'; + Vue.version = '2.6.14'; /* */ @@ -5480,7 +5524,7 @@ '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' ); @@ -5604,7 +5648,7 @@ // 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 ); @@ -5809,7 +5853,8 @@ 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 && @@ -5817,7 +5862,6 @@ sameInputType(a, b) ) || ( isTrue(a.isAsyncPlaceholder) && - a.asyncFactory === b.asyncFactory && isUndef(b.asyncFactory.error) ) ) @@ -6705,7 +6749,7 @@ 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] @@ -6725,8 +6769,8 @@ } } - 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 @@ -7649,7 +7693,7 @@ // skip the update if old and new VDOM state is the same. // `value` is handled separately because the DOM value may be temporarily // out of sync with VDOM state due to focus, composition and modifiers. - // This #4521 by skipping the unnecesarry `checked` update. + // This #4521 by skipping the unnecessary `checked` update. cur !== oldProps[key] ) { // some property updates can throw @@ -9247,7 +9291,7 @@ // 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)); @@ -9552,7 +9596,7 @@ var slotRE = /^v-slot(:|$)|^#/; var lineBreakRE = /[\r\n]/; - var whitespaceRE$1 = /\s+/g; + var whitespaceRE$1 = /[ \f\t\r\n]+/g; var invalidAttributeRE = /[\s"'<>\/=]/; @@ -9600,8 +9644,12 @@ 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'); @@ -9894,7 +9942,7 @@ } }, comment: function comment (text, start, end) { - // adding anyting as a sibling to the root node is forbidden + // adding anything as a sibling to the root node is forbidden // comments should still be allowed, but ignored if (currentParent) { var child = { @@ -10850,9 +10898,9 @@ 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; @@ -10938,7 +10986,8 @@ options ) { var state = new CodegenState(options); - var code = ast ? genElement(ast, state) : '_c("div")'; + // fix #11483, Root level