Every line of 'svg appendchild' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
10 append(el) { 11 if (!(el instanceof GraphSvg)) { 12 el = new GraphSvg(el); 13 } 14 this.node.appendChild(el.node); 15 return el; 16 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
301 add(element) { 302 this.element.appendChild(element); 303 }
6 export function addSvg (el, binding, vnode) { 7 let classNames = ['icon'] 8 const id = binding.expression || vnode.data.attrs.symbol 9 let svg = el 10 11 // span or svg ? 12 if (vnode.tag === 'span') { 13 // add SVG element 14 svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') 15 el.appendChild(svg) 16 } 17 18 // add classes to wrapper 19 classNames.push(`icon--${id}`) 20 classNames.forEach(function (className) { 21 el.classList.add(className) 22 }) 23 24 // add title to SVGs 25 const title = document.createElementNS('http://www.w3.org/2000/svg', 'title') 26 27 title.textContent = id 28 svg.appendChild(title) 29 30 // Add the <use> element to <svg> 31 const href = `#icon--${id}` 32 const use = document.createElementNS('http://www.w3.org/2000/svg', 'use') 33 34 use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', href) 35 svg.appendChild(use) 36 }