should not skip onLoad when previous sibling node is deactivated

This commit is contained in:
Jare Guo
2017-05-05 18:07:02 +08:00
parent 2410a7a4ba
commit 830b51d9bd
3 changed files with 17 additions and 9 deletions
+1 -5
View File
@@ -66,12 +66,8 @@ function createActivateTask () {
for (iterator.i = 0; iterator.i < array.length; ++iterator.i) {
let comp = array[iterator.i];
callOnLoadInTryCatch(comp);
if (!comp.node._activeInHierarchy) {
// deactivated during onLoad
break;
}
}
} : CompScheduler.createInvokeImpl('c.onLoad();if(!c.node._activeInHierarchy)break;');
} : CompScheduler.createInvokeImpl('c.onLoad();');
return {
preload: new UnsortedInvoker(invokePreload),
onLoad: new CompScheduler.OneOffInvoker(invokeOnLoad),
+1 -2
View File
@@ -179,8 +179,7 @@ function defineGetSet (cls, name, propName, val, es6) {
var attrs = parseAttributes(cls, val, name, propName, true);
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
Attr.attr(cls, propName, attr);
Attr.attr(cls, propName, attrs[i]);
}
attrs.length = 0;
@@ -201,7 +201,15 @@ test('disable component during onEnable', function () {
}
test('could deactivate self node in onLoad', function () {
var node = new cc.Node();
var nodes = createNodes({
node: {
},
sibling: {
comps: cc.Component,
}
});
var node = nodes.node;
var previousComp = createOnlyOnLoadComp(node, 'previous');
@@ -224,11 +232,16 @@ test('disable component during onEnable', function () {
}
node.runAction(cc.delayTime(0));
cc.director.getScene().addChild(node);
var siblingComp = nodes.siblingComps[0];
siblingComp.onLoad = new Callback().enable();
cc.director.getScene().addChild(nodes.root);
strictEqual(node.active, false, 'node should be deactivated');
strictEqual(cc.director.getActionManager().isTargetPaused_TEST(node), true, 'action should be paused');
previousComp.onLoad.once('onLoad of previous component should be called').disable();
siblingComp.onLoad.once('onLoad of sibling node should still be called');
if (StillInvokeRestCompsOnSameNode) {
compShouldBeActivated(restComp, 'rest');