From 345b1ca323a5fd690e687ef3053329c16eb4d2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=BC=E6=97=8F=E5=B0=8F=E7=8B=88?= <1340641314@qq.com> Date: Fri, 5 May 2017 11:22:41 +0800 Subject: [PATCH 01/10] Update use.js fix:use feat continuous operation --- src/core/global-api/use.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/global-api/use.js b/src/core/global-api/use.js index 8f459528780..347bf4b6fcc 100644 --- a/src/core/global-api/use.js +++ b/src/core/global-api/use.js @@ -6,7 +6,7 @@ export function initUse (Vue: GlobalAPI) { Vue.use = function (plugin: Function | Object) { /* istanbul ignore if */ if (plugin.installed) { - return + return this } // additional parameters const args = toArray(arguments, 1) From 4f03c66015e8072fe723008b7709aa6cbc17f55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=BC=E6=97=8F=E5=B0=8F=E7=8B=88?= <1340641314@qq.com> Date: Fri, 5 May 2017 11:38:20 +0800 Subject: [PATCH 02/10] Update mixin.js fix:mixin feat continuous operation --- src/core/global-api/mixin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/global-api/mixin.js b/src/core/global-api/mixin.js index 83f7a139d5a..36017a324a2 100644 --- a/src/core/global-api/mixin.js +++ b/src/core/global-api/mixin.js @@ -5,5 +5,6 @@ import { mergeOptions } from '../util/index' export function initMixin (Vue: GlobalAPI) { Vue.mixin = function (mixin: Object) { this.options = mergeOptions(this.options, mixin) + return this } } From 5f285e0cf15bd3ca7d9abb310453b3e2a94b4aeb Mon Sep 17 00:00:00 2001 From: lzxb <1340641314@qq.com> Date: Wed, 13 Dec 2017 11:16:24 +0800 Subject: [PATCH 03/10] Merge remote-tracking branch 'upstream/dev' into dev --- BACKERS.md | 223 ++++++------------ README.md | 41 ++-- src/compiler/codegen/index.js | 10 +- .../instance/render-helpers/render-static.js | 20 +- src/platforms/weex/entry-framework.js | 14 +- test/unit/modules/compiler/codegen.spec.js | 4 +- test/weex/compiler/compile.spec.js | 6 +- 7 files changed, 126 insertions(+), 192 deletions(-) diff --git a/BACKERS.md b/BACKERS.md index 951ec5d738b..88dee004705 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -13,19 +13,32 @@ Funds donated via Patreon goes directly to support Evan You's full-time work on

Platinum via Patreon

-

- - - -

- - - -

- - - -

+ + + + + + + + + +
+ + + + + + + + + + + + + + + +

Platinum via OpenCollective

@@ -274,215 +287,125 @@ Funds donated via Patreon goes directly to support Evan You's full-time work on

Generous Backers via Patreon ($50+)

-- No Divide Studio -- James Kyle -- Blake Newman -- Lee Smith -- Adam Dorsey -- Greg McCarvell -- Yoshiya Hinosawa + - Wasim Khamlichi - errorrik - Alex Balashov - Konstantin Levinski - Samuel Smith -- Harri J Salomaa +- HARRI J SALOMAA +- tjkoury +

Backers via Patreon

-- Sylvain Pollet-Villard + - Luca Borghini -- Kazuya Kawaguchi -- Keisuke Kita -- Anirudh Sanjeev -- Guido Bertolino -- Fábio Vedovelli +- kazuya kawaguchi +- Keisuke KITA +- Fabio Vedovelli - Jack Barham -- Stephane Demoote -- Paul R. Dillinger -- Sean Washington -- Alun Davey -- Eduardo Kyvenko -- Thijs de Maa -- Joris Noordermeer -- Niklas Lifors -- An Phan -- Richard Wyke -- Roman Kuba +- Santa Cruz - Tom Conlon -- Matt Pickle - Simon East -- Bill Columbia -- Hayden Bickerton - Henry Zhu -- John Smith - Benjamin Listwon -- Rainer Morgan -- Brian Jorden -- Christopher Dosin - Lars Andreas Ness -- Drew Lustro - Victor Tolbert -- Jon Pokrzyk -- Frank Dungan III -- Lanes.io -- Anders -- Dexter Miguel -- Stephen Michael Hartley +- Frank Dugan III +- Stephen Hartley - Wen-Tien Chang -- Ole Støvern -- Valerian Cure -- Dani Ilops -- louisbl -- Yegor Sytnyk -- Guido H. -- Joan Cejudo -- Ian Walter +- Chestnut Hill - Nikola Trifunovic -- Nicolas Mutis Mesa -- Fahed Toumi -- James Brooks - Kirk Lewis -- Spenser -- Takuya Nishio -- Daniel Diekmeier -- Peter Thaleikis -- Karol Fabjanczuk -- Eduardo -- Lê Chương -- Webber Wang -- Daniel Schmitz -- Bruce Li -- Mohammed -- Sam Wainwright -- TJ Hillard -- Kyle Arrington -- Jason Land +- Karol F - Miljan Aleksic -- James Ye -- Laurids Duellmann -- Christo Crampton -- Adon Metcalfe +- 叶解 - Paul Straw - Jake Ingman -- Eduardo Camillo - Barbara Liau -- Jens Lind -- Yegor Sytnyk -- Benson Wong -- Anthony Tsui -- Karol Fabjanczuk - Isaac Sant - Milos Stojanovic -- Matsumoto Takamasa -- Douglas Lowder -- Bess Brooks +- 4 +- The Graphic Design School - Christian Griffith -- Matt Rockwell - Jarek Tkaczyk -- Michael Laccetti -- Jonothan Allen - Andrew Davis -- Jason Rys -- Sean -- Xiaojie Li -- Joakim Bugge -- Lacey Pevey +- Sean MacIsaac +- Xiaojie LI - David Hess - Niannian Modisette -- Kim Cuartero -- Luke Sampson - Dariusz Jastrzębski -- Ivan Sieder -- Jivan Roquet -- Shane -- Stew Heckenberg - Matt Jones - Dave Chenell - Frank Baele -- Jack McDade -- Patrick O'Dacre -- Wietse Wind -- Donny Donny -- Duncan Kenzie +- Cheng-Wei Chien +- Duncan J Kenzie - Mike Margerum -- Michael Richards -- Eduardo Reveles -- Jan Kremlacek +- Cruz Eduardo Reveles Caldera - Guy Gavergun -- Keith Bailey -- Joel Birch -- Bernhard E. Reiter -- Radu Cretu -- Luiz Tanure -- Poamrong Rith +- Edithvale +- Intevation GmbH +- Luiz Eduardo Tanure Bacelar +- Polo Rith - Chengzhi Yin - Dan Barrett - Zoran Knezevic -- Charles Beaumont -- Jonathan Kent - James Simpson -- Pascal Germain - Pierre Vanhulst - Vincent Gabriel -- Kyovo Digaw -- devneko -- Cheng-Wei Chien +- Shinji Yamada - Michael Mazurczak -- Daniel - Chris Anderson - Jon Hobbs-Smith - Chez Tschetter - Akiho Nagao -- Alexander Karelas - Asaf Yishai - Diana Espino - Alexandre Madurell -- alxs -- Anthony Estebe +- Estebe Anthony - Haim Yulzari -- Blake Campbell +- Blake Camobell - David McGuigan -- Niklas Wallentin - Jeremy Tan - Jim Raden - Luka Savic -- IMGNRY -- Pascal Germain -- Raphaël Saunier -- Kirk Lewis +- Fille Åström - Nicholas Reid -- Tyler -- Yong Jun Thong -- Jonatan Machado -- Tai Shi Ling +- Tyler Scott +- Thong Yong Jun +- Tai Shi Lgin - Bryan Gruneberg +- Roman Kuba - Matthew McMillion -- Keith Mancuso -- Alexander Karelas +- Familiar Studio - Matias Verdier - Jamie McElwain - Travis Gertz -- Ale Mohamad -- Jonas Galvez -- William Correa -- Raphael Belvederese +- Vivekanandhan Natarajan +- Alejandro Mohamad +- Rafael Belvederese - Mickaël Andrieu - Guilherme S L de Souza - Rob Yedlin - Daniel Waghorn -- Eric Githinji -- Vivekanandhan Natarajan -- Chih-Hsuan Fan +- Chih-Hsuan, Fan - Jordan Oroshiba - Brian Jorden - Cliff Hess -- Joe Gregory +- Joe Ray Gregory - Johnny Eshan - Alexander Karelas - Kamil Ocean -- Orney Enrique Martinez Said +- Orney Enrique martinez Said - Tom Striker +- Oskar Lindgren +- RADD Creative +- Maegan Wilson +- Rua Cura D'ars +- Arthur Tyukayev +- Richard Simpson +

Backers via OpenCollective

diff --git a/README.md b/README.md index bae6837b164..7910db58487 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

+

Vue logo

Build Status @@ -26,19 +26,32 @@ Funds donated via Patreon goes directly to support Evan You's full-time work on

Platinum

-

- - - -

- - - -

- - - -

+ + + + + + + + + +
+ + + + + + + + + + + + + + + +

Gold

diff --git a/src/compiler/codegen/index.js b/src/compiler/codegen/index.js index 7b8a1826d7a..e031e15b053 100644 --- a/src/compiler/codegen/index.js +++ b/src/compiler/codegen/index.js @@ -86,15 +86,13 @@ export function genElement (el: ASTElement, state: CodegenState): string { } // hoist static sub-trees out -function genStatic (el: ASTElement, state: CodegenState, once: ?boolean): string { +function genStatic (el: ASTElement, state: CodegenState): string { el.staticProcessed = true state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`) return `_m(${ state.staticRenderFns.length - 1 - },${ - el.staticInFor ? 'true' : 'false' - },${ - once ? 'true' : 'false' + }${ + el.staticInFor ? ',true' : '' })` } @@ -121,7 +119,7 @@ function genOnce (el: ASTElement, state: CodegenState): string { } return `_o(${genElement(el, state)},${state.onceId++},${key})` } else { - return genStatic(el, state, true) + return genStatic(el, state) } } diff --git a/src/core/instance/render-helpers/render-static.js b/src/core/instance/render-helpers/render-static.js index d80311e5604..a26abbb6ee9 100644 --- a/src/core/instance/render-helpers/render-static.js +++ b/src/core/instance/render-helpers/render-static.js @@ -7,19 +7,9 @@ import { cloneVNode, cloneVNodes } from 'core/vdom/vnode' */ export function renderStatic ( index: number, - isInFor: boolean, - isOnce: boolean + isInFor: boolean ): VNode | Array { - // render fns generated by compiler < 2.5.4 does not provide v-once - // information to runtime so be conservative - const isOldVersion = arguments.length < 3 - // if a static tree is generated by v-once, it is cached on the instance; - // otherwise it is purely static and can be cached on the shared options - // across all instances. - const renderFns = this.$options.staticRenderFns - const cached = isOldVersion || isOnce - ? (this._staticTrees || (this._staticTrees = [])) - : (renderFns.cached || (renderFns.cached = [])) + const cached = this._staticTrees || (this._staticTrees = []) let tree = cached[index] // if has already-rendered static tree and not inside v-for, // we can reuse the same tree by doing a shallow clone. @@ -29,7 +19,11 @@ export function renderStatic ( : cloneVNode(tree) } // otherwise, render a fresh tree. - tree = cached[index] = renderFns[index].call(this._renderProxy, null, this) + tree = cached[index] = this.$options.staticRenderFns[index].call( + this._renderProxy, + null, + this // for render fns generated for functional component templates + ) markStatic(tree, `__static__${index}`, false) return tree } diff --git a/src/platforms/weex/entry-framework.js b/src/platforms/weex/entry-framework.js index 9b7c920cfbd..f5352867d05 100644 --- a/src/platforms/weex/entry-framework.js +++ b/src/platforms/weex/entry-framework.js @@ -61,12 +61,8 @@ export function createInstance ( }, timerAPIs, env.services) appCode = `(function(global){ \n${appCode}\n })(Object.create(this))` - callFunction(instanceVars, appCode) - // Send `createFinish` signal to native. - document.taskCenter.send('dom', { action: 'createFinish' }, []) - return instance } @@ -208,6 +204,16 @@ function createVueModuleInstance (instanceId, weex) { // record instance by id instance.app = this } + }, + mounted () { + const options = this.$options + // root component (vm) + if (options.el && weex.document) { + try { + // Send "createFinish" signal to native. + weex.document.taskCenter.send('dom', { action: 'createFinish' }, []) + } catch (e) {} + } } }) diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js index 5e042668fd7..d8b6c7e6839 100644 --- a/test/unit/modules/compiler/codegen.spec.js +++ b/test/unit/modules/compiler/codegen.spec.js @@ -478,7 +478,7 @@ describe('codegen', () => { // have "inline-template'" assertCodegen( '

hello world

', - `with(this){return _c('my-component',{inlineTemplate:{render:function(){with(this){return _m(0,false,false)}},staticRenderFns:[function(){with(this){return _c('p',[_c('span',[_v("hello world")])])}}]}})}` + `with(this){return _c('my-component',{inlineTemplate:{render:function(){with(this){return _m(0)}},staticRenderFns:[function(){with(this){return _c('p',[_c('span',[_v("hello world")])])}}]}})}` ) // "have inline-template attrs, but not having exactly one child element assertCodegen( @@ -498,7 +498,7 @@ describe('codegen', () => { it('generate static trees inside v-for', () => { assertCodegen( `

`, - `with(this){return _c('div',_l((10),function(i){return _c('div',[_m(0,true,false)])}))}`, + `with(this){return _c('div',_l((10),function(i){return _c('div',[_m(0,true)])}))}`, [`with(this){return _c('p',[_c('span')])}`] ) }) diff --git a/test/weex/compiler/compile.spec.js b/test/weex/compiler/compile.spec.js index cd69c7414d9..7a717f19146 100644 --- a/test/weex/compiler/compile.spec.js +++ b/test/weex/compiler/compile.spec.js @@ -32,12 +32,12 @@ describe('compile basic', () => { it('should compile unary tag', () => { const inputCase = compile(`
abc
`) - expect(inputCase.render).toMatch(strToRegExp(`return _m(0,false,false)`)) + expect(inputCase.render).toMatch(strToRegExp(`return _m(0)`)) expect(inputCase.staticRenderFns).toMatch(strToRegExp(`_c('div',[_c('input'),_c('text',[_v("abc")])])`)) expect(inputCase.errors).toEqual([]) const imageCase = compile(`
abc
`) - expect(imageCase.render).toMatch(strToRegExp(`return _m(0,false,false)`)) + expect(imageCase.render).toMatch(strToRegExp(`return _m(0)`)) expect(imageCase.staticRenderFns).toMatch(strToRegExp(`_c('div',[_c('image',{attrs:{"src":"path"}}),_c('text',[_v("abc")])])`)) expect(imageCase.errors).toEqual([]) @@ -54,7 +54,7 @@ describe('compile basic', () => { `) - expect(complexCase.render).toMatch(strToRegExp(`return _m(0,false,false)`)) + expect(complexCase.render).toMatch(strToRegExp(`return _m(0)`)) expect(complexCase.staticRenderFns).toMatch(strToRegExp(`_c('image',{attrs:{"src":"path"}}),_c('image'),_c('div'`)) expect(complexCase.staticRenderFns).toMatch(strToRegExp(`_c('div',[_c('embed'),_c('text',[_v("start")]),_c('input',{attrs:{"type":"text"}}),_c('input',{attrs:{"type":"url"}}),_c('text',[_v("end")])]`)) expect(complexCase.errors).toEqual([]) From d3b04ca98439b2640c9b89f043842c62a4d02b96 Mon Sep 17 00:00:00 2001 From: lzxb Date: Fri, 3 Aug 2018 09:40:04 +0800 Subject: [PATCH 04/10] fix: fix types --- types/vue.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/vue.d.ts b/types/vue.d.ts index e1431453dd9..5a821ecd962 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -98,9 +98,9 @@ export interface VueConstructor { component(id: string, definition?: ThisTypedComponentOptionsWithRecordProps): ExtendedVue; component(id: string, definition?: ComponentOptions): ExtendedVue; - use(plugin: PluginObject | PluginFunction, options?: T): void; - use(plugin: PluginObject | PluginFunction, ...options: any[]): void; - mixin(mixin: VueConstructor | ComponentOptions): void; + use(plugin: PluginObject | PluginFunction, options?: T): this; + use(plugin: PluginObject | PluginFunction, ...options: any[]): this; + mixin(mixin: VueConstructor | ComponentOptions): this; compile(template: string): { render(createElement: typeof Vue.prototype.$createElement): VNode; staticRenderFns: (() => VNode)[]; From 8f85e94ab480ef46ed391bc8efa267cd36415d63 Mon Sep 17 00:00:00 2001 From: lzxb Date: Fri, 3 Aug 2018 09:59:53 +0800 Subject: [PATCH 05/10] fix: flow types --- flow/global-api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flow/global-api.js b/flow/global-api.js index 0b2efb23ac3..9477c1c7746 100644 --- a/flow/global-api.js +++ b/flow/global-api.js @@ -8,8 +8,8 @@ declare interface GlobalAPI { set: (target: Object | Array, key: string | number, value: T) => T; delete: (target: Object| Array, key: string | number) => void; nextTick: (fn: Function, context?: Object) => void | Promise<*>; - use: (plugin: Function | Object) => void; - mixin: (mixin: Object) => void; + use: (plugin: Function | Object) => this; + mixin: (mixin: Object) => this; compile: (template: string) => { render: Function, staticRenderFns: Array }; directive: (id: string, def?: Function | Object) => Function | Object | void; From c20977a3fc8a6cf334f0d6eaf769d137c9856e97 Mon Sep 17 00:00:00 2001 From: lzxb Date: Fri, 3 Aug 2018 10:06:25 +0800 Subject: [PATCH 06/10] fix: flow type --- flow/global-api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flow/global-api.js b/flow/global-api.js index 9477c1c7746..eab244c22bb 100644 --- a/flow/global-api.js +++ b/flow/global-api.js @@ -8,8 +8,8 @@ declare interface GlobalAPI { set: (target: Object | Array, key: string | number, value: T) => T; delete: (target: Object| Array, key: string | number) => void; nextTick: (fn: Function, context?: Object) => void | Promise<*>; - use: (plugin: Function | Object) => this; - mixin: (mixin: Object) => this; + use: (plugin: Function | Object) => GlobalAPI; + mixin: (mixin: Object) => GlobalAPI; compile: (template: string) => { render: Function, staticRenderFns: Array }; directive: (id: string, def?: Function | Object) => Function | Object | void; From 7fa8b9839d39aa2a935814a534702660e54c7ac9 Mon Sep 17 00:00:00 2001 From: lzxb Date: Fri, 3 Aug 2018 20:01:51 +0800 Subject: [PATCH 07/10] test: add typescript test --- types/test/vue-test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts index 031a909b67a..1f5f09b7404 100644 --- a/types/test/vue-test.ts +++ b/types/test/vue-test.ts @@ -96,6 +96,11 @@ class Test extends Vue { this.use; this.mixin(Test); this.compile("
{{ message }}
"); + this + .use(() => { + + }) + .mixin({}); } } From 14fed5988bc1d67ebb3a9ef1eda519c2d6514488 Mon Sep 17 00:00:00 2001 From: lzxb Date: Fri, 3 Aug 2018 20:12:09 +0800 Subject: [PATCH 08/10] test: add #8595 unit test --- test/unit/features/global-api/mixin.spec.js | 5 +++++ test/unit/features/global-api/use.spec.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/unit/features/global-api/mixin.spec.js b/test/unit/features/global-api/mixin.spec.js index bcf962402c2..c6f2920e996 100644 --- a/test/unit/features/global-api/mixin.spec.js +++ b/test/unit/features/global-api/mixin.spec.js @@ -162,4 +162,9 @@ describe('Global API: mixin', () => { expect(base).toHaveBeenCalled() expect(injected).toHaveBeenCalled() }) + + // #8595 + it('chain call', () => { + expect(Vue.mixin({}).toBe(Vue)) + }) }) diff --git a/test/unit/features/global-api/use.spec.js b/test/unit/features/global-api/use.spec.js index 00053f808a7..d54ff0750f3 100644 --- a/test/unit/features/global-api/use.spec.js +++ b/test/unit/features/global-api/use.spec.js @@ -49,4 +49,9 @@ describe('Global API: use', () => { expect(Vue.options.directives['plugin-test']).toBeUndefined() expect(Ctor2.options.directives['plugin-test']).toBe(def) }) + + // #8595 + it('chain call', () => { + expect(Vue.use(() => {})).toBe(Vue) + }) }) From fc4d50c551967ea52c56387e667d463136160e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=BC=E6=97=8F=E5=B0=8F=E7=8B=88?= <1340641314@qq.com> Date: Sat, 4 Aug 2018 15:45:41 +0800 Subject: [PATCH 09/10] Update mixin.spec.js --- test/unit/features/global-api/mixin.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/features/global-api/mixin.spec.js b/test/unit/features/global-api/mixin.spec.js index c6f2920e996..0b83773a5d4 100644 --- a/test/unit/features/global-api/mixin.spec.js +++ b/test/unit/features/global-api/mixin.spec.js @@ -165,6 +165,6 @@ describe('Global API: mixin', () => { // #8595 it('chain call', () => { - expect(Vue.mixin({}).toBe(Vue)) + expect(Vue.mixin({})).toBe(Vue) }) }) From 8f7131e3b523d1f4ed2a3e18487eaba447a8751d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=BC=E6=97=8F=E5=B0=8F=E7=8B=88?= <1340641314@qq.com> Date: Sat, 4 Aug 2018 15:48:28 +0800 Subject: [PATCH 10/10] fix: typescript types --- types/test/vue-test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts index 1f5f09b7404..b03b227ffab 100644 --- a/types/test/vue-test.ts +++ b/types/test/vue-test.ts @@ -100,6 +100,10 @@ class Test extends Vue { .use(() => { }) + .use(() => { + + }) + .mixin({}) .mixin({}); } }