diff --git a/src/core/vdom/create-element.js b/src/core/vdom/create-element.js index 46027084..ba36e15b 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 a97ddaa8..b7801a82 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