this.disposeSwitchNode = () => {
        circuitSwitch.closedProperty.unlink( closeListener );
        screenView && this.contentNode.removeInputListener( buttonListener );

        // Make sure the lifelikeNode and schematicNode are not listed as parents for their children because the children
        // (images) persist.
        lifelikeNode.dispose();
        schematicNode.dispose();
      };
Ejemplo n.º 2
0
  QUnit.test( 'click extra', assert => {

    // create a node
    const a1 = new Node( {
      tagName: 'button'
    } );
    const root = new Node( { tagName: 'div' } );
    const display = new Display( root ); // eslint-disable-line
    beforeTest( display );

    root.addChild( a1 );
    assert.ok( a1.inputListeners.length === 0, 'no input accessible listeners on instantiation' );
    assert.ok( a1.labelContent === null, 'no label on instantiation' );

    // add a listener
    const listener = { click: function() { a1.labelContent = TEST_LABEL; } };
    a1.addInputListener( listener );
    assert.ok( a1.inputListeners.length === 1, 'accessible listener added' );

    // verify added with hasInputListener
    assert.ok( a1.hasInputListener( listener ) === true, 'found with hasInputListener' );

    // fire the event
    a1.accessibleInstances[ 0 ].peer.primarySibling.click();
    assert.ok( a1.labelContent === TEST_LABEL, 'click fired, label set' );

    // remove the listener
    a1.removeInputListener( listener );
    assert.ok( a1.inputListeners.length === 0, 'accessible listener removed' );

    // verify removed with hasInputListener
    assert.ok( a1.hasInputListener( listener ) === false, 'not found with hasInputListener' );

    // make sure event listener was also removed from DOM element
    // click should not change the label
    a1.labelContent = TEST_LABEL_2;
    assert.ok( a1.labelContent === TEST_LABEL_2, 'before click' );

    // setting the label redrew the pdom, so get a reference to the new dom element.
    a1.accessibleInstances[ 0 ].peer.primarySibling.click();
    assert.ok( a1.labelContent === TEST_LABEL_2, 'click should not change label' );

    // verify disposal removes accessible input listeners
    a1.addInputListener( listener );
    a1.dispose();

    // TODO: Since converting to use Node.inputListeners, we can't assume this anymore
    // assert.ok( a1.hasInputListener( listener ) === false, 'disposal removed accessible input listeners' );
    
    afterTest( display );
  } );
Ejemplo n.º 3
0
 parent.toImage( function( image ) {
   self.imageWrappers[ i ].image = image;
   parent.dispose(); // not needed anymore, see https://github.com/phetsims/area-model-common/issues/128
 } );