aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Line.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 19:49:49 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 19:49:49 +0100
commit09e7d0b595da5a2e86e375ea4bd9bd7aba02c588 (patch)
treeae4d2df2887187bed13756c0cc79657cca680cf2 /src/elements/Line.js
parent8c81fb7c2e6e9842570d27a84b1a1c600c82c16b (diff)
downloadsvg.js-09e7d0b595da5a2e86e375ea4bd9bd7aba02c588.tar.gz
svg.js-09e7d0b595da5a2e86e375ea4bd9bd7aba02c588.zip
added possibility to pass in additional attribues to element creators (#796)
e.g. - `canvas.rect({x:100})` or - `canvas.rect(100, 100, {x:100})`
Diffstat (limited to 'src/elements/Line.js')
-rw-r--r--src/elements/Line.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/elements/Line.js b/src/elements/Line.js
index ba15135..99e7497 100644
--- a/src/elements/Line.js
+++ b/src/elements/Line.js
@@ -1,4 +1,9 @@
-import { extend, nodeOrNew, register } from '../utils/adopter.js'
+import {
+ extend,
+ nodeOrNew,
+ register,
+ wrapWithAttrCheck
+} from '../utils/adopter.js'
import { proportionalSize } from '../utils/utils.js'
import { registerMethods } from '../utils/methods.js'
import PointArray from '../types/PointArray.js'
@@ -49,14 +54,14 @@ extend(Line, pointed)
registerMethods({
Container: {
// Create a line element
- line (...args) {
+ line: wrapWithAttrCheck(function (...args) {
// make sure plot is called as a setter
// x1 is not necessarily a number, it can also be an array, a string and a PointArray
return Line.prototype.plot.apply(
this.put(new Line())
, args[0] != null ? args : [0, 0, 0, 0]
)
- }
+ })
}
})