aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/elements/Element.js8
-rw-r--r--src/elements/Svg.js10
-rw-r--r--src/modules/core/namespaces.js1
-rw-r--r--src/utils/utils.js3
4 files changed, 14 insertions, 8 deletions
diff --git a/src/elements/Element.js b/src/elements/Element.js
index 7a563d6..e3a4211 100644
--- a/src/elements/Element.js
+++ b/src/elements/Element.js
@@ -25,9 +25,13 @@ export default class Element extends Dom {
// create circular reference
this.node.instance = this
- if (node.hasAttribute('svgjs:data')) {
+ if (node.hasAttribute('data-svgjs') || node.hasAttribute('svgjs:data')) {
// pull svgjs data from the dom (getAttributeNS doesn't work in html5)
- this.setData(JSON.parse(node.getAttribute('svgjs:data')) || {})
+ this.setData(
+ JSON.parse(node.getAttribute('data-svgjs')) ??
+ JSON.parse(node.getAttribute('svgjs:data')) ??
+ {}
+ )
}
}
diff --git a/src/elements/Svg.js b/src/elements/Svg.js
index 7b36daa..40d50c9 100644
--- a/src/elements/Svg.js
+++ b/src/elements/Svg.js
@@ -4,7 +4,7 @@ import {
register,
wrapWithAttrCheck
} from '../utils/adopter.js'
-import { svg, svgjs, xlink, xmlns } from '../modules/core/namespaces.js'
+import { svg, xlink, xmlns } from '../modules/core/namespaces.js'
import { registerMethods } from '../utils/methods.js'
import Container from './Container.js'
import Defs from './Defs.js'
@@ -34,9 +34,11 @@ export default class Svg extends Container {
// Add namespaces
namespace() {
if (!this.isRoot()) return this.root().namespace()
- return this.attr({ xmlns: svg, version: '1.1' })
- .attr('xmlns:xlink', xlink, xmlns)
- .attr('xmlns:svgjs', svgjs, xmlns)
+ return this.attr({ xmlns: svg, version: '1.1' }).attr(
+ 'xmlns:xlink',
+ xlink,
+ xmlns
+ )
}
removeNamespace() {
diff --git a/src/modules/core/namespaces.js b/src/modules/core/namespaces.js
index 778d402..544efa2 100644
--- a/src/modules/core/namespaces.js
+++ b/src/modules/core/namespaces.js
@@ -3,4 +3,3 @@ export const svg = 'http://www.w3.org/2000/svg'
export const html = 'http://www.w3.org/1999/xhtml'
export const xmlns = 'http://www.w3.org/2000/xmlns/'
export const xlink = 'http://www.w3.org/1999/xlink'
-export const svgjs = 'http://svgjs.dev/svgjs'
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 2438431..90ef548 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -135,8 +135,9 @@ export const writeDataToDom = (element, data, defaults = {}) => {
}
if (Object.keys(cloned).length) {
- element.node.setAttribute('svgjs:data', JSON.stringify(cloned)) // see #428
+ element.node.setAttribute('data-svgjs', JSON.stringify(cloned)) // see #428
} else {
+ element.node.removeAttribute('data-svgjs')
element.node.removeAttribute('svgjs:data')
}
}