@@ -119,11 +119,10 @@ Blockly.WorkspaceSvg = function(options, opt_blockDragSurface, opt_wsDragSurface
119119goog . inherits ( Blockly . WorkspaceSvg , Blockly . Workspace ) ;
120120
121121/**
122- * A wrapper function called when a resize event occurs.
123- * You can pass the result to `unbindEvent_`.
124- * @type {Array.<!Array> }
122+ * Save resize observer of the canvas in order to unobserve later in dispose
123+ * @type {ResizeObserver }
125124 */
126- Blockly . WorkspaceSvg . prototype . resizeHandlerWrapper_ = null ;
125+ Blockly . WorkspaceSvg . prototype . resizeObserver_ = null ;
127126
128127/**
129128 * The render status of an SVG workspace.
@@ -408,11 +407,11 @@ Blockly.WorkspaceSvg.prototype.getInjectionDiv = function() {
408407} ;
409408
410409/**
411- * Save resize handler data so we can delete it later in dispose.
412- * @param {!Array.<!Array> } handler Data that can be passed to unbindEvent_ .
410+ * Save resize observer so we can delete it later in dispose.
411+ * @param {ResizeObserver } observer Data to unobserve .
413412 */
414- Blockly . WorkspaceSvg . prototype . setResizeHandlerWrapper = function ( handler ) {
415- this . resizeHandlerWrapper_ = handler ;
413+ Blockly . WorkspaceSvg . prototype . setResizeObserver = function ( observer ) {
414+ this . resizeObserver_ = observer ;
416415} ;
417416
418417/**
@@ -547,9 +546,10 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
547546 // SVG is injected into (i.e. injectionDiv).
548547 goog . dom . removeNode ( this . getParentSvg ( ) . parentNode ) ;
549548 }
550- if ( this . resizeHandlerWrapper_ ) {
551- Blockly . unbindEvent_ ( this . resizeHandlerWrapper_ ) ;
552- this . resizeHandlerWrapper_ = null ;
549+
550+ if ( this . resizeObserver_ ) {
551+ this . resizeObserver_ . disconnect ( ) ;
552+ this . resizeObserver_ = null ;
553553 }
554554} ;
555555
0 commit comments