@@ -417,61 +417,63 @@ describe('render()', () => {
417
417
} ) ;
418
418
} ) ;
419
419
420
- it ( 'should support dangerouslySetInnerHTML' , ( ) => {
421
- let html = '<b>foo & bar</b>' ;
422
- // eslint-disable-next-line react/no-danger
423
- let root = render ( < div dangerouslySetInnerHTML = { { __html : html } } /> , scratch ) ;
420
+ describe ( 'dangerouslySetInnerHTML' , ( ) => {
421
+ it ( 'should support dangerouslySetInnerHTML' , ( ) => {
422
+ let html = '<b>foo & bar</b>' ;
423
+ // eslint-disable-next-line react/no-danger
424
+ let root = render ( < div dangerouslySetInnerHTML = { { __html : html } } /> , scratch ) ;
424
425
425
- expect ( scratch . firstChild , 'set' ) . to . have . property ( 'innerHTML' , html ) ;
426
- expect ( scratch . innerHTML ) . to . equal ( '<div>' + html + '</div>' ) ;
426
+ expect ( scratch . firstChild , 'set' ) . to . have . property ( 'innerHTML' , html ) ;
427
+ expect ( scratch . innerHTML ) . to . equal ( '<div>' + html + '</div>' ) ;
427
428
428
- root = render ( < div > a< strong > b</ strong > </ div > , scratch , root ) ;
429
+ root = render ( < div > a< strong > b</ strong > </ div > , scratch , root ) ;
429
430
430
- expect ( scratch , 'unset' ) . to . have . property ( 'innerHTML' , `<div>a<strong>b</strong></div>` ) ;
431
+ expect ( scratch , 'unset' ) . to . have . property ( 'innerHTML' , `<div>a<strong>b</strong></div>` ) ;
431
432
432
- // eslint-disable-next-line react/no-danger
433
- render ( < div dangerouslySetInnerHTML = { { __html : html } } /> , scratch , root ) ;
433
+ // eslint-disable-next-line react/no-danger
434
+ render ( < div dangerouslySetInnerHTML = { { __html : html } } /> , scratch , root ) ;
434
435
435
- expect ( scratch . innerHTML , 're-set' ) . to . equal ( '<div>' + html + '</div>' ) ;
436
- } ) ;
436
+ expect ( scratch . innerHTML , 're-set' ) . to . equal ( '<div>' + html + '</div>' ) ;
437
+ } ) ;
437
438
438
- it ( 'should apply proper mutation for VNodes with dangerouslySetInnerHTML attr' , ( ) => {
439
- class Thing extends Component {
440
- constructor ( props , context ) {
441
- super ( props , context ) ;
442
- this . state . html = this . props . html ;
439
+ it ( 'should apply proper mutation for VNodes with dangerouslySetInnerHTML attr' , ( ) => {
440
+ class Thing extends Component {
441
+ constructor ( props , context ) {
442
+ super ( props , context ) ;
443
+ this . state . html = this . props . html ;
444
+ }
445
+ render ( props , { html } ) {
446
+ // eslint-disable-next-line react/no-danger
447
+ return html ? < div dangerouslySetInnerHTML = { { __html : html } } /> : < div /> ;
448
+ }
443
449
}
444
- render ( props , { html } ) {
445
- // eslint-disable-next-line react/no-danger
446
- return html ? < div dangerouslySetInnerHTML = { { __html : html } } /> : < div /> ;
447
- }
448
- }
449
450
450
- let thing ;
451
+ let thing ;
451
452
452
- render ( < Thing ref = { c => thing = c } html = "<b><i>test</i></b>" /> , scratch ) ;
453
+ render ( < Thing ref = { c => thing = c } html = "<b><i>test</i></b>" /> , scratch ) ;
453
454
454
- expect ( scratch . innerHTML ) . to . equal ( '<div><b><i>test</i></b></div>' ) ;
455
+ expect ( scratch . innerHTML ) . to . equal ( '<div><b><i>test</i></b></div>' ) ;
455
456
456
- thing . setState ( { html : false } ) ;
457
- thing . forceUpdate ( ) ;
457
+ thing . setState ( { html : false } ) ;
458
+ thing . forceUpdate ( ) ;
458
459
459
- expect ( scratch . innerHTML ) . to . equal ( '<div></div>' ) ;
460
+ expect ( scratch . innerHTML ) . to . equal ( '<div></div>' ) ;
460
461
461
- thing . setState ( { html : '<foo><bar>test</bar></foo>' } ) ;
462
- thing . forceUpdate ( ) ;
462
+ thing . setState ( { html : '<foo><bar>test</bar></foo>' } ) ;
463
+ thing . forceUpdate ( ) ;
463
464
464
- expect ( scratch . innerHTML ) . to . equal ( '<div><foo><bar>test</bar></foo></div>' ) ;
465
- } ) ;
465
+ expect ( scratch . innerHTML ) . to . equal ( '<div><foo><bar>test</bar></foo></div>' ) ;
466
+ } ) ;
466
467
467
- it ( 'should hydrate with dangerouslySetInnerHTML' , ( ) => {
468
- let html = '<b>foo & bar</b>' ;
469
- scratch . innerHTML = `<div>${ html } </div>` ;
470
- // eslint-disable-next-line react/no-danger
471
- render ( < div dangerouslySetInnerHTML = { { __html : html } } /> , scratch , scratch . lastChild ) ;
468
+ it ( 'should hydrate with dangerouslySetInnerHTML' , ( ) => {
469
+ let html = '<b>foo & bar</b>' ;
470
+ scratch . innerHTML = `<div>${ html } </div>` ;
471
+ // eslint-disable-next-line react/no-danger
472
+ render ( < div dangerouslySetInnerHTML = { { __html : html } } /> , scratch , scratch . lastChild ) ;
472
473
473
- expect ( scratch . firstChild ) . to . have . property ( 'innerHTML' , html ) ;
474
- expect ( scratch . innerHTML ) . to . equal ( `<div>${ html } </div>` ) ;
474
+ expect ( scratch . firstChild ) . to . have . property ( 'innerHTML' , html ) ;
475
+ expect ( scratch . innerHTML ) . to . equal ( `<div>${ html } </div>` ) ;
476
+ } ) ;
475
477
} ) ;
476
478
477
479
it ( 'should reconcile mutated DOM attributes' , ( ) => {
0 commit comments