* For big svg string, this method might be time consuming. * * @param {string} svg xml string * @return {Object} xml root.
(svg)
| 26377 | * @return {Object} xml root. |
| 26378 | */ |
| 26379 | function parseXML(svg) { |
| 26380 | if (isString(svg)) { |
| 26381 | var parser = new DOMParser(); |
| 26382 | svg = parser.parseFromString(svg, 'text/xml'); |
| 26383 | } |
| 26384 | |
| 26385 | // Document node. If using $.get, doc node may be input. |
| 26386 | if (svg.nodeType === 9) { |
| 26387 | svg = svg.firstChild; |
| 26388 | } |
| 26389 | // nodeName of <!DOCTYPE svg> is also 'svg'. |
| 26390 | while (svg.nodeName.toLowerCase() !== 'svg' || svg.nodeType !== 1) { |
| 26391 | svg = svg.nextSibling; |
| 26392 | } |
| 26393 | |
| 26394 | return svg; |
| 26395 | } |
| 26396 | |
| 26397 | function SVGParser() { |
| 26398 | this._defs = {}; |
no test coverage detected