aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Use.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements/Use.js')
-rw-r--r--src/elements/Use.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/elements/Use.js b/src/elements/Use.js
new file mode 100644
index 0000000..43a4e9b
--- /dev/null
+++ b/src/elements/Use.js
@@ -0,0 +1,27 @@
+import { nodeOrNew, register } from '../utils/adopter.js'
+import { registerMethods } from '../utils/methods.js'
+import { xlink } from '../modules/core/namespaces.js'
+import Shape from './Shape.js'
+
+export default class Use extends Shape {
+ constructor (node) {
+ super(nodeOrNew('use', node), Use)
+ }
+
+ // Use element as a reference
+ element (element, file) {
+ // Set lined element
+ return this.attr('href', (file || '') + '#' + element, xlink)
+ }
+}
+
+registerMethods({
+ Container: {
+ // Create a use element
+ use: function (element, file) {
+ return this.put(new Use()).element(element, file)
+ }
+ }
+})
+
+register(Use)