Skip to content

Commit

Permalink
Do not attach Path's shape listeners to Shapes that are immutable. See
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Sep 26, 2016
1 parent 44bbb64 commit ff21c54
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/nodes/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ define( function( require ) {

// Used as a listener to Shapes for when they are invalidated
this._invalidShapeListener = this.invalidateShape.bind( this );
// Need to record, since the Shape may be made immutable after our Path is given the Shape (don't want to leak).
this._invalidShapeListenerAttached = false;

this.initializePaintable();

Expand Down Expand Up @@ -77,8 +79,9 @@ define( function( require ) {
setShape: function( shape ) {
if ( this._shape !== shape ) {
// Remove Shape invalidation listener if applicable
if ( this._shape ) {
if ( this._invalidShapeListenerAttached ) {
this._shape.offStatic( 'invalidated', this._invalidShapeListener );
this._invalidShapeListenerAttached = false;
}

if ( typeof shape === 'string' ) {
Expand All @@ -89,8 +92,9 @@ define( function( require ) {
this.invalidateShape();

// Add Shape invalidation listener if applicable
if ( this._shape ) {
if ( this._shape && !this._shape.isImmutable() ) {
this._shape.onStatic( 'invalidated', this._invalidShapeListener );
this._invalidShapeListenerAttached = true;
}
}
return this;
Expand Down

0 comments on commit ff21c54

Please sign in to comment.