Skip to content

Commit df97aec

Browse files
committed
Children components belong to the State now and fixed parent checks so all the movement methods now work again.
1 parent 2425d01 commit df97aec

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

v3/src/components/Children.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ var Children = new Class({
44

55
initialize:
66

7-
function Children (owner)
7+
function Children (state)
88
{
9-
this.owner = owner;
9+
// The State that owns this component
10+
this.state = state;
1011

1112
// The objects that belong to this collection.
1213
// The equivalent of the old `Sprite.children` array.
@@ -17,7 +18,7 @@ var Children = new Class({
1718

1819
add: function (child)
1920
{
20-
if (child.parent === this)
21+
if (child.parent === this.state)
2122
{
2223
return child;
2324
}
@@ -26,7 +27,7 @@ var Children = new Class({
2627
child.parent.children.remove(child);
2728
}
2829

29-
child.parent = this.owner;
30+
child.parent = this.state;
3031

3132
this.list.push(child);
3233

@@ -49,7 +50,7 @@ var Children = new Class({
4950
child.parent.children.remove(child);
5051
}
5152

52-
child.parent = this;
53+
child.parent = this.state;
5354

5455
this.list.splice(index, 0, child);
5556
}
@@ -322,7 +323,7 @@ var Children = new Class({
322323
{
323324
return false;
324325
}
325-
else if (child.parent === this)
326+
else if (child.parent === this.state)
326327
{
327328
return true;
328329
}
@@ -341,7 +342,7 @@ var Children = new Class({
341342
*/
342343
bringToTop: function (child)
343344
{
344-
if (child.parent === this && this.getIndex(child) < this.list.length)
345+
if (child.parent === this.state && this.getIndex(child) < this.list.length)
345346
{
346347
this.remove(child);
347348
this.add(child);
@@ -359,7 +360,7 @@ var Children = new Class({
359360
*/
360361
sendToBack: function (child)
361362
{
362-
if (child.parent === this && this.getIndex(child) > 0)
363+
if (child.parent === this.state && this.getIndex(child) > 0)
363364
{
364365
this.remove(child);
365366
this.addAt(child, 0);
@@ -567,7 +568,7 @@ var Children = new Class({
567568
*/
568569
reparent: function (newParent)
569570
{
570-
if (newParent !== this)
571+
if (newParent !== this.state)
571572
{
572573
for (var i = 0; i < this.list.length; i++)
573574
{

0 commit comments

Comments
 (0)