summaryrefslogtreecommitdiffstats
path: root/dist/svg.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-02-20 15:29:14 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-02-20 15:29:14 +0100
commit1144404e4bea677c293e9bad273ce273aa1cd885 (patch)
treeec66756c26c653194619a055dffa0234811b55fe /dist/svg.js
parentdfc07aa5be10a2b3749c3aae548d3652f0b780d5 (diff)
downloadsvg.js-1144404e4bea677c293e9bad273ce273aa1cd885.tar.gz
svg.js-1144404e4bea677c293e9bad273ce273aa1cd885.zip
Added clone method to SVG.Array/PointArray/PathArray (#590)
Diffstat (limited to 'dist/svg.js')
-rw-r--r--dist/svg.js27
1 files changed, 22 insertions, 5 deletions
diff --git a/dist/svg.js b/dist/svg.js
index 48c78e2..6a9ae01 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Fri Feb 17 2017 22:19:12 GMT-0500 (EST)
+* BUILT: Mon Feb 20 2017 15:25:03 GMT+0100 (Mitteleuropäische Zeit)
*/;
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
@@ -504,15 +504,20 @@ SVG.extend(SVG.Array, {
return this
}
-
+, clone: function() {
+ var clone = new this.constructor()
+ clone.value = array_clone(this.value)
+ return clone
+ }
})
// Poly points array
SVG.PointArray = function(array, fallback) {
- this.constructor.call(this, array, fallback || [[0,0]])
+ SVG.Array.call(this, array, fallback || [[0,0]])
}
// Inherit from SVG.Array
SVG.PointArray.prototype = new SVG.Array
+SVG.PointArray.prototype.constructor = SVG.PointArray
SVG.extend(SVG.PointArray, {
// Convert array to string
@@ -606,16 +611,16 @@ SVG.extend(SVG.PointArray, {
return SVG.parser.poly.getBBox()
}
-
})
// Path points array
SVG.PathArray = function(array, fallback) {
- this.constructor.call(this, array, fallback || [['M', 0, 0]])
+ SVG.Array.call(this, array, fallback || [['M', 0, 0]])
}
// Inherit from SVG.Array
SVG.PathArray.prototype = new SVG.Array
+SVG.PathArray.prototype.constructor = SVG.PathArray
SVG.extend(SVG.PathArray, {
// Convert array to string
@@ -5258,6 +5263,18 @@ SVG.extend(SVG.Parent, {
}
})
+// creates deep clone of array
+function array_clone(arr){
+ var clone = arr.slice(0)
+ for(var i = clone.length; i--;){
+ if(Array.isArray(clone[i])){
+ clone[i] = array_clone(clone[i])
+ }
+ }
+ return clone
+}
+
+// tests if a given element is instance of an object
function is(el, obj){
return el instanceof obj
}