summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-21 22:06:38 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-21 22:06:38 +0100
commitda216c2af803c50ee4bc82ec0e954a1efc1e8a4e (patch)
treeb43dff9760656220aa832d297535a5cb74d30171
parentddf28b67dd55aab000a5e6c44f2089c9f0b91ff8 (diff)
downloadsvg.js-da216c2af803c50ee4bc82ec0e954a1efc1e8a4e.tar.gz
svg.js-da216c2af803c50ee4bc82ec0e954a1efc1e8a4e.zip
rewrite few lines of adopter
-rw-r--r--dist/svg.js20
-rw-r--r--src/utils/adopter.js21
2 files changed, 18 insertions, 23 deletions
diff --git a/dist/svg.js b/dist/svg.js
index 9d7a861..5407a1a 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Wed Nov 21 2018 10:58:56 GMT+0100 (GMT+01:00)
+* BUILT: Wed Nov 21 2018 22:04:17 GMT+0100 (GMT+01:00)
*/;
var SVG = (function () {
'use strict';
@@ -437,19 +437,17 @@ var SVG = (function () {
} // initialize variables
- var element; // adopt with element-specific settings
+ var className = capitalize(node.nodeName);
- if (node.nodeName === 'svg') {
- element = new elements[root](node);
- } else if (node.nodeName === 'linearGradient' || node.nodeName === 'radialGradient') {
- element = new elements.Gradient(node);
- } else if (elements[capitalize(node.nodeName)]) {
- element = new elements[capitalize(node.nodeName)](node);
- } else {
- element = new elements.Bare(node);
+ if (className === 'LinearGradient' || className === 'RadialGradient') {
+ className = 'Gradient';
}
- return element;
+ if (!elements[className]) {
+ className = 'Bare';
+ }
+
+ return new elements[className](node);
}
function register(element) {
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element.name;
diff --git a/src/utils/adopter.js b/src/utils/adopter.js
index 80bfd8a..6109f22 100644
--- a/src/utils/adopter.js
+++ b/src/utils/adopter.js
@@ -55,20 +55,17 @@ export function adopt (node) {
}
// initialize variables
- var element
-
- // adopt with element-specific settings
- if (node.nodeName === 'svg') {
- element = new elements[root](node)
- } else if (node.nodeName === 'linearGradient' || node.nodeName === 'radialGradient') {
- element = new elements.Gradient(node)
- } else if (elements[capitalize(node.nodeName)]) {
- element = new elements[capitalize(node.nodeName)](node)
- } else {
- element = new elements.Bare(node)
+ var className = capitalize(node.nodeName)
+
+ if (className === 'LinearGradient' || className === 'RadialGradient') {
+ className = 'Gradient'
}
- return element
+ if (!elements[className]) {
+ className = 'Bare'
+ }
+
+ return new elements[className](node)
}
export function register (element, name = element.name, asRoot = false) {