diff --git a/src/item/Item.js b/src/item/Item.js index 295e5759..dad79723 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -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. diff --git a/test/tests/item.js b/test/tests/item.js index 1c141040..5185864b 100644 --- a/test/tests/item.js +++ b/test/tests/item.js @@ -132,4 +132,16 @@ test('hidden', function() { var firstPath = new Path(); firstPath.visible = false; equals(firstPath.hidden, true); -}); \ No newline at end of file +}); + +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); +}) \ No newline at end of file