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 = {
66 priority : 1500 ,
77
88 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 )
2013 }
14+ } ,
2115
16+ update : function ( id ) {
17+ if ( this . id ) {
18+ this . unbind ( )
19+ }
20+ this . id = id
21+ var refs = ( this . _scope || this . vm ) . $$
2222 if ( refs . hasOwnProperty ( id ) ) {
2323 refs [ id ] = this . el
2424 } else {
@@ -27,6 +27,9 @@ module.exports = {
2727 } ,
2828
2929 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+ }
3134 }
3235}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ if (_.inBrowser) {
4343 } )
4444 } )
4545
46- it ( 'bind-el' , function ( ) {
46+ it ( 'bind-el' , function ( done ) {
4747 var vm = new Vue ( {
4848 el : el ,
4949 data : {
@@ -53,7 +53,13 @@ if (_.inBrowser) {
5353 } )
5454 expect ( vm . $$ . test ) . toBeTruthy ( )
5555 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+ } )
5763 } )
5864
5965 it ( 'with v-repeat' , function ( done ) {
You can’t perform that action at this time.
0 commit comments