From: nobuti Date: Fri, 26 Oct 2018 16:57:55 +0000 (+0200) Subject: Modifiers implementation on getter X-Git-Tag: 3.0.0~57^2~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=973556a88de356e610a8bf26d1e22d5a92033769;p=svg.js.git Modifiers implementation on getter --- diff --git a/src/element.js b/src/element.js index f0d9e8e..57a83ac 100644 --- a/src/element.js +++ b/src/element.js @@ -261,7 +261,7 @@ SVG.Element = SVG.invent({ var well, len // act as a setter if svg is given - if (svg && this instanceof SVG.Parent) { + if (typeof svg === 'string' && this instanceof SVG.Parent) { // create temporary holder well = document.createElementNS(SVG.ns, 'svg') // dump raw svg @@ -271,9 +271,20 @@ SVG.Element = SVG.invent({ for (len = well.children.length; len--;) { this.node.appendChild(well.firstElementChild) } - // otherwise act as a getter } else { + if (typeof svg === 'function') { + well = svg(this) + + if (well instanceof SVG.Element) { + return well.svg() + } + + if (typeof well === 'boolean' && !well) { + return null + } + } + // write svgjs data to the dom this.writeDataToDom()