DOMElement lifecycle issues
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 249
- PR merge metrics
- No merged PRs in 30d
Description
1. Repurposing a DOMElement leaves existing/previous classes/attributes/properties intact, e.g:

or as a pseudo-test (can I submit PRs just for tests? :))
``` js
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:~~

~~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?
Contributor guide
Assessment
This issue has not been assessed yet.