diff --git a/src/platforms/web/runtime/modules/attrs.js b/src/platforms/web/runtime/modules/attrs.js index b5e0640305c..245b4939fc3 100644 --- a/src/platforms/web/runtime/modules/attrs.js +++ b/src/platforms/web/runtime/modules/attrs.js @@ -39,7 +39,7 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) { cur = attrs[key] old = oldAttrs[key] if (old !== cur) { - setAttr(elm, key, cur) + setAttr(elm, key, cur, vnode.data.pre) } } // #4391: in IE9, setting type can reset value for input[type=radio] @@ -59,9 +59,11 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) { } } -function setAttr (el: Element, key: string, value: any) { +function setAttr (el: Element, key: string, value: any, isInPre: any) { if (el.tagName.indexOf('-') > -1) { baseSetAttr(el, key, value) + } else if(isInPre) { + baseSetAttr(el, key, value) } else if (isBooleanAttr(key)) { // set attribute for blank value // e.g. diff --git a/test/unit/features/directives/pre.spec.js b/test/unit/features/directives/pre.spec.js index ed48bf0f860..a876587ac20 100644 --- a/test/unit/features/directives/pre.spec.js +++ b/test/unit/features/directives/pre.spec.js @@ -42,4 +42,15 @@ describe('Directive v-pre', function () { vm.$mount() expect(vm.$el.firstChild.tagName).toBe('VTEST') }) + + // #10087 + it('should not compile attributes', function () { + Vue.component('vtest', { template: `
Hello World
` }) + const vm = new Vue({ + template: '
', + replace: true + }) + vm.$mount() + expect(vm.$el.firstChild.getAttribute('open')).toBe('hello') + }) })