File tree Expand file tree Collapse file tree 2 files changed +23
-14
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -6,19 +6,19 @@ module.exports = {
6
6
priority : 1500 ,
7
7
8
8
bind : function ( ) {
9
- var scope = this . _scope || this . vm
10
- var refs = scope . $$
11
- var id = this . id = this . arg // bind-el ?
12
- ? scope . $eval ( this . expression )
13
- : this . expression
14
-
15
- if ( process . env . NODE_ENV !== 'production' && this . arg ) {
16
- _ . log (
17
- 'You are using bind- syntax on "el", which is a special ' +
18
- 'attribute. It will be evaluated only once.'
19
- )
9
+ if ( this . arg ) {
10
+ this . _isDynamicLiteral = true
11
+ } else {
12
+ this . update ( this . expression )
20
13
}
14
+ } ,
21
15
16
+ update : function ( id ) {
17
+ if ( this . id ) {
18
+ this . unbind ( )
19
+ }
20
+ this . id = id
21
+ var refs = ( this . _scope || this . vm ) . $$
22
22
if ( refs . hasOwnProperty ( id ) ) {
23
23
refs [ id ] = this . el
24
24
} else {
@@ -27,6 +27,9 @@ module.exports = {
27
27
} ,
28
28
29
29
unbind : function ( ) {
30
- ( this . _scope || this . vm ) . $$ [ this . id ] = null
30
+ var refs = ( this . _scope || this . vm ) . $$
31
+ if ( refs [ this . id ] === this . el ) {
32
+ refs [ this . id ] = null
33
+ }
31
34
}
32
35
}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ if (_.inBrowser) {
43
43
} )
44
44
} )
45
45
46
- it ( 'bind-el' , function ( ) {
46
+ it ( 'bind-el' , function ( done ) {
47
47
var vm = new Vue ( {
48
48
el : el ,
49
49
data : {
@@ -53,7 +53,13 @@ if (_.inBrowser) {
53
53
} )
54
54
expect ( vm . $$ . test ) . toBeTruthy ( )
55
55
expect ( vm . $$ . test . id ) . toBe ( 'test' )
56
- expect ( _ . log ) . toHaveBeenCalled ( )
56
+ vm . id = 'changed'
57
+ _ . nextTick ( function ( ) {
58
+ expect ( vm . $$ . test ) . toBeNull ( )
59
+ expect ( vm . $$ . changed ) . toBeTruthy ( )
60
+ expect ( vm . $$ . changed . id ) . toBe ( 'test' )
61
+ done ( )
62
+ } )
57
63
} )
58
64
59
65
it ( 'with v-repeat' , function ( done ) {
You can’t perform that action at this time.
0 commit comments