Skip to content

Commit

Permalink
simplify type instanceof checks, return this for chaining, see #665
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Sep 5, 2017
1 parent eafcd0f commit fc2d1cf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/nodes/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,11 @@ define( function( require ) {
*
* @param {Node} oldChild
* @param {Node} newChild
* @returns {Node} - Returns 'this' reference, for chaining
*/
replaceChild: function( oldChild, newChild ) {
assert && assert( oldChild && oldChild instanceof Node, 'child to replace must be a Node' );
assert && assert( newChild && newChild instanceof Node, 'new child must be a Node' );
assert && assert( oldChild instanceof Node, 'child to replace must be a Node' );
assert && assert( newChild instanceof Node, 'new child must be a Node' );
assert && assert( this.hasChild( oldChild ), 'Attempted to replace a node that was not a child.' );

// information that needs to be restored
Expand All @@ -919,6 +920,8 @@ define( function( require ) {
if ( oldChildFocused && newChild.focusable ) {
newChild.focus();
}

return this; // allow chaining
},

/**
Expand Down

0 comments on commit fc2d1cf

Please sign in to comment.