summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-18 11:13:56 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-18 11:13:56 +0200
commit6175adf23ddd6587954b20dc2700458d27ccaf69 (patch)
tree0b8075688109a4845ef13a2b783fb905a1f2661e
parent55874e6dd16cb85181e879b8c35b4e65bb310e11 (diff)
downloadsvg.js-6175adf23ddd6587954b20dc2700458d27ccaf69.tar.gz
svg.js-6175adf23ddd6587954b20dc2700458d27ccaf69.zip
Revert "Merge pull request #828 from svgdotjs/797-throw-error-in-at"
This reverts commit 55874e6dd16cb85181e879b8c35b4e65bb310e11, reversing changes made to 31e94c28d85f676a0f4ec073a06435bc86b1dc73.
-rw-r--r--spec/spec/array.js13
-rw-r--r--spec/spec/boxes.js4
-rw-r--r--spec/spec/color.js4
-rw-r--r--spec/spec/matrix.js4
-rw-r--r--spec/spec/number.js4
-rw-r--r--spec/spec/point.js4
-rw-r--r--src/array.js2
-rw-r--r--src/boxes.js2
-rw-r--r--src/color.js2
-rw-r--r--src/matrix.js2
-rw-r--r--src/number.js2
-rw-r--r--src/patharray.js2
-rw-r--r--src/point.js2
-rw-r--r--src/pointarray.js2
14 files changed, 25 insertions, 24 deletions
diff --git a/spec/spec/array.js b/spec/spec/array.js
index 03046ca..7530ea1 100644
--- a/spec/spec/array.js
+++ b/spec/spec/array.js
@@ -113,8 +113,8 @@ describe('Array', function () {
arr1.morph(arr2)
expect(arr1.at(0.5).value).toEqual([1.5, 2.5, 3.5, 4.5])
})
- it('throws when no destination was specified', function() {
- expect(arr1.at).toThrow()
+ it('returns itself if no destination was specified', function() {
+ expect(arr1.at(0.5)).toBe(arr1)
})
})
})
@@ -221,8 +221,8 @@ describe('PointArray', function () {
arr1.morph(arr2)
expect(arr1.at(0.5).value).toEqual([[1.5, 2.5], [3.5, 4.5]])
})
- it('throws when no destination was specified', function() {
- expect(arr1.at).toThrow()
+ it('returns itself if no destination was specified', function() {
+ expect(arr1.at(0.5)).toBe(arr1)
})
})
})
@@ -394,9 +394,10 @@ describe('PathArray', function () {
expect(morphedPathArray.value[1][4]).toBe(1)
expect(morphedPathArray.value[1][5]).toBe(0)
})
- it('throws when no destination was specified', function(){
+ it('return itself if the destination attribute is null', function(){
var pathArray = new SVG.PathArray('M 13 13 A 25 37 0 0 1 43 25')
- expect(pathArray.at).toThrow()
+ pathArray.destination = null
+ expect(pathArray.at(0.45)).toBe(pathArray)
})
})
diff --git a/spec/spec/boxes.js b/spec/spec/boxes.js
index cc428e4..9e33c60 100644
--- a/spec/spec/boxes.js
+++ b/spec/spec/boxes.js
@@ -148,9 +148,9 @@ describe('Box', function() {
expect(box2.toString()).toBe('50 -100 300 300')
expect(box3.toString()).toBe('30 0 250 300')
})
- it('throws itself when no destination was specified', function() {
+ it('returns itself when no destination given', function() {
var box = new SVG.Box(10, 100, 200, 300)
- expect(box.at).toThrow()
+ expect(box.at(0.5)).toBe(box)
})
})
})
diff --git a/spec/spec/color.js b/spec/spec/color.js
index b70af1b..1e86544 100644
--- a/spec/spec/color.js
+++ b/spec/spec/color.js
@@ -77,8 +77,8 @@ describe('Color', function() {
expect(morphed.b).toBe(255)
})
- it('throws when no destination specified', function() {
- expect(color.at).toThrow()
+ it('returns itself when no destination specified', function() {
+ expect(color.at(0.5)).toBe(color)
})
})
diff --git a/spec/spec/matrix.js b/spec/spec/matrix.js
index aaebd68..0816f66 100644
--- a/spec/spec/matrix.js
+++ b/spec/spec/matrix.js
@@ -193,9 +193,9 @@ describe('Matrix', function() {
expect(matrix2.toString()).toBe('matrix(1,0,0,1,4,3)')
expect(matrix3.toString()).toBe('matrix(1.5,0,0,3,2,1.5)')
})
- it('throws when no destination specified', function() {
+ it('returns itself when no destination specified', function() {
var matrix = new SVG.Matrix(2, 0, 0, 5, 0, 0)
- expect(matrix.at).toThrow()
+ expect(matrix.at(0.5)).toBe(matrix)
})
})
diff --git a/spec/spec/number.js b/spec/spec/number.js
index 2d33fef..58c14bd 100644
--- a/spec/spec/number.js
+++ b/spec/spec/number.js
@@ -237,8 +237,8 @@ describe('Number', function() {
it('use the unit of this number as the unit of the returned number when the destination number as no unit', function() {
expect(expect(new SVG.Number('100s').morph(50).at(0.5).unit).toBe('s'))
})
- it('throws when no destination specified', function() {
- expect(number.at).toThrow()
+ it('returns itself when no destination specified', function() {
+ expect(number.at(0.5)).toBe(number)
})
})
diff --git a/spec/spec/point.js b/spec/spec/point.js
index 80cc414..8eacb84 100644
--- a/spec/spec/point.js
+++ b/spec/spec/point.js
@@ -117,9 +117,9 @@ describe('Point', function() {
expect(point3).toEqual(new SVG.Point(1.5, 1.5))
})
- it('throws when no destination specified', function() {
+ it('returns itself when no destination specified', function() {
var point = new SVG.Point(1,1)
- expect(point.at).toThrow()
+ expect(point.at(0.4)).toBe(point)
})
})
diff --git a/src/array.js b/src/array.js
index 5ce0160..ca51d8e 100644
--- a/src/array.js
+++ b/src/array.js
@@ -49,7 +49,7 @@ SVG.extend(SVG.Array, {
// Get morphed array at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
// generate morphed array
for (var i = 0, il = this.value.length, array = []; i < il; i++) {
diff --git a/src/boxes.js b/src/boxes.js
index de96081..f0154bd 100644
--- a/src/boxes.js
+++ b/src/boxes.js
@@ -74,7 +74,7 @@ SVG.Box = SVG.invent({
},
at: function (pos) {
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
return new SVG.Box(
this.x + (this.destination.x - this.x) * pos
diff --git a/src/color.js b/src/color.js
index 22b8506..8f47f70 100644
--- a/src/color.js
+++ b/src/color.js
@@ -68,7 +68,7 @@ SVG.extend(SVG.Color, {
// Get morphed color at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
// normalise pos
pos = pos < 0 ? 0 : pos > 1 ? 1 : pos
diff --git a/src/matrix.js b/src/matrix.js
index 8028b15..e823a81 100644
--- a/src/matrix.js
+++ b/src/matrix.js
@@ -68,7 +68,7 @@ SVG.Matrix = SVG.invent({
// Get morphed matrix at a given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
// calculate morphed matrix at a given position
var matrix = new SVG.Matrix({
diff --git a/src/number.js b/src/number.js
index ba95151..6413f94 100644
--- a/src/number.js
+++ b/src/number.js
@@ -91,7 +91,7 @@ SVG.Number = SVG.invent({
// Get morphed number at given position
at: function (pos) {
// Make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
// Generate new morphed number
return new SVG.Number(this.destination)
diff --git a/src/patharray.js b/src/patharray.js
index ca58513..d9ffecd 100644
--- a/src/patharray.js
+++ b/src/patharray.js
@@ -195,7 +195,7 @@ SVG.extend(SVG.PathArray, {
// Get morphed path array at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
var sourceArray = this.value
var destinationArray = this.destination.value
diff --git a/src/point.js b/src/point.js
index 72a9572..682092e 100644
--- a/src/point.js
+++ b/src/point.js
@@ -32,7 +32,7 @@ SVG.Point = SVG.invent({
// Get morphed point at a given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
// calculate morphed matrix at a given position
var point = new SVG.Point({
diff --git a/src/pointarray.js b/src/pointarray.js
index 6229e2e..ecf5c40 100644
--- a/src/pointarray.js
+++ b/src/pointarray.js
@@ -32,7 +32,7 @@ SVG.extend(SVG.PointArray, {
// Get morphed array at given position
at: function (pos) {
// make sure a destination is defined
- if (!this.destination) throw new Error('No destination set')
+ if (!this.destination) return this
// generate morphed point string
for (var i = 0, il = this.value.length, array = []; i < il; i++) {