Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createScene on same selector as an old dismounted (but not removed) Scene -> Node is not mounted #330

Open
gadicc opened this issue Jun 23, 2015 · 8 comments
Assignees

Comments

@gadicc
Copy link

gadicc commented Jun 23, 2015

Given:

var FamousEngine = require('famous/core/FamousEngine');
var DOMElement = require('famous/dom-renderables/DOMElement');

var clock = FamousEngine.getClock();
FamousEngine.init();

var scene1 = FamousEngine.createScene('body');
scene1.dismount();

var scene2 = FamousEngine.createScene('body');

I get:

Uncaught Error: Node is not mounted
   dismount @ bundle.js:2880
   createScene @ bundle.js:1544

That's here:

FamousEngine.prototype.createScene = function createScene (selector) {
    selector = selector || 'body';

    if (this._scenes[selector]) this._scenes[selector].dismount(); // <---
    this._scenes[selector] = new Scene(selector, this);
    return this._scenes[selector];
};

So I guess the ref isn't cleaned up properly on dismount. Is this Scene.dismount()'s responsibility though? I don't recall if it's a new method or not, but calling FamousEngine.removeScene(scene1); works as expected.

@jd-carroll
Copy link
Contributor

Dismounting a scene and removing a scene are two separate things, if you are finished with a particular scene you should call removeScene. FamousEngine.createScene should either throw an error or return the existing scene when the same selector is used. My preference would be returning the existing scene.

@gadicc
Copy link
Author

gadicc commented Jun 23, 2015

Got it, thanks @jd-carroll. I remembered eventually that I was doing things that way because removeScene() didn't exist at the time, all makes sense now.

Note to others, current behaviour is to dismount an existing scene on the same selector if one exists, which fails if that Scene has already been dismounted.

@gadicc gadicc changed the title Regression: new Scene where old Scene was dismounted -> Node is not mounted createScene on same selector as an old dismounted (but not removed) Scene -> Node is not mounted Jun 23, 2015
@michaelobriena
Copy link
Member

Closing as the new removeScene functionality seems to have provided the needed functionality.

@jd-carroll
Copy link
Contributor

@michaelobriena this actually still isn't fixed.. While what you say is true the new removeScene functionality is there, #377 still blocks this

@JeremySaks
Copy link

@jd-carroll Is there a known workaround or fix for this? I'm also encountering the issue where calling createScene() on a selector where I previously called removeScene() fails to instantiate the new scene.

This is in an embedded context with routing so it's necessary to add and remove scenes frequently (in Meteor @gadicc - perhaps you have a solution as well?).

@jd-carroll
Copy link
Contributor

@michaelobriena this actually still isn't fixed.. While what you say is true the new removeScene functionality is there, #377 still blocks this

@jd-carroll
Copy link
Contributor

@JeremySaks The reason is that the Compositor still thinks there is a Scene attached to that selector so it tries to re-use that Scene. The problem is the Scene maintains a hard reference to an element which is no longer in the DOM tree.

@alexanderGugel
Copy link
Member

@jd-carroll Exactly. There simply isn't a command for that right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants