diff --git a/.circleci/config.yml b/.circleci/config.yml index e09c1b569..8d5e7bbff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,8 +9,6 @@ restore_node_modules: &restore_node_modules name: Restore node_modules cache keys: - v1-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }} - - v1-dependencies-{{ .Branch }}- - - v1-dependencies- jobs: install: <<: *defaults diff --git a/flow/config.flow.js b/flow/config.flow.js index 5cf6fe60a..3b8ca796f 100644 --- a/flow/config.flow.js +++ b/flow/config.flow.js @@ -3,6 +3,5 @@ declare type Config = { mocks?: Object, methods?: { [name: string]: Function }, provide?: Object, - logModifiedComponents?: boolean, silent?: boolean } diff --git a/package.json b/package.json index 78994ecc1..6c501aaa2 100644 --- a/package.json +++ b/package.json @@ -68,12 +68,12 @@ "sinon-chai": "^2.10.0", "typescript": "^3.0.1", "vee-validate": "^2.1.3", - "vue": "2.5.16", + "vue": "2.5.21", "vue-class-component": "^6.1.2", "vue-loader": "^13.6.2", "vue-router": "^3.0.1", - "vue-server-renderer": "2.5.16", - "vue-template-compiler": "2.5.16", + "vue-server-renderer": "2.5.21", + "vue-template-compiler": "2.5.21", "vuepress": "^0.14.2", "vuepress-theme-vue": "^1.0.3", "vuex": "^3.0.1", diff --git a/packages/create-instance/create-instance.js b/packages/create-instance/create-instance.js index 27a63d5b0..b0869002b 100644 --- a/packages/create-instance/create-instance.js +++ b/packages/create-instance/create-instance.js @@ -72,10 +72,11 @@ export default function createInstance( componentOptions.$_vueTestUtils_original = component // make sure all extends are based on this instance - componentOptions._base = _Vue const Constructor = _Vue.extend(componentOptions).extend(instanceOptions) + Constructor.options._base = _Vue + const scopedSlots = createScopedSlots(options.scopedSlots, _Vue) const parentComponentOptions = options.parentComponent || {} diff --git a/packages/create-instance/extract-instance-options.js b/packages/create-instance/extract-instance-options.js index f74a0d52f..5962b594c 100644 --- a/packages/create-instance/extract-instance-options.js +++ b/packages/create-instance/extract-instance-options.js @@ -11,7 +11,6 @@ const MOUNTING_OPTIONS = [ 'attrs', 'listeners', 'propsData', - 'logModifiedComponents', 'sync', 'shouldProxy' ] diff --git a/packages/server-test-utils/dist/vue-server-test-utils.js b/packages/server-test-utils/dist/vue-server-test-utils.js index efd9bd959..376820378 100644 --- a/packages/server-test-utils/dist/vue-server-test-utils.js +++ b/packages/server-test-utils/dist/vue-server-test-utils.js @@ -10,11 +10,7 @@ var cheerio = _interopDefault(require('cheerio')); // -function createVNodes ( - vm, - slotValue, - name -) { +function createVNodes(vm, slotValue, name) { var el = vueTemplateCompiler.compileToFunctions( ("
") ); @@ -28,7 +24,7 @@ function createVNodes ( return vnode.children[0] } -function createVNodesForSlot ( +function createVNodesForSlot( vm, slotValue, name @@ -41,15 +37,14 @@ function createVNodesForSlot ( return vnode } -function createSlotVNodes ( +function createSlotVNodes( vm, slots ) { return Object.keys(slots).reduce(function (acc, key) { var content = slots[key]; if (Array.isArray(content)) { - var nodes = content.map( - function (slotDef) { return createVNodesForSlot(vm, slotDef, key); } + var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); } ); return acc.concat(nodes) } @@ -1464,11 +1459,11 @@ var semver_39 = semver.coerce; // -function throwError (msg) { +function throwError(msg) { throw new Error(("[vue-test-utils]: " + msg)) } -function warn (msg) { +function warn(msg) { console.error(("[vue-test-utils]: " + msg)); } @@ -1491,11 +1486,11 @@ var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice var hyphenateRE = /\B([A-Z])/g; var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); }; -function hasOwnProperty (obj, prop) { +function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop) } -function resolveComponent (id, components) { +function resolveComponent(id, components) { if (typeof id !== 'string') { return } @@ -1515,19 +1510,19 @@ function resolveComponent (id, components) { return components[id] || components[camelizedId] || components[PascalCaseId] } -var UA = typeof window !== 'undefined' && +var UA = + typeof window !== 'undefined' && 'navigator' in window && navigator.userAgent.toLowerCase(); -var isPhantomJS = UA && UA.includes && - UA.match(/phantomjs/i); +var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i); var isEdge = UA && UA.indexOf('edge/') > 0; var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; // -function addMocks ( +function addMocks( _Vue, mockedProperties ) { @@ -1543,8 +1538,8 @@ function addMocks ( } catch (e) { warn( "could not overwrite property " + key + ", this is " + - "usually caused by a plugin that has added " + - "the property as a read-only value" + "usually caused by a plugin that has added " + + "the property as a read-only value" ); } // $FlowIgnore @@ -1554,7 +1549,7 @@ function addMocks ( // -function logEvents ( +function logEvents( vm, emitted, emittedByOrder @@ -1563,16 +1558,15 @@ function logEvents ( vm.$emit = function (name) { var args = [], len = arguments.length - 1; while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - (emitted[name] || (emitted[name] = [])).push(args); +(emitted[name] || (emitted[name] = [])).push(args); emittedByOrder.push({ name: name, args: args }); return emit.call.apply(emit, [ vm, name ].concat( args )) }; } -function addEventLogger (_Vue) { +function addEventLogger(_Vue) { _Vue.mixin({ - beforeCreate: function () { + beforeCreate: function() { this.__emitted = Object.create(null); this.__emittedByOrder = []; logEvents(this, this.__emitted, this.__emittedByOrder); @@ -1584,19 +1578,18 @@ var VUE_VERSION = Number( ((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1])) ); -var BEFORE_RENDER_LIFECYCLE_HOOK = - semver.gt(Vue.version, '2.1.8') - ? 'beforeCreate' - : 'beforeMount'; +var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue.version, '2.1.8') + ? 'beforeCreate' + : 'beforeMount'; var CREATE_ELEMENT_ALIAS = semver.gt(Vue.version, '2.1.5') ? '_c' : '_h'; -function addStubs (_Vue, stubComponents) { +function addStubs(_Vue, stubComponents) { var obj; - function addStubComponentsMixin () { + function addStubComponentsMixin() { Object.assign(this.$options.components, stubComponents); } @@ -1605,27 +1598,27 @@ function addStubs (_Vue, stubComponents) { // -function isVueComponent (component) { - if (typeof component === 'function' && component.options) { +function isVueComponent(c) { + if (isConstructor(c)) { return true } - if (component === null || typeof component !== 'object') { + if (c === null || typeof c !== 'object') { return false } - if (component.extends || component._Ctor) { + if (c.extends || c._Ctor) { return true } - if (typeof component.template === 'string') { + if (typeof c.template === 'string') { return true } - return typeof component.render === 'function' + return typeof c.render === 'function' } -function componentNeedsCompiling (component) { +function componentNeedsCompiling(component) { return ( component && !component.render && @@ -1634,7 +1627,29 @@ function componentNeedsCompiling (component) { ) } -function templateContainsComponent ( +function isConstructor(c) { + return typeof c === 'function' && c.cid +} + +function isDynamicComponent(c) { + return typeof c === 'function' && !c.cid +} + +function isComponentOptions(c) { + return typeof c === 'object' && (c.template || c.render) +} + +function isFunctionalComponent(c) { + if (!isVueComponent(c)) { + return false + } + if (isConstructor(c)) { + return c.options.functional + } + return c.functional +} + +function templateContainsComponent( template, name ) { @@ -1644,44 +1659,45 @@ function templateContainsComponent ( }) } -function isPlainObject (obj) { - return Object.prototype.toString.call(obj) === '[object Object]' +function isPlainObject(c) { + return Object.prototype.toString.call(c) === '[object Object]' } -function makeMap ( - str, - expectsLowerCase -) { +function makeMap(str, expectsLowerCase) { var map = Object.create(null); var list = str.split(','); for (var i = 0; i < list.length; i++) { map[list[i]] = true; } return expectsLowerCase - ? function (val) { return map[val.toLowerCase()] } - : function (val) { return map[val] } + ? function(val) { + return map[val.toLowerCase()] + } + : function(val) { + return map[val] + } } 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,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,' + - 'embed,object,param,source,canvas,script,noscript,del,ins,' + - 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' + - 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + - 'output,progress,select,textarea,' + - 'details,dialog,menu,menuitem,summary,' + - 'content,element,shadow,template,blockquote,iframe,tfoot' + 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + + '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,' + + 'embed,object,param,source,canvas,script,noscript,del,ins,' + + 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' + + 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + + 'output,progress,select,textarea,' + + 'details,dialog,menu,menuitem,summary,' + + 'content,element,shadow,template,blockquote,iframe,tfoot' ); // this map is intentionally selective, only covering SVG elements that may // 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,' + - 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', + 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + + 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true ); @@ -1689,7 +1705,7 @@ var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); }; // -function compileFromString (str) { +function compileFromString(str) { if (!vueTemplateCompiler.compileToFunctions) { throwError( "vueTemplateCompiler is undefined, you must pass " + @@ -1700,7 +1716,7 @@ function compileFromString (str) { return vueTemplateCompiler.compileToFunctions(str) } -function compileTemplate (component) { +function compileTemplate(component) { if (component.template) { Object.assign(component, vueTemplateCompiler.compileToFunctions(component.template)); } @@ -1723,7 +1739,7 @@ function compileTemplate (component) { } } -function compileTemplateForSlots (slots) { +function compileTemplateForSlots(slots) { Object.keys(slots).forEach(function (key) { var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]]; slot.forEach(function (slotValue) { @@ -1747,14 +1763,11 @@ var MOUNTING_OPTIONS = [ 'attrs', 'listeners', 'propsData', - 'logModifiedComponents', 'sync', 'shouldProxy' ]; -function extractInstanceOptions ( - options -) { +function extractInstanceOptions(options) { var instanceOptions = Object.assign({}, options); MOUNTING_OPTIONS.forEach(function (mountingOption) { delete instanceOptions[mountingOption]; @@ -1764,46 +1777,11 @@ function extractInstanceOptions ( // -function isValidSlot (slot) { - return ( - isVueComponent(slot) || - typeof slot === 'string' - ) -} - -function requiresTemplateCompiler (slot) { - if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) { - throwError( - "vueTemplateCompiler is undefined, you must pass " + - "precompiled components if vue-template-compiler is " + - "undefined" - ); - } -} - -function validateSlots (slots) { - Object.keys(slots).forEach(function (key) { - var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]]; - - slot.forEach(function (slotValue) { - if (!isValidSlot(slotValue)) { - throwError( - "slots[key] must be a Component, string or an array " + - "of Components" - ); - } - requiresTemplateCompiler(slotValue); - }); - }); -} - -// - -function isDestructuringSlotScope (slotScope) { +function isDestructuringSlotScope(slotScope) { return slotScope[0] === '{' && slotScope[slotScope.length - 1] === '}' } -function getVueTemplateCompilerHelpers ( +function getVueTemplateCompilerHelpers( _Vue ) { // $FlowIgnore @@ -1834,7 +1812,7 @@ function getVueTemplateCompilerHelpers ( return helpers } -function validateEnvironment () { +function validateEnvironment() { if (VUE_VERSION < 2.1) { throwError("the scopedSlots option is only supported in vue@2.1+."); } @@ -1843,13 +1821,13 @@ function validateEnvironment () { var slotScopeRe = /<[^>]+ slot-scope=\"(.+)\"/; // Hide warning about