Skip to content

DOMElement lifecycle issues #245

Description

@gadicc
  1. Repurposing a DOMElement leaves existing/previous classes/attributes/properties intact, e.g:

    x

    or as a pseudo-test (can I submit PRs just for tests? :))

    var FamousEngine = require('famous/core/FamousEngine');
    var DOMElement = require('famous/dom-renderables/DOMElement');
    
    var scene = FamousEngine.createScene('body');
    var clock = FamousEngine.getClock();
    FamousEngine.init();
    
    var node1 = scene.addChild();
    var domElement1 = new DOMElement(node1);
    domElement1.addClass('myClass');
    
    clock.setTimeout(function() {
        // node1.removeComponent(domElement1);
        scene.removeChild(node1);
    
        var node2 = scene.addChild();
        var domElement2 = new DOMElement(node2);
        clock.setTimeout(function () {
          // fail/false in 0.5.2 -> 0.7, pass with PR#266
          console.log('test pass:', 
            !document.querySelector('[data-fa-path="body/0"]')
              .className.match(/\bmyClass\b/));
        }, 17);
    }, 17);

    Note: unnoticeable without the setTimeout.

  2. Fixed in 0.6. In DOMElement.onDismount, we recycle the element by (amongst other things), setting display: none and leaving it attached to the DOM. But the plane is still visible on WebGL animations:

    x

    at least in Chrome stable 43 and beta 44. cc: @trusktr. Confirming that display: none is set (you can see the contents and background color all disappear).

  3. Should node.removeComponent(domElement) do any of the stuff that DOMElement.onDismount does? i.e. recycle the domElement.

    What is the expected behaviour if we call removeComponent with and/or without removing the node too?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions