(el, attrs, children)
| 37 | var sin = math.sin; |
| 38 | |
| 39 | var V = function(el, attrs, children) { |
| 40 | |
| 41 | // This allows using V() without the new keyword. |
| 42 | if (!(this instanceof V)) { |
| 43 | return V.apply(Object.create(V.prototype), arguments); |
| 44 | } |
| 45 | |
| 46 | if (!el) return; |
| 47 | |
| 48 | if (V.isV(el)) { |
| 49 | el = el.node; |
| 50 | } |
| 51 | |
| 52 | attrs = attrs || {}; |
| 53 | |
| 54 | if (V.isString(el)) { |
| 55 | |
| 56 | el = el.trim(); |
| 57 | |
| 58 | if (el.toLowerCase() === 'svg') { |
| 59 | |
| 60 | // Create a new SVG canvas. |
| 61 | el = V.createSvgDocument(); |
| 62 | |
| 63 | } else if (el[0] === '<') { |
| 64 | |
| 65 | // Create element from an SVG string. |
| 66 | // Allows constructs of type: `document.appendChild(V('<rect></rect>').node)`. |
| 67 | |
| 68 | var svgDoc = V.createSvgDocument(el); |
| 69 | |
| 70 | // Note that `V()` might also return an array should the SVG string passed as |
| 71 | // the first argument contain more than one root element. |
| 72 | if (svgDoc.childNodes.length > 1) { |
| 73 | |
| 74 | // Map child nodes to `V`s. |
| 75 | var arrayOfVels = []; |
| 76 | var i, len; |
| 77 | |
| 78 | for (i = 0, len = svgDoc.childNodes.length; i < len; i++) { |
| 79 | |
| 80 | var childNode = svgDoc.childNodes[i]; |
| 81 | arrayOfVels.push(new V(document.importNode(childNode, true))); |
| 82 | } |
| 83 | |
| 84 | return arrayOfVels; |
| 85 | } |
| 86 | |
| 87 | el = document.importNode(svgDoc.firstChild, true); |
| 88 | |
| 89 | } else { |
| 90 | |
| 91 | el = createSVGElement(el); |
| 92 | } |
| 93 | |
| 94 | V.ensureId(el); |
| 95 | } |
| 96 |
no test coverage detected