diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-21 22:06:38 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-21 22:06:38 +0100 |
commit | da216c2af803c50ee4bc82ec0e954a1efc1e8a4e (patch) | |
tree | b43dff9760656220aa832d297535a5cb74d30171 /src/utils | |
parent | ddf28b67dd55aab000a5e6c44f2089c9f0b91ff8 (diff) | |
download | svg.js-da216c2af803c50ee4bc82ec0e954a1efc1e8a4e.tar.gz svg.js-da216c2af803c50ee4bc82ec0e954a1efc1e8a4e.zip |
rewrite few lines of adopter
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/adopter.js | 21 |
1 files changed, 9 insertions, 12 deletions
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) { |