File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -199,4 +199,27 @@ describe('Directive v-bind', () => {
199199 } ) . $mount ( )
200200 expect ( 'v-bind without argument expects an Object or Array value' ) . toHaveBeenWarned ( )
201201 } )
202+
203+ // a vdom patch edge case where the user has several un-keyed elements of the
204+ // same tag next to each other, and toggling them.
205+ it ( 'properly update for toggling un-keyed children' , done => {
206+ const vm = new Vue ( {
207+ template : `
208+ <div>
209+ <div v-if="ok" id="a" data-test="1"></div>
210+ <div v-if="!ok" id="b"></div>
211+ </div>
212+ ` ,
213+ data : {
214+ ok : true
215+ }
216+ } ) . $mount ( )
217+ expect ( vm . $el . children [ 0 ] . id ) . toBe ( 'a' )
218+ expect ( vm . $el . children [ 0 ] . getAttribute ( 'data-test' ) ) . toBe ( '1' )
219+ vm . ok = false
220+ waitForUpdate ( ( ) => {
221+ expect ( vm . $el . children [ 0 ] . id ) . toBe ( 'b' )
222+ expect ( vm . $el . children [ 0 ] . getAttribute ( 'data-test' ) ) . toBe ( null )
223+ } ) . then ( done )
224+ } )
202225} )
Original file line number Diff line number Diff line change @@ -106,4 +106,25 @@ describe('Directive v-bind:class', () => {
106106 expect ( vm . $el . className ) . toBe ( 'a b' )
107107 } ) . then ( done )
108108 } )
109+
110+ // a vdom patch edge case where the user has several un-keyed elements of the
111+ // same tag next to each other, and toggling them.
112+ it ( 'properly remove staticClass for toggling un-keyed children' , done => {
113+ const vm = new Vue ( {
114+ template : `
115+ <div>
116+ <div v-if="ok" class="a"></div>
117+ <div v-if="!ok"></div>
118+ </div>
119+ ` ,
120+ data : {
121+ ok : true
122+ }
123+ } ) . $mount ( )
124+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'a' )
125+ vm . ok = false
126+ waitForUpdate ( ( ) => {
127+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( '' )
128+ } ) . then ( done )
129+ } )
109130} )
You can’t perform that action at this time.
0 commit comments