diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-10-27 20:43:35 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-10-27 20:43:35 +0200 |
commit | 1c75fcaf02ceb144152d59557643c6fdd7264065 (patch) | |
tree | 5184af75f2fd27ca6b81c24a06b1676d17ca2c76 /src/A.js | |
parent | b1b776a710d0ce0a6259043b8ce0665e205195fa (diff) | |
download | svg.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.js | 39 |
1 files changed, 20 insertions, 19 deletions
@@ -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) } -}) +} |