nl_tokens: Create SVG element . -------------------
pl_tokens: function createElement ( el , attrs , children ) { if ( ! el ) return undefined ; // If `el` is an object, it is probably a native SVG element. Wrap it to VElement. if ( typeof el === 'object' ) { return new VElement ( el ) ; } attrs = attrs || { } ; // If `el` is a `'svg'` or `'SVG'` string, create a new SVG canvas. if ( el . toLowerCase ( ) === 'svg' ) { attrs . xmlns = ns . xmlns ; attrs [ 'xmlns:xlink' ] = ns . xlink ; attrs . version = SVGversion ; } else if ( el [ 0 ] === '<' ) { // Create element from an SVG string. // Allows constructs of type: `document.appendChild(Vectorizer('<rect></rect>').node)`. var svg = '<svg xmlns="' + ns . xmlns + '" xmlns:xlink="' + ns . xlink + '" version="' + SVGversion + '">' + el + '</svg>' ; var parser = new DOMParser ( ) ; parser . async = false ; var svgDoc = parser . parseFromString ( svg , 'text/xml' ) . documentElement ; // Note that `createElement()` might also return an array should the SVG string passed as // the first argument contain more then one root element. if ( svgDoc . childNodes . length > 1 ) { return _ . map ( svgDoc . childNodes , function ( childNode ) { return new VElement ( document . importNode ( childNode , true ) ) ; } ) ; } return new VElement ( document . importNode ( svgDoc . firstChild , true ) ) ; } el = document . createElementNS ( ns . xmlns , el ) ; // Set attributes. for ( var key in attrs ) { setAttribute ( <mask> , key , attrs [ key ] ) ; } // Normalize `children` array. if ( Object . prototype . toString . call ( children ) != '[object Array]' ) children = [ children ] ; // Append children if they are specified. var i = 0 , len = ( children [ 0 ] && children . length ) || 0 , child ; for ( ; i < len ; i ++ ) { child = children [ i ] ; el . appendChild ( child instanceof VElement ? child . node : child ) ; } return new VElement ( el ) ; }