From 55d2828f06612b892d4ae1a3fe9d21bc3d0ad305 Mon Sep 17 00:00:00 2001 From: billyzou Date: Wed, 24 Apr 2019 17:45:01 -0400 Subject: [PATCH 01/11] feat: check if a tag is already in window.customElements --- src/core/vdom/patch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index 9746bb794f8..41310c84420 100644 --- a/src/core/vdom/patch.js +++ b/src/core/vdom/patch.js @@ -106,6 +106,7 @@ export function createPatchFunction (backend) { function isUnknownElement (vnode, inVPre) { return ( + !(typeof window !== 'undefined' && window.customElements && window.customElements.get(vnode.tag)) && !inVPre && !vnode.ns && !( From a9a303009a4267b7f12b956741b4e34dfdc6566f Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 25 Apr 2019 10:00:51 +0800 Subject: [PATCH 02/11] chore: fix SimpleSet export --- src/core/util/env.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/util/env.js b/src/core/util/env.js index eff1d21dc75..820bacdb405 100644 --- a/src/core/util/env.js +++ b/src/core/util/env.js @@ -87,11 +87,10 @@ if (typeof Set !== 'undefined' && isNative(Set)) { } } -interface SimpleSet { +export interface SimpleSet { has(key: string | number): boolean; add(key: string | number): mixed; clear(): void; } export { _Set } -export type { SimpleSet } From ea113d261835d14b7fb7a14896972efc3c8a75b9 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 25 Apr 2019 10:13:32 +0800 Subject: [PATCH 03/11] test: separate failing test for TS 3.4 --- types/test/options-test.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/types/test/options-test.ts b/types/test/options-test.ts index b8bdc098312..28060b7c817 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -76,10 +76,6 @@ Vue.component('union-prop', { complexUnion: { type: [User, Number] as PropType }, kittyUser: Object as PropType, callback: Function as PropType, - mixed: [RegExp, Array], - object: [Cat, User], - primitive: [String, Number], - regex: RegExp, union: [User, Number] as PropType }, data() { @@ -87,10 +83,6 @@ Vue.component('union-prop', { this.complexUnion; this.kittyUser; this.callback(true); - this.mixed; - this.object; - this.primitive; - this.regex.compile; this.union; return { fixedSize: this.union, @@ -98,6 +90,22 @@ Vue.component('union-prop', { } }); +// stopped working since TS 3.4 +// Vue.component('union-prop-with-no-casting', { +// props: { +// mixed: [RegExp, Array], +// object: [Cat, User], +// primitive: [String, Number], +// regex: RegExp +// }, +// data() { +// this.mixed; +// this.object; +// this.primitive; +// this.regex.compile; +// } +// }) + Vue.component('prop-with-primitive-default', { props: { id: { From 43b98fe25151b0b6bacd36f3ee27c5d61add5fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E8=BF=9F?= Date: Thu, 25 Apr 2019 10:34:55 +0800 Subject: [PATCH 04/11] refactor: remove useless parameter to the function removeVnodes (#9914) close #9910 --- packages/weex-vue-framework/factory.js | 8 ++++---- src/core/vdom/patch.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/weex-vue-framework/factory.js b/packages/weex-vue-framework/factory.js index 8bcfb675ba9..fb30d12bbbd 100644 --- a/packages/weex-vue-framework/factory.js +++ b/packages/weex-vue-framework/factory.js @@ -5797,7 +5797,7 @@ function createPatchFunction (backend) { } } - function removeVnodes (parentElm, vnodes, startIdx, endIdx) { + function removeVnodes (vnodes, startIdx, endIdx) { for (; startIdx <= endIdx; ++startIdx) { var ch = vnodes[startIdx]; if (isDef(ch)) { @@ -5908,7 +5908,7 @@ function createPatchFunction (backend) { refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); } else if (newStartIdx > newEndIdx) { - removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); + removeVnodes(oldCh, oldStartIdx, oldEndIdx); } } @@ -5985,7 +5985,7 @@ function createPatchFunction (backend) { if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); } else if (isDef(oldCh)) { - removeVnodes(elm, oldCh, 0, oldCh.length - 1); + removeVnodes(oldCh, 0, oldCh.length - 1); } else if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } @@ -6216,7 +6216,7 @@ function createPatchFunction (backend) { // destroy old node if (isDef(parentElm$1)) { - removeVnodes(parentElm$1, [oldVnode], 0, 0); + removeVnodes([oldVnode], 0, 0); } else if (isDef(oldVnode.tag)) { invokeDestroyHook(oldVnode); } diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index 9746bb794f8..2052df913b3 100644 --- a/src/core/vdom/patch.js +++ b/src/core/vdom/patch.js @@ -358,7 +358,7 @@ export function createPatchFunction (backend) { } } - function removeVnodes (parentElm, vnodes, startIdx, endIdx) { + function removeVnodes (vnodes, startIdx, endIdx) { for (; startIdx <= endIdx; ++startIdx) { const ch = vnodes[startIdx] if (isDef(ch)) { @@ -469,7 +469,7 @@ export function createPatchFunction (backend) { refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue) } else if (newStartIdx > newEndIdx) { - removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx) + removeVnodes(oldCh, oldStartIdx, oldEndIdx) } } @@ -561,7 +561,7 @@ export function createPatchFunction (backend) { if (isDef(oldVnode.text)) nodeOps.setTextContent(elm, '') addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue) } else if (isDef(oldCh)) { - removeVnodes(elm, oldCh, 0, oldCh.length - 1) + removeVnodes(oldCh, 0, oldCh.length - 1) } else if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, '') } @@ -790,7 +790,7 @@ export function createPatchFunction (backend) { // destroy old node if (isDef(parentElm)) { - removeVnodes(parentElm, [oldVnode], 0, 0) + removeVnodes([oldVnode], 0, 0) } else if (isDef(oldVnode.tag)) { invokeDestroyHook(oldVnode) } From bd6cea0973247e2a8e1d4a2250614c0bf44f0b26 Mon Sep 17 00:00:00 2001 From: zrh122 <46116414+zrh122@users.noreply.github.com> Date: Thu, 25 Apr 2019 10:35:16 +0800 Subject: [PATCH 05/11] test: fix running e2e test on windows (#9909) --- test/e2e/nightwatch.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/nightwatch.config.js b/test/e2e/nightwatch.config.js index 2004f92b45b..8ec592494fe 100644 --- a/test/e2e/nightwatch.config.js +++ b/test/e2e/nightwatch.config.js @@ -50,7 +50,8 @@ module.exports = { 'desiredCapabilities': { 'browserName': 'phantomjs', 'javascriptEnabled': true, - 'acceptSslCerts': true + 'acceptSslCerts': true, + 'phantomjs.binary.path': require('phantomjs-prebuilt').path } } } From 861aea16615a9736eab6af6d05fa5500ae4d6c37 Mon Sep 17 00:00:00 2001 From: Natalia Tepluhina Date: Thu, 25 Apr 2019 05:39:19 +0300 Subject: [PATCH 06/11] polish: add warning when .native modifier is used on native HTML elements (#9884) --- src/core/vdom/create-element.js | 6 ++++++ test/unit/features/directives/on.spec.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/core/vdom/create-element.js b/src/core/vdom/create-element.js index 46027084b51..ba36e15b12d 100644 --- a/src/core/vdom/create-element.js +++ b/src/core/vdom/create-element.js @@ -98,6 +98,12 @@ export function _createElement ( ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag) if (config.isReservedTag(tag)) { // platform built-in elements + if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.nativeOn)) { + warn( + `The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, + context + ) + } vnode = new VNode( config.parsePlatformTagName(tag), data, children, undefined, undefined, context diff --git a/test/unit/features/directives/on.spec.js b/test/unit/features/directives/on.spec.js index a97ddaa8947..b7801a82f22 100644 --- a/test/unit/features/directives/on.spec.js +++ b/test/unit/features/directives/on.spec.js @@ -460,6 +460,20 @@ describe('Directive v-on', () => { expect(spy).toHaveBeenCalled() }) + it('should throw a warning if native modifier is used on native HTML element', () => { + vm = new Vue({ + el, + template: ` + + `, + methods: { foo: spy }, + }) + + triggerEvent(vm.$el, 'click') + expect(`The .native modifier for v-on is only valid on components but it was used on