mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 10:48:38 -05:00
Implement Item#isParent and add tests for it.
This commit is contained in:
parent
594c11fedd
commit
d02885cba7
2 changed files with 7 additions and 5 deletions
|
@ -309,10 +309,9 @@ var Item = this.Item = Base.extend({
|
|||
*/
|
||||
// TODO: isBelow
|
||||
|
||||
// TODO: this is confusing the beans
|
||||
// isParent: function(item) {
|
||||
// return this.parent == item;
|
||||
// },
|
||||
isParent: function(item) {
|
||||
return this.parent == item;
|
||||
},
|
||||
|
||||
isChild: function(item) {
|
||||
return item.parent == this;
|
||||
|
|
|
@ -35,7 +35,7 @@ test('appendChild(item)', function() {
|
|||
equals(doc.activeLayer.children.length, 1);
|
||||
});
|
||||
|
||||
test('item.parent / item.isChild', function() {
|
||||
test('item.parent / item.isChild / item.isParent', function() {
|
||||
var doc = new Document();
|
||||
var secondDoc = new Document();
|
||||
var path = new Path();
|
||||
|
@ -43,7 +43,10 @@ test('item.parent / item.isChild', function() {
|
|||
equals(doc.activeLayer.children.indexOf(path) != -1, true);
|
||||
secondDoc.activeLayer.appendTop(path);
|
||||
equals(doc.activeLayer.isChild(path), false);
|
||||
equals(path.isParent(doc.activeLayer), false);
|
||||
equals(secondDoc.activeLayer.isChild(path), true);
|
||||
equals(path.isParent(secondDoc.activeLayer), true);
|
||||
|
||||
equals(doc.activeLayer.children.indexOf(path) == -1, true);
|
||||
equals(secondDoc.activeLayer.children.indexOf(path) == 0, true);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue