Implement Item#reverseChildren() and add tests for it.

This commit is contained in:
Jonathan Puckey 2011-02-24 19:31:07 +01:00
parent d77741db4f
commit d9b75a7232
2 changed files with 20 additions and 2 deletions

View file

@ -142,7 +142,13 @@ Item = Base.extend({
// TODO: get/setKnockout (print specific feature)
// TODO get/setAlphaIsShape
// TODO: get/setData
// TODO: reverseChildren
/**
* Reverses the order of this item's children
*/
reverseChildren: function() {
this.children.reverse();
},
/**
* The first item contained within this item.

View file

@ -132,4 +132,16 @@ test('hidden', function() {
var firstPath = new Path();
firstPath.visible = false;
equals(firstPath.hidden, true);
});
});
test('reverseChildren()', function() {
var doc = new Doc();
var path = new Path();
var secondPath = new Path();
var thirdPath = new Path();
equals(doc.activeLayer.firstChild == path, true);
doc.activeLayer.reverseChildren();
equals(doc.activeLayer.firstChild == path, false);
equals(doc.activeLayer.firstChild == thirdPath, true);
equals(doc.activeLayer.lastChild == path, true);
})