summaryrefslogtreecommitdiffstats
path: root/src/A.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/A.js
parentb1b776a710d0ce0a6259043b8ce0665e205195fa (diff)
downloadsvg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.tar.gz
svg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.zip
resolve circular references and make example working again
Diffstat (limited to 'src/A.js')
-rw-r--r--src/A.js39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/A.js b/src/A.js
index 72e13e4..eb95dc0 100644
--- a/src/A.js
+++ b/src/A.js
@@ -1,10 +1,10 @@
-import {Container, Element} from './classes.js'
-import {nodeOrNew, addFactory} from './tools.js'
+import Base from './Base.js'
+import {nodeOrNew} from './tools.js'
import {xlink} from './namespaces.js'
-export default class A extends Container {
+export default class A extends Base{
constructor (node) {
- super(nodeOrNew('a', node))
+ super(nodeOrNew('a', node), A)
}
// Link url
@@ -18,22 +18,23 @@ export default class A extends Container {
}
}
-addFactory(Container, {
- // Create a hyperlink element
- link: function (url) {
- return this.put(new A()).to(url)
- }
-})
+A.constructors = {
+ Container: {
+ // Create a hyperlink element
+ link: function (url) {
+ return this.put(new A()).to(url)
+ }
+ },
+ Element: {
+ // Create a hyperlink element
+ linkTo: function (url) {
+ var link = new A()
-addFactory(Element, {
- // Create a hyperlink element
- linkTo: function (url) {
- var link = new A()
+ if (typeof url === 'function') { url.call(link, link) } else {
+ link.to(url)
+ }
- if (typeof url === 'function') { url.call(link, link) } else {
- link.to(url)
+ return this.parent().put(link).put(this)
}
-
- return this.parent().put(link).put(this)
}
-})
+}