@@ -151,6 +151,76 @@ describe('Options directives', () => {
151151 } ) . then ( done )
152152 } )
153153
154+ it ( 'should properly handle same node with different directive sets' , done => {
155+ const spies = { }
156+ const createSpy = name => ( spies [ name ] = jasmine . createSpy ( name ) )
157+ const vm = new Vue ( {
158+ data : {
159+ ok : true ,
160+ val : 123
161+ } ,
162+ template : `
163+ <div>
164+ <div v-if="ok" v-test="val" v-test.hi="val"></div>
165+ <div v-if="!ok" v-test.hi="val" v-test2="val"></div>
166+ </div>
167+ ` ,
168+ directives : {
169+ test : {
170+ bind : createSpy ( 'bind1' ) ,
171+ inserted : createSpy ( 'inserted1' ) ,
172+ update : createSpy ( 'update1' ) ,
173+ componentUpdated : createSpy ( 'componentUpdated1' ) ,
174+ unbind : createSpy ( 'unbind1' )
175+ } ,
176+ test2 : {
177+ bind : createSpy ( 'bind2' ) ,
178+ inserted : createSpy ( 'inserted2' ) ,
179+ update : createSpy ( 'update2' ) ,
180+ componentUpdated : createSpy ( 'componentUpdated2' ) ,
181+ unbind : createSpy ( 'unbind2' )
182+ }
183+ }
184+ } ) . $mount ( )
185+
186+ expect ( spies . bind1 . calls . count ( ) ) . toBe ( 2 )
187+ expect ( spies . inserted1 . calls . count ( ) ) . toBe ( 2 )
188+ expect ( spies . bind2 . calls . count ( ) ) . toBe ( 0 )
189+ expect ( spies . inserted2 . calls . count ( ) ) . toBe ( 0 )
190+
191+ vm . ok = false
192+ waitForUpdate ( ( ) => {
193+ // v-test with modifier should be updated
194+ expect ( spies . update1 . calls . count ( ) ) . toBe ( 1 )
195+ expect ( spies . componentUpdated1 . calls . count ( ) ) . toBe ( 1 )
196+
197+ // v-test without modifier should be unbound
198+ expect ( spies . unbind1 . calls . count ( ) ) . toBe ( 1 )
199+
200+ // v-test2 should be bound
201+ expect ( spies . bind2 . calls . count ( ) ) . toBe ( 1 )
202+ expect ( spies . inserted2 . calls . count ( ) ) . toBe ( 1 )
203+
204+ vm . ok = true
205+ } ) . then ( ( ) => {
206+ // v-test without modifier should be bound again
207+ expect ( spies . bind1 . calls . count ( ) ) . toBe ( 3 )
208+ expect ( spies . inserted1 . calls . count ( ) ) . toBe ( 3 )
209+
210+ // v-test2 should be unbound
211+ expect ( spies . unbind2 . calls . count ( ) ) . toBe ( 1 )
212+
213+ // v-test with modifier should be updated again
214+ expect ( spies . update1 . calls . count ( ) ) . toBe ( 2 )
215+ expect ( spies . componentUpdated1 . calls . count ( ) ) . toBe ( 2 )
216+
217+ vm . val = 234
218+ } ) . then ( ( ) => {
219+ expect ( spies . update1 . calls . count ( ) ) . toBe ( 4 )
220+ expect ( spies . componentUpdated1 . calls . count ( ) ) . toBe ( 4 )
221+ } ) . then ( done )
222+ } )
223+
154224 it ( 'warn non-existent' , ( ) => {
155225 new Vue ( {
156226 template : '<div v-test></div>'
0 commit comments