From da216c2af803c50ee4bc82ec0e954a1efc1e8a4e Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Wed, 21 Nov 2018 22:06:38 +0100 Subject: rewrite few lines of adopter --- src/utils/adopter.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/utils') 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) { -- cgit v1.2.3