@@ -14,7 +14,7 @@ import {
1414} from 'phosphor/lib/algorithm/searching' ;
1515
1616import {
17- sendMessage , Message
17+ postMessage , Message
1818} from 'phosphor/lib/core/messaging' ;
1919
2020import {
@@ -235,14 +235,7 @@ class BoxView extends DOMWidgetView {
235235 initialize ( parameters ) {
236236 super . initialize ( parameters ) ;
237237 this . children_views = new ViewList ( this . add_child_model , null , this ) ;
238- this . listenTo ( this . model , 'change:children' , ( model , value ) => {
239- this . children_views . update ( value ) . then ( ( views : DOMWidgetView [ ] ) => {
240- // Notify all children that their sizes may have changed.
241- views . forEach ( ( view ) => {
242- sendMessage ( view . pWidget , ResizeMessage . UnknownSize ) ;
243- } )
244- } ) ;
245- } ) ;
238+ this . listenTo ( this . model , 'change:children' , this . update_children ) ;
246239 this . listenTo ( this . model , 'change:box_style' , this . update_box_style ) ;
247240
248241 this . pWidget . addClass ( 'jupyter-widgets' ) ;
@@ -255,10 +248,18 @@ class BoxView extends DOMWidgetView {
255248 */
256249 render ( ) {
257250 super . render ( ) ;
258- this . children_views . update ( this . model . get ( 'children' ) ) ;
251+ this . update_children ( ) ;
259252 this . set_box_style ( ) ;
260253 }
261254
255+ update_children ( ) {
256+ this . children_views . update ( this . model . get ( 'children' ) ) . then ( ( views : DOMWidgetView [ ] ) => {
257+ // Notify all children that their sizes may have changed.
258+ views . forEach ( ( view ) => {
259+ postMessage ( view . pWidget , ResizeMessage . UnknownSize ) ;
260+ } ) ;
261+ } ) ;
262+ }
262263 update_box_style ( ) {
263264 this . update_mapped_classes ( BoxView . class_map , 'box_style' ) ;
264265 }
0 commit comments