diff --git a/src/platforms/web/runtime/modules/attrs.js b/src/platforms/web/runtime/modules/attrs.js index b5e06403..f6dc500a 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,8 +59,8 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) { } } -function setAttr (el: Element, key: string, value: any) { - if (el.tagName.indexOf('-') > -1) { +function setAttr (el: Element, key: string, value: any, isInPre: any) { + if (isInPre || el.tagName.indexOf('-') > -1) { baseSetAttr(el, key, value) } else if (isBooleanAttr(key)) { // set attribute for blank value diff --git a/test/unit/features/directives/pre.spec.js b/test/unit/features/directives/pre.spec.js index ed48bf0f..65def9cd 100644 --- a/test/unit/features/directives/pre.spec.js +++ b/test/unit/features/directives/pre.spec.js @@ -42,4 +42,13 @@ describe('Directive v-pre', function () { vm.$mount() expect(vm.$el.firstChild.tagName).toBe('VTEST') }) + + // #10087 + it('should not compile attributes', function () { + const vm = new Vue({ + template: '
A Test