summaryrefslogtreecommitdiffstats
path: root/src/Gradient.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-27 20:43:35 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-27 20:43:35 +0200
commit1c75fcaf02ceb144152d59557643c6fdd7264065 (patch)
tree5184af75f2fd27ca6b81c24a06b1676d17ca2c76 /src/Gradient.js
parentb1b776a710d0ce0a6259043b8ce0665e205195fa (diff)
downloadsvg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.tar.gz
svg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.zip
resolve circular references and make example working again
Diffstat (limited to 'src/Gradient.js')
-rw-r--r--src/Gradient.js37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/Gradient.js b/src/Gradient.js
index da76666..ab4cc4f 100644
--- a/src/Gradient.js
+++ b/src/Gradient.js
@@ -1,10 +1,15 @@
import Stop from './Stop.js'
+import Base from './Base.js'
import * as gradiented from './gradiented.js'
-import {nodeOrNew, extend, addFactory} from './tools.js'
+import {nodeOrNew, extend} from './tools.js'
+import attr from './attr.js'
-export default class Gradient extends Container {
+export default class Gradient extends Base {
constructor (type) {
- super(nodeOrNew(type + 'Gradient', typeof type === 'string' ? null : type))
+ super(
+ nodeOrNew(type + 'Gradient', typeof type === 'string' ? null : type),
+ Gradient
+ )
}
// Add a color stop
@@ -38,23 +43,23 @@ export default class Gradient extends Container {
// custom attr to handle transform
attr (a, b, c) {
if (a === 'transform') a = 'gradientTransform'
- return super.attr(a, b, c)
+ return attr.call(this, a, b, c)
}
}
extend(Gradient, gradiented)
-addFactory(Parent, {
- // Create gradient element in defs
- gradient (type, block) {
- return this.defs().gradient(type, block)
- }
-})
-
-// Base gradient generation
-addFactory(Defs, {
+Gradient.constructors = {
+ Container: {
+ // Create gradient element in defs
+ gradient (type, block) {
+ return this.defs().gradient(type, block)
+ }
+ },
// define gradient
- gradient: function (type, block) {
- return this.put(new Gradient(type)).update(block)
+ Defs: {
+ gradient (type, block) {
+ return this.put(new Gradient(type)).update(block)
+ }
}
-})
+}