diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index 547b878db81..e91bc855b98 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -483,8 +483,8 @@ function processAttrs (el) { ) } } - if (!el.component && ( - isProp || platformMustUseProp(el.tag, el.attrsMap.type, name) + if (isProp || ( + !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name) )) { addProp(el, name, value) } else { diff --git a/test/unit/features/component/component.spec.js b/test/unit/features/component/component.spec.js index e5948315e81..52744c68bad 100644 --- a/test/unit/features/component/component.spec.js +++ b/test/unit/features/component/component.spec.js @@ -187,6 +187,25 @@ describe('Component', () => { }).then(done) }) + it('dynamic elements with domProps', done => { + const vm = new Vue({ + template: '', + data: { + view: 'input', + val: 'hello' + } + }).$mount() + expect(vm.$el.tagName).toBe('INPUT') + expect(vm.$el.value).toBe('hello') + vm.view = 'textarea' + vm.val += ' world' + waitForUpdate(() => { + expect(vm.$el.tagName).toBe('TEXTAREA') + expect(vm.$el.value).toBe('hello world') + vm.view = '' + }).then(done) + }) + it('should compile parent template directives & content in parent scope', done => { const vm = new Vue({ data: { diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index 71e032f15b9..c2bb6c25129 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -463,6 +463,14 @@ describe('parser', () => { expect(ast.props).toBeUndefined() }) + it('use prop when prop modifier was explicitly declared', () => { + const ast = parse('', baseOptions) + expect(ast.attrs).toBeUndefined() + expect(ast.props.length).toBe(1) + expect(ast.props[0].name).toBe('value') + expect(ast.props[0].value).toBe('val') + }) + it('pre/post transforms', () => { const options = extend({}, baseOptions) const spy1 = jasmine.createSpy('preTransform')