aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Bare.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements/Bare.js')
-rw-r--r--src/elements/Bare.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/elements/Bare.js b/src/elements/Bare.js
new file mode 100644
index 0000000..43fc075
--- /dev/null
+++ b/src/elements/Bare.js
@@ -0,0 +1,30 @@
+import { nodeOrNew, register } from '../utils/adopter.js'
+import { registerMethods } from '../utils/methods.js'
+import Container from './Container.js'
+
+export default class Bare extends Container {
+ constructor (node) {
+ super(nodeOrNew(node, typeof node === 'string' ? null : node), Bare)
+ }
+
+ words (text) {
+ // remove contents
+ while (this.node.hasChildNodes()) {
+ this.node.removeChild(this.node.lastChild)
+ }
+
+ // create text node
+ this.node.appendChild(document.createTextNode(text))
+
+ return this
+ }
+}
+
+register(Bare)
+
+registerMethods('Container', {
+ // Create an element that is not described by SVG.js
+ element (node, inherit) {
+ return this.put(new Bare(node, inherit))
+ }
+})