@@ -218,4 +218,75 @@ describe('hot module replacement', () => {
218
218
rerender ( parentId , compileToFunction ( `<Child msg="bar" />` ) )
219
219
expect ( serializeInner ( root ) ) . toBe ( `<div>bar</div>` )
220
220
} )
221
+
222
+ // #1305 - component should remove class
223
+ test ( 'remove static class from parent' , ( ) => {
224
+ const root = nodeOps . createElement ( 'div' )
225
+ const parentId = 'test-force-class-parent'
226
+ const childId = 'test-force-class-child'
227
+
228
+ const Child : ComponentOptions = {
229
+ __hmrId : childId ,
230
+ render : compileToFunction ( `<div>child</div>` )
231
+ }
232
+ createRecord ( childId , Child )
233
+
234
+ const Parent : ComponentOptions = {
235
+ __hmrId : parentId ,
236
+ components : { Child } ,
237
+ render : compileToFunction ( `<Child class="test" />` )
238
+ }
239
+ createRecord ( parentId , Parent )
240
+
241
+ render ( h ( Parent ) , root )
242
+ expect ( serializeInner ( root ) ) . toBe ( `<div class="test">child</div>` )
243
+
244
+ rerender ( parentId , compileToFunction ( `<Child/>` ) )
245
+ expect ( serializeInner ( root ) ) . toBe ( `<div>child</div>` )
246
+ } )
247
+
248
+ test ( 'rerender if any parent in the parent chain' , ( ) => {
249
+ const root = nodeOps . createElement ( 'div' )
250
+ const parent = 'test-force-props-parent-'
251
+ const childId = 'test-force-props-child'
252
+
253
+ const numberOfParents = 5
254
+
255
+ const Child : ComponentOptions = {
256
+ __hmrId : childId ,
257
+ render : compileToFunction ( `<div>child</div>` )
258
+ }
259
+ createRecord ( childId , Child )
260
+
261
+ const components : ComponentOptions [ ] = [ ]
262
+
263
+ for ( let i = 0 ; i < numberOfParents ; i ++ ) {
264
+ const parentId = `${ parent } ${ i } `
265
+ const parentComp : ComponentOptions = {
266
+ __hmrId : parentId
267
+ }
268
+ components . push ( parentComp )
269
+ if ( i === 0 ) {
270
+ parentComp . render = compileToFunction ( `<Child />` )
271
+ parentComp . components = {
272
+ Child
273
+ }
274
+ } else {
275
+ parentComp . render = compileToFunction ( `<Parent />` )
276
+ parentComp . components = {
277
+ Parent : components [ i - 1 ]
278
+ }
279
+ }
280
+
281
+ createRecord ( parentId , parentComp )
282
+ }
283
+
284
+ const last = components [ components . length - 1 ]
285
+
286
+ render ( h ( last ) , root )
287
+ expect ( serializeInner ( root ) ) . toBe ( `<div>child</div>` )
288
+
289
+ rerender ( last . __hmrId ! , compileToFunction ( `<Parent class="test"/>` ) )
290
+ expect ( serializeInner ( root ) ) . toBe ( `<div class="test">child</div>` )
291
+ } )
221
292
} )
0 commit comments