File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1- import { replace } from '../../util/index'
1+ import { replace , getAttr } from '../../util/index'
22import Directive from '../../directive'
33import { compile , compileRoot , transclude } from '../../compiler/index'
44
@@ -49,6 +49,11 @@ export default function (Vue) {
4949 el = transclude ( el , options )
5050 this . _initElement ( el )
5151
52+ // handle v-pre on root node (#2026)
53+ if ( el . nodeType === 1 && getAttr ( el , 'v-pre' ) !== null ) {
54+ return
55+ }
56+
5257 // root is always compiled per-instance, because
5358 // container attrs and props can be different every time.
5459 var contextOptions = this . _context && this . _context . $options
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ var Vue = require('../../../../../src/index')
22
33describe ( 'v-pre' , function ( ) {
44
5+ beforeEach ( function ( ) {
6+ spyWarns ( )
7+ } )
8+
59 it ( 'should work' , function ( ) {
610 var vm = new Vue ( {
711 el : document . createElement ( 'div' ) ,
@@ -12,4 +16,17 @@ describe('v-pre', function () {
1216 } )
1317 expect ( vm . $el . firstChild . textContent ) . toBe ( '{{a}}' )
1418 } )
19+
20+ it ( 'should work on root node' , function ( ) {
21+ var vm = new Vue ( {
22+ el : document . createElement ( 'div' ) ,
23+ template : '<div v-pre>{{a}}</div>' ,
24+ replace : true ,
25+ data : {
26+ a : 123
27+ }
28+ } )
29+ expect ( vm . $el . textContent ) . toBe ( '{{a}}' )
30+ expect ( getWarnCount ( ) ) . toBe ( 0 )
31+ } )
1532} )
You can’t perform that action at this time.
0 commit comments