From 0cfec1bfc3c167edf90d13af6a984a769c4913b2 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 3 Apr 2014 19:34:25 +0200 Subject: [PATCH 1/5] fix for Element.Children Element.children is a function not a field, now it's correctly mapped --- svgjs/svgjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svgjs/svgjs.d.ts b/svgjs/svgjs.d.ts index f5ceb81f2..08513b78b 100644 --- a/svgjs/svgjs.d.ts +++ b/svgjs/svgjs.d.ts @@ -205,7 +205,7 @@ declare module svgjs { export interface Parent { put(element:Element, i?:number):Element; add(element:Element, i?:number):Element; - children:Element[]; + children():Element[]; rect(w:number, h:number):Element; ellipse(w:number, h:number):Element; From 900f86cb1f7b17a2a3b6c8f7d749a0319e34a917 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 3 Apr 2014 19:44:18 +0200 Subject: [PATCH 2/5] added a Test to check Element.children() as title says --- svgjs/svgjs-tests.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/svgjs/svgjs-tests.ts b/svgjs/svgjs-tests.ts index 60d07cab5..0a0a2357c 100644 --- a/svgjs/svgjs-tests.ts +++ b/svgjs/svgjs-tests.ts @@ -86,3 +86,27 @@ function elementTransformShouldReturnTransformObject() { if (trans.skewX != 10) { throw "skewX value is not correct" } if (trans.skewY != 25) { throw "skewY value is not correct" } } + +//Test if svgjs.Element.children() correctly return an svgjs.Element[] +function elementTransformShouldReturnTransformObject() { + /* create an svg drawing */ + var div = document.createElement('div') + var draw = SVG(div) + + /* draw a rectangle scale, rotate and skew it */ + var group = draw.group() + group.rect(10,10) + group.rect(20,20) + group.rect(30,30) + group.rect(40,40) + group.rect(50,50) + + /* first try to cast it */ + var result:svgjs.Element[] = group.children() + /* then check values if they are correct */ + if (!(result[0] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[1] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[2] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[3] instanceof svgjs.Element)) { throw "Element.children() is not working" } + if (!(result[4] instanceof svgjs.Element)) { throw "Element.children() is not working" } +} From 18dad4a676e2f6c9b8a8d95ea9958bddcd45a9ce Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 3 Apr 2014 20:51:46 +0200 Subject: [PATCH 3/5] Update svgjs-tests.ts --- svgjs/svgjs-tests.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/svgjs/svgjs-tests.ts b/svgjs/svgjs-tests.ts index 0a0a2357c..5ea5d2d50 100644 --- a/svgjs/svgjs-tests.ts +++ b/svgjs/svgjs-tests.ts @@ -104,9 +104,8 @@ function elementTransformShouldReturnTransformObject() { /* first try to cast it */ var result:svgjs.Element[] = group.children() /* then check values if they are correct */ - if (!(result[0] instanceof svgjs.Element)) { throw "Element.children() is not working" } - if (!(result[1] instanceof svgjs.Element)) { throw "Element.children() is not working" } - if (!(result[2] instanceof svgjs.Element)) { throw "Element.children() is not working" } - if (!(result[3] instanceof svgjs.Element)) { throw "Element.children() is not working" } - if (!(result[4] instanceof svgjs.Element)) { throw "Element.children() is not working" } + for (var i = 0; i < 5; i++) { + var elem: svgjs.Element = result[i]; + if (elem == null) { throw "Element.children() is not working" } + } } From c801c1475f7fe5fa4d75641a48e49433f5ed8649 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 3 Apr 2014 20:56:44 +0200 Subject: [PATCH 4/5] wrong comment --- svgjs/svgjs-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svgjs/svgjs-tests.ts b/svgjs/svgjs-tests.ts index 5ea5d2d50..a135aab25 100644 --- a/svgjs/svgjs-tests.ts +++ b/svgjs/svgjs-tests.ts @@ -93,7 +93,7 @@ function elementTransformShouldReturnTransformObject() { var div = document.createElement('div') var draw = SVG(div) - /* draw a rectangle scale, rotate and skew it */ + /* draw some rectangle inside a group */ var group = draw.group() group.rect(10,10) group.rect(20,20) @@ -107,5 +107,5 @@ function elementTransformShouldReturnTransformObject() { for (var i = 0; i < 5; i++) { var elem: svgjs.Element = result[i]; if (elem == null) { throw "Element.children() is not working" } - } + } } From 04eb30761acad48eb4a6339157153fb4ccb25ea7 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Fri, 4 Apr 2014 11:20:48 +0200 Subject: [PATCH 5/5] opz same function name maybe less significative names can be ok too --- svgjs/svgjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svgjs/svgjs-tests.ts b/svgjs/svgjs-tests.ts index a135aab25..63fcc1ce7 100644 --- a/svgjs/svgjs-tests.ts +++ b/svgjs/svgjs-tests.ts @@ -88,7 +88,7 @@ function elementTransformShouldReturnTransformObject() { } //Test if svgjs.Element.children() correctly return an svgjs.Element[] -function elementTransformShouldReturnTransformObject() { +function elementChildrenShouldReturnElementArray() { /* create an svg drawing */ var div = document.createElement('div') var draw = SVG(div)