From 6033292369fe8e669bdf3a200d2c1bd408a296be Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Fri, 8 Apr 2016 17:27:01 +0800 Subject: [PATCH 1/2] should be able to deactivate self during onLoad --- cocos2d/core/CCNode.js | 56 +++++-- cocos2d/core/components/CCComponent.js | 92 +++-------- cocos2d/core/platform/CCObject.js | 6 +- test/qunit/unit/test-component.js | 154 ------------------- test/qunit/unit/test-node.js | 204 ++++++++++++++++++++++++- 5 files changed, 272 insertions(+), 240 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 0381ec1363..5a35660e2e 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -30,6 +30,7 @@ var JS = cc.js; var Flags = cc.Object.Flags; var Destroying = Flags.Destroying; var DontDestroy = Flags.DontDestroy; +var Activating = Flags.Activating; //var RegisteredInEditor = Flags.RegisteredInEditor; /** @@ -847,6 +848,20 @@ var Node = cc.Class({ }, _onActivatedInHierarchy: function (newActive) { + var cancelActivation = false; + if (this._objFlags & Activating) { + if (newActive) { + cc.error('Node "%s" is already activating', this.name); + return; + } + else { + cancelActivation = true; + } + } + else if (newActive) { + this._objFlags |= Activating; + } + this._activeInHierarchy = newActive; // component maybe added during onEnable, and the onEnable of new component is already called @@ -854,42 +869,63 @@ var Node = cc.Class({ var originCount = this._components.length; for (var c = 0; c < originCount; ++c) { var component = this._components[c]; - if ( !(component instanceof cc.Component) ) { + if (component instanceof cc.Component) { + component.__onNodeActivated(newActive); + if (newActive && !this._activeInHierarchy) { + // deactivated during activating + this._objFlags &= ~Activating; + return; + } + } + else { if (CC_EDITOR) { - cc.error('Sorry, the component of "%s" which with an index of %s is corrupted! It has been removed.', this.name, c); + cc.error('Sorry, the component of "%s" which with an index of %s is corrupted! It has been removed.', + this.name, c); console.log('Corrupted component value:', component); } if (component) { this._removeComponent(component); } else { - this._components.splice(c, 1); + JS.array.removeAt(this._components, c); } --c; --originCount; } - else { - component.__onNodeActivated(newActive); - } } + // activate children recursively - for (var i = 0, len = this.childrenCount; i < len; ++i) { + for (var i = 0, len = this._children.length; i < len; ++i) { var child = this._children[i]; if (child._active) { child._onActivatedInHierarchy(newActive); + if (newActive && !this._activeInHierarchy) { + // deactivated during activating + this._objFlags &= ~Activating; + return; + } } } - // activate or desactivate ActionManager, EventManager - // Activate + + if (cancelActivation) { + this._objFlags &= ~Activating; + return; + } + + // ActionManager, EventManager if (newActive) { + // activate cc.director.getActionManager().resumeTarget(this); cc.eventManager.resumeTarget(this); } - // Desactivate else { + // deactivate cc.director.getActionManager().pauseTarget(this); cc.eventManager.pauseTarget(this); } + + // + this._objFlags &= ~Activating; }, _onHierarchyChanged: function (oldParent) { diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index e4de6e5000..526b8894cf 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -75,6 +75,11 @@ function callOnEnable (self, enable) { } } + var deactivatedDuringOnEnable = !self.node._activeInHierarchy; + if (deactivatedDuringOnEnable) { + return; + } + cc.director.getScheduler().resumeTarget(self); _registerEvent(self, true); @@ -520,75 +525,6 @@ var Component = cc.Class({ return this.node.getComponentsInChildren(typeOrClassName); }, - ///** - // * Invokes the method on this component after a specified delay. - // * The method will be invoked even if this component is disabled, but will not invoked if this component is - // * destroyed. - // * - // * @method invoke - // * @param {function|string} functionOrMethodName - // * @param {number} [delay=0] - The number of seconds that the function call should be delayed by. If omitted, it defaults to 0. The actual delay may be longer. - // * @return {number} - Will returns a new InvokeID if the functionOrMethodName is type function. InvokeID is the numerical ID of the invoke, which can be used later with cancelInvoke(). - // * @example {@link examples/Fire/Component/invoke.js } - // */ - //invoke: createInvoker(Timer.setTimeout, Timer.setTimeoutWithKey, 'invoke'), - // - ///** - // * Invokes the method on this component repeatedly, with a fixed time delay between each call. - // * The method will be invoked even if this component is disabled, but will not invoked if this component is - // * destroyed. - // * - // * @method repeat - // * @param {function|string} functionOrMethodName - // * @param {number} [delay=0] - The number of seconds that the function call should wait before each call to the method. If omitted, it defaults to 0. The actual delay may be longer. - // * @return {number} - Will returns a new RepeatID if the method is type function. RepeatID is the numerical ID of the repeat, which can be used later with cancelRepeat(). - // * @example {@link examples/Fire/Component/repeat.js} - // */ - //repeat: createInvoker(Timer.setInterval, Timer.setIntervalWithKey, 'repeat'), - // - ///** - // * Cancels previous invoke calls with methodName or InvokeID on this component. - // * When using methodName, all calls with the same methodName will be canceled. - // * InvokeID is the identifier of the invoke action you want to cancel, as returned by invoke(). - // * - // * @method cancelInvoke - // * @param {string|number} methodNameOrInvokeId - // * @example {@link examples/Fire/Component/cancelInvoke.js} - // */ - //cancelInvoke: function (methodNameOrInvokeId) { - // if (typeof methodNameOrInvokeId === 'string') { - // var key = this.id + '.' + methodNameOrInvokeId; - // Timer.clearTimeoutByKey(key); - // } - // else { - // Timer.clearTimeout(methodNameOrInvokeId); - // } - //}, - // - ///** - // * Cancels previous repeat calls with methodName or RepeatID on this component. - // * When using methodName, all calls with the same methodName will be canceled. - // * RepeatID is the identifier of the repeat action you want to cancel, as returned by repeat(). - // * - // * @method cancelRepeat - // * @param {string|number} methodNameOrRepeatId - // * @example {@link examples/Fire/Component/cancelRepeat.js} - // */ - //cancelRepeat: function (methodNameOrRepeatId) { - // if (typeof methodNameOrRepeatId === 'string') { - // var key = this.id + '.' + methodNameOrRepeatId; - // Timer.clearIntervalByKey(key); - // } - // else { - // Timer.clearInterval(methodNameOrRepeatId); - // } - //}, - // - //isInvoking: function (methodName) { - // var key = this.id + '.' + methodName; - // return Timer.hasTimeoutKey(key); - //}, - // VIRTUAL /** @@ -665,7 +601,7 @@ var Component = cc.Class({ }, __onNodeActivated: CC_EDITOR ? function (active) { - if (!(this._objFlags & IsOnLoadStarted) && + if (active && !(this._objFlags & IsOnLoadStarted) && (cc.engine._isPlaying || this.constructor._executeInEditMode)) { this._objFlags |= IsOnLoadStarted; @@ -688,20 +624,30 @@ var Component = cc.Class({ _Scene.AssetsWatcher.start(this); } } - if (this._enabled) { + if (active) { + var deactivatedOnLoading = !this.node._activeInHierarchy; + if (deactivatedOnLoading) { + return; + } + } callOnEnable(this, active); } } : function (active) { - if (!(this._objFlags & IsOnLoadStarted)) { + if (active && !(this._objFlags & IsOnLoadStarted)) { this._objFlags |= IsOnLoadStarted; if (this.onLoad) { this.onLoad(); } this._objFlags |= IsOnLoadCalled; } - if (this._enabled) { + if (active) { + var deactivatedOnLoading = !this.node._activeInHierarchy; + if (deactivatedOnLoading) { + return; + } + } callOnEnable(this, active); } }, diff --git a/cocos2d/core/platform/CCObject.js b/cocos2d/core/platform/CCObject.js index fcb356c59f..ead5ff6208 100644 --- a/cocos2d/core/platform/CCObject.js +++ b/cocos2d/core/platform/CCObject.js @@ -5,10 +5,11 @@ var JS = require('./js'); var Destroyed = 1 << 0; var ToDestroy = 1 << 1; var DontSave = 1 << 2; -var EditorOnly = 1 << 3; +var EditorOnly = 1 << 3; var Dirty = 1 << 4; var DontDestroy = 1 << 5; var Destroying = 1 << 6; +var Activating = 1 << 7; //var RegisteredInEditor = 1 << 8; var HideInGame = 1 << 9; var HideInEditor = 1 << 10; @@ -26,7 +27,7 @@ var IsPositionLocked = 1 << 20; var Hide = HideInGame | HideInEditor; // should not clone or serialize these flags -var PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy | +var PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy | Activating | IsOnEnableCalled | IsOnLoadStarted | IsOnLoadCalled | IsOnStartCalled /*RegisteredInEditor*/); @@ -93,6 +94,7 @@ CCObject.Flags = { // FLAGS FOR ENGINE Destroying: Destroying, + Activating: Activating, /** * !#en diff --git a/test/qunit/unit/test-component.js b/test/qunit/unit/test-component.js index f2a22b025d..54c92348a3 100644 --- a/test/qunit/unit/test-component.js +++ b/test/qunit/unit/test-component.js @@ -66,157 +66,3 @@ test('should not cause an infinite loops if re-activated in onLoad', function () // var comp = parent.addComponent(Comp); // comp.stopTest(); //}); - -//asyncTest('invoke using name', function () { -// var cb = new Callback().setDisabledMessage('method should not invokes in this frame'); -// var cb2 = new Callback().disable('method should not being called after destroyed'); -// -// var MyComp = Fire.Class({ -// extends: Component, -// onLoad: function () { -// this.invoke('myCallback', 0.001); -// }, -// myCallback: cb, -// callback2: cb2 -// }); -// cc.executeInEditMode(MyComp); -// -// var ent = new cc.Node(); -// var comp = ent.addComponent(MyComp); -// -// cb.enable(); -// setTimeout(function () { -// cb.once('method should being invoked'); -// -// comp.invoke('callback2', 0); -// comp.destroy(); -// FO._deferredDestroy(); -// -// setTimeout(function () { -// start(); -// }, 1); -// }, 0.001 * 1000); -//}); -// -//asyncTest('cancel invoke using name', 0, function () { -// var cb1 = new Callback().disable('method 1 should not invoked if canceled'); -// -// var MyComp = Fire.Class({ -// extends: Component, -// myCallback1: cb1, -// }); -// cc.executeInEditMode(MyComp); -// var ent = new cc.Node(); -// var comp = ent.addComponent(MyComp); -// -// comp.invoke('myCallback1', 0.001); -// comp.invoke('myCallback1', 0.001); -// -// comp.cancelInvoke('myCallback1'); -// -// setTimeout(start, 0.001 * 1000); -//}); -// -//asyncTest('invoke using function', function () { -// var cb = new Callback().setDisabledMessage('method should not invokes in this frame'); -// var cb2 = new Callback().disable('method should not being called after destroyed'); -// -// var MyComp = Fire.Class({ -// extends: Component, -// onLoad: function () { -// this.invoke(this.myCallback, 0.001); -// }, -// myCallback: cb, -// callback2: cb2 -// }); -// cc.executeInEditMode(MyComp); -// -// var ent = new cc.Node(); -// var comp = ent.addComponent(MyComp); -// -// cb.enable(); -// setTimeout(function () { -// cb.once('method should being invoked'); -// -// comp.invoke(comp.callback2, 0); -// comp.destroy(); -// FO._deferredDestroy(); -// -// setTimeout(function () { -// start(); -// }, 1); -// }, 0.001 * 1000); -//}); -// -//asyncTest('cancel invoke using id', 0, function () { -// var cb1 = new Callback().disable('method 1 should not invoked if canceled'); -// -// var MyComp = Fire.Class({ -// extends: Component, -// myCallback1: cb1, -// }); -// cc.executeInEditMode(MyComp); -// var ent = new cc.Node(); -// var comp = ent.addComponent(MyComp); -// -// var id1 = comp.invoke(comp.myCallback1, 0.001); -// comp.cancelInvoke(id1); -// -// setTimeout(start, 0.001 * 1000); -//}); -// -//asyncTest('repeat using name', function () { -// var cb = new Callback(function () { -// if (cb.calledCount > 1) { -// ok(true, 'method should being invoked repeatedly'); -// cb.disable(); -// comp.cancelRepeat('myCallback'); -// clearTimeout(stopId); -// start(); -// } -// }).enable(); -// -// var MyComp = Fire.Class({ -// extends: Component, -// myCallback: cb, -// }); -// cc.executeInEditMode(MyComp); -// -// var ent = new cc.Node(); -// var comp = ent.addComponent(MyComp); -// -// comp.repeat('myCallback', 0); -// -// var stopId = setTimeout(function () { -// ok(false, 'Timeout: method should being invoked repeatedly'); -// start(); -// }, 100); -//}); -// -//asyncTest('repeat using function', function () { -// var cb = new Callback(function () { -// if (cb.calledCount > 1) { -// ok(true, 'method should being invoked repeatedly'); -// cb.disable(); -// comp.cancelRepeat(repeatId); -// clearTimeout(stopId); -// start(); -// } -// }).enable(); -// -// var MyComp = Fire.Class({ -// extends: Component, -// myCallback: cb, -// }); -// cc.executeInEditMode(MyComp); -// -// var ent = new cc.Node(); -// var comp = ent.addComponent(MyComp); -// -// var repeatId = comp.repeat(cb, 0); -// -// var stopId = setTimeout(function () { -// ok(false, 'Timeout: method should being invoked repeatedly'); -// start(); -// }, 100); -//}); diff --git a/test/qunit/unit/test-node.js b/test/qunit/unit/test-node.js index 3f36de982d..06cfc076ce 100644 --- a/test/qunit/unit/test-node.js +++ b/test/qunit/unit/test-node.js @@ -260,7 +260,7 @@ test('life cycle logic for component', function () { this._assert(CallbackTester.OnEnable); comp.notExpect(CallbackTester.OnEnable, 'onEnable should only be called once'); this.enabled = true; - } + }; comp.expect(CallbackTester.OnEnable, 'onEnable should be called once after entity active'); obj.active = true; @@ -315,6 +315,208 @@ test('activation logic for component in hierarchy', function () { comp.stopTest(); }); +(function () { + + var StillInvokeRestCompsOnSameNode = false; + var StillInvokeOnEnableOnSameComp = false; + if (StillInvokeRestCompsOnSameNode) { + strictEqual(StillInvokeOnEnableOnSameComp, true); + } + + function createNormalComp (node) { + var comp = node.addComponent(cc.Component); + comp.onLoad = new Callback().enable(); + comp.onEnable = new Callback(function () { + this.onDisable.enable(); + }).enable(); + comp.onDisable = new Callback().disable('onDisable should called after onEnable'); + comp.update = new Callback().disable('all update should not be called (deactivated)'); + return comp; + } + + function createDisabledComp (node, name) { + var comp = node.addComponent(cc.Component); + comp.onLoad = new Callback().disable('onLoad of ' + name + ' component should not be called (deactivated)'); + comp.onEnable = new Callback().disable('onEnable of ' + name + ' component should not be called (deactivated)'); + comp.update = new Callback().disable('update of ' + name + ' component should not be called (deactivated)'); + return comp; + } + + function compShouldBeActivated (comp, name) { + comp.onLoad.once('onLoad of ' + name + ' component should be called').disable(); + comp.onEnable.once('onEnable of ' + name + ' component should be called').disable(); + comp.onDisable.once('onDisable of ' + name + ' component should be called').disable(); + } + + test('could deactivate self node in onLoad', function () { + var node = new cc.Node(); + + var previousComp = createNormalComp(node); + + var testComp = node.addComponent(cc.Component); + testComp.onLoad = function () { + this.node.active = false; + }; + if (StillInvokeOnEnableOnSameComp) { + testComp.onEnable = new Callback(function () { + this.onDisable.enable(); + }).enable(); + testComp.onDisable = new Callback().disable('onDisable should called after onEnable'); + } + else { + testComp.onEnable = new Callback().disable( + 'onEnable of testing component should not be called (deactivated)'); + testComp.onDisable = new Callback().disable( + 'onDisable of testing component should not be called (deactivated)'); + } + testComp.update = new Callback().disable('update of testing component should not be called (deactivated)'); + + var restComp; + if (StillInvokeRestCompsOnSameNode) { + restComp = createNormalComp(node); + } + else { + restComp = createDisabledComp(node, 'rest'); + } + + var child = new cc.Node(); + createDisabledComp(child, 'child'); + + cc.director.getScene().addChild(node); + + strictEqual(node.active, false, 'node should be deactivated'); + compShouldBeActivated(previousComp, 'previous'); + + if (StillInvokeOnEnableOnSameComp) { + testComp.onEnable.once('onEnable of test component should still be called').disable(); + testComp.onDisable.once('onDisable of test component should still be called').disable(); + } + + if (StillInvokeRestCompsOnSameNode) { + compShouldBeActivated(restComp, 'rest'); + } + + cc.game.step(); + }); + + test('could deactivate parent in onLoad', function () { + strictEqual(StillInvokeRestCompsOnSameNode, false, 'test cases not implemented if "StillInvokeRestCompsOnSameNode"'); + strictEqual(StillInvokeOnEnableOnSameComp, false, 'test cases not implemented if "StillInvokeOnEnableOnSameComp"'); + + var parent = new cc.Node(); + var prevNode = new cc.Node(); + var node = new cc.Node(); + var nextNode = new cc.Node(); + parent.addChild(prevNode); + parent.addChild(node); + parent.addChild(nextNode); + var child = new cc.Node(); + node.addChild(child); + + // init parent + var compOfParent = createNormalComp(parent); + + // init prevNode + var compOfPrevNode = createNormalComp(prevNode); + + // init nextNode + var compOfNextNode = createDisabledComp(nextNode, 'next node\'s'); + + // init node + + var previousComp = createNormalComp(node); + + var testComp = node.addComponent(cc.Component); + testComp.onLoad = function () { + // deactivate parent + parent.active = false; + }; + if (StillInvokeOnEnableOnSameComp) { + testComp.onEnable = new Callback(function () { + this.onDisable.enable(); + }).enable(); + testComp.onDisable = new Callback().disable('onDisable should called after onEnable'); + } + else { + testComp.onEnable = new Callback().disable( + 'onEnable of testing component should not be called (deactivated)'); + testComp.onDisable = new Callback().disable( + 'onDisable of testing component should not be called (deactivated)'); + } + testComp.update = new Callback().disable('update of testing component should not be called (deactivated)'); + + var restComp; + if (StillInvokeRestCompsOnSameNode) { + restComp = createNormalComp(node); + } + else { + restComp = createDisabledComp(node, 'rest'); + } + + // init child + createDisabledComp(child, 'child'); + + // ACTIVATE + cc.director.getScene().addChild(parent); + + // test + + strictEqual(parent.active, false, 'parent should be deactivated'); + strictEqual(node.active, true, 'node should be deactivated'); + compShouldBeActivated(compOfParent, 'parent node\'s'); + compShouldBeActivated(compOfPrevNode, 'previous node\'s'); + compShouldBeActivated(previousComp, 'previous'); + + if (StillInvokeOnEnableOnSameComp) { + testComp.onEnable.once('onEnable of test component should still be called').disable(); + testComp.onDisable.once('onDisable of test component should still be called').disable(); + } + + if (StillInvokeRestCompsOnSameNode) { + compShouldBeActivated(restComp, 'rest'); + } + + cc.game.step(); + }); + + test('could deactivate self node in onEnable', function () { + var node = new cc.Node(); + + var previousComp = createNormalComp(node); + + var testComp = node.addComponent(cc.Component); + testComp.onEnable = new Callback(function () { + this.node.active = false; + }).enable(); + + testComp.update = new Callback().disable('update of testing component should not be called (deactivated)'); + + var restComp; + if (StillInvokeRestCompsOnSameNode) { + restComp = createNormalComp(node); + } + else { + restComp = createDisabledComp(node, 'rest'); + } + + var child = new cc.Node(); + createDisabledComp(child, 'child'); + + cc.director.getScene().addChild(node); + + strictEqual(node.active, false, 'node should be deactivated'); + compShouldBeActivated(previousComp, 'previous'); + + testComp.onEnable.once('onEnable of test component should still be called').disable(); + + if (StillInvokeRestCompsOnSameNode) { + compShouldBeActivated(restComp, 'rest'); + } + + cc.game.step(); + }); +})(); + test('destroy', function () { var parent = new cc.Node(); var child = new cc.Node(); From 9facb9a14f0212bc65e01afbff3d2b01cd133915 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Fri, 8 Apr 2016 17:29:49 +0800 Subject: [PATCH 2/2] inline unused method in base-node --- cocos2d/core/utils/base-node.js | 44 ++++++++---------------------- cocos2d/core/value-types/CCEnum.js | 4 +++ cocos2d/deprecated.js | 3 ++ 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 397a04a6de..7a21910086 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -1222,22 +1222,16 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ cc.assert(child, cc._LogInfos.Node.addChild_3); cc.assert(child._parent === null, "child already added. It can't be added again"); - this._addChildHelper(child, localZOrder, tag, name, setTag); - }, + // invokes the parent setter + child.parent = this; - _addChildHelper: function(child, localZOrder, tag, name, setTag){ - this._insertChild(child, localZOrder); + child.zIndex = localZOrder; if (setTag) child.setTag(tag); else child.setName(name); }, - _insertChild: function (child, z) { - child.parent = this; - child.zIndex = z; - }, - // composition: REMOVE /** @@ -1282,14 +1276,14 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * node.removeChild(newNode, false); */ removeChild: function (child, cleanup) { - // explicit nil handling - if (this._children.length === 0) - return; - - if (cleanup === undefined) - cleanup = true; - if (this._children.indexOf(child) > -1) - this._detachChild(child, cleanup); + if (this._children.indexOf(child) > -1) { + // If you don't do cleanup, the child's actions will not get removed and the + if (cleanup || cleanup === undefined) { + child.cleanup(); + } + // invoke the parent setter + child.parent = null; + } }, /** @@ -1354,22 +1348,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ this._children.length = 0; }, - _detachChild: function (child, doCleanup) { - // IMPORTANT: - // - 1st do onExit - // - 2nd cleanup - //if (this._running) { - // child.onExitTransitionDidStart(); - // child.onExit(); - //} - - // If you don't do cleanup, the child's actions will not get removed and the - if (doCleanup) - child.cleanup(); - - child.parent = null; - }, - setNodeDirty: function(){ this._sgNode.setNodeDirty(); }, diff --git a/cocos2d/core/value-types/CCEnum.js b/cocos2d/core/value-types/CCEnum.js index dc3f5d20ee..c377b6e2ef 100644 --- a/cocos2d/core/value-types/CCEnum.js +++ b/cocos2d/core/value-types/CCEnum.js @@ -61,6 +61,10 @@ cc.Enum = function (obj) { var reverseKey = '' + val; if (key !== reverseKey) { + if (enumType.hasOwnProperty(reverseKey) && CC_EDITOR) { + cc.error('%s already defined in Enum.', reverseKey); + continue; + } Object.defineProperty(enumType, reverseKey, { value: key, enumerable: false diff --git a/cocos2d/deprecated.js b/cocos2d/deprecated.js index 15097b1612..309d055660 100644 --- a/cocos2d/deprecated.js +++ b/cocos2d/deprecated.js @@ -389,6 +389,9 @@ if (CC_DEV) { running: 'activeInHierarchy, active', _realOpacity: '_opacity, _opacity', _realColor: '_color, _color', + _insertChild: 'addChild', + _addChildHelper: 'addChild', + _detachChild: 'removeChild', getZOrder: 'getLocalZOrder', setZOrder: 'setLocalZOrder', getOrderOfArrival: 'getSiblingIndex',