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'
2
2
import Directive from '../../directive'
3
3
import { compile , compileRoot , transclude } from '../../compiler/index'
4
4
@@ -49,6 +49,11 @@ export default function (Vue) {
49
49
el = transclude ( el , options )
50
50
this . _initElement ( el )
51
51
52
+ // handle v-pre on root node (#2026)
53
+ if ( el . nodeType === 1 && getAttr ( el , 'v-pre' ) !== null ) {
54
+ return
55
+ }
10B6A
56
+
52
57
// root is always compiled per-instance, because
53
58
// container attrs and props can be different every time.
54
59
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')
2
2
3
3
describe ( 'v-pre' , function ( ) {
4
4
5
+ beforeEach ( function ( ) {
6
+ spyWarns ( )
7
+ } )
8
+
5
9
it ( 'should work' , function ( ) {
6
10
var vm = new Vue ( {
7
11
el : document . createElement ( 'div' ) ,
@@ -12,4 +16,17 @@ describe('v-pre', function () {
12
16
} )
13
17
expect ( vm . $el . firstChild . textContent ) . toBe ( '{{a}}' )
14
18
} )
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
+ } )
15
32
} )
You can’t perform that action at this time.
0 commit comments