diff --git a/js/display/Display.js b/js/display/Display.js index 36f0d43ba..70ec0b4a7 100644 --- a/js/display/Display.js +++ b/js/display/Display.js @@ -1792,7 +1792,7 @@ define( function( require ) { * @returns {boolean} */ Display.assertSubtreeDisposed = function( node ) { - assert && assert( !node.isDisposed(), 'Disposed nodes should not be included in a scene graph to display.' ); + assert && assert( !node.isDisposed, 'Disposed nodes should not be included in a scene graph to display.' ); if ( assert ) { for ( var i = 0; i < node.children.length; i++ ) { diff --git a/js/input/Input.js b/js/input/Input.js index 6467b0782..60bc4ffff 100644 --- a/js/input/Input.js +++ b/js/input/Input.js @@ -1563,7 +1563,7 @@ define( function( require ) { for ( var i = trail.getLastInputEnabledIndex(); i >= 0; bubbles ? i-- : i = -1 ) { var target = trail.nodes[ i ]; - if ( target.isDisposed() ) { + if ( target.isDisposed ) { continue; } diff --git a/js/nodes/Image.js b/js/nodes/Image.js index 408cbab6e..4dfa9c091 100644 --- a/js/nodes/Image.js +++ b/js/nodes/Image.js @@ -959,7 +959,7 @@ define( function( require ) { attachImageLoadListener: function() { assert && assert( !this._imageLoadListenerAttached, 'Should only be attached to one thing at a time' ); - if ( !this._isDisposed ) { + if ( !this.isDisposed ) { this._image.addEventListener( 'load', this._imageLoadListener ); this._imageLoadListenerAttached = true; } diff --git a/js/nodes/Node.js b/js/nodes/Node.js index ad85a744a..c0a382ea1 100644 --- a/js/nodes/Node.js +++ b/js/nodes/Node.js @@ -515,21 +515,6 @@ define( function( require ) { // Initialize sub-components this._picker = new Picker( this ); - // Make sure Node's prototype dispose() is called when dispose() is called, and make sure that it isn't called - // more than once. See https://github.com/phetsims/scenery/issues/601. - // @private {boolean} - this._isDisposed = false; - if ( assert ) { - // Wrap the prototype dispose method with a check. NOTE: We will not catch devious cases where the dispose() is - // overridden after the Node constructor (which may happen). - var protoDispose = this.dispose; - this.dispose = function() { - assert && assert( !this._isDisposed, 'This Node has already been disposed, and cannot be disposed again' ); - protoDispose.call( this ); - assert && assert( this._isDisposed, 'Node.dispose() call is missing from an overridden dispose method' ); - }; - } - // @public (scenery-internal) {boolean} - There are certain specific cases (in this case due to a11y) where we need // to know that a node is getting removed from its parent BUT that process has not completed yet. It would be ideal // to not need this. @@ -1892,7 +1877,7 @@ define( function( require ) { var index = _.indexOf( this._inputListeners, listener ); // ensure the listener is in our list (ignore assertion for disposal, see https://github.com/phetsims/sun/issues/394) - assert && assert( this._isDisposed || index >= 0, 'Could not find input listener to remove' ); + assert && assert( this.isDisposed || index >= 0, 'Could not find input listener to remove' ); if ( index >= 0 ) { this._inputListeners.splice( index, 1 ); this._picker.onRemoveInputListener(); @@ -4999,10 +4984,7 @@ define( function( require ) { * * @returns {boolean} */ - isDisposed: function() { - return this._isDisposed; - }, - get disposed() { return this.isDisposed(); }, + get disposed() { return this.isDisposed; }, /** * Override for extra information in the fing output (from Display.getDebugHTML()). @@ -5147,8 +5129,6 @@ define( function( require ) { * @public */ dispose: function() { - // See constructor for Node disposal checks - this._isDisposed = true; // remove all accessibility input listeners this.disposeAccessibility(); @@ -5169,7 +5149,7 @@ define( function( require ) { * techniques. */ disposeSubtree: function() { - if ( !this.isDisposed() ) { + if ( !this.isDisposed ) { // makes a copy before disposing var children = this.children; diff --git a/js/nodes/Path.js b/js/nodes/Path.js index 6c7dbd7f2..410f892b0 100644 --- a/js/nodes/Path.js +++ b/js/nodes/Path.js @@ -259,7 +259,7 @@ define( function( require ) { assert && assert( !this._invalidShapeListenerAttached, 'We do not want to have two listeners attached!' ); // Do not attach shape listeners if we are disposed - if ( !this._isDisposed ) { + if ( !this.isDisposed ) { this._shape.onStatic( 'invalidated', this._invalidShapeListener ); this._invalidShapeListenerAttached = true; }