_toDataURI (options = {}, callback) {
    // Setup default options
    options.scale = options.scale || 1;

    // Setup some SVG data
    const xmlns = 'http://www.w3.org/2000/xmlns/';

    // Inline images first
    this._inlineImages(() => {
      // Setup a container <div>
      const outer = document.createElement('div');

      // Clone the element
      const clone = this.element.cloneNode(true);

      // Setup some vars
      let width,
        height,
        svg;

      // If the element is an SVG we work out the size of the SVG using a variety of methods,
      //  depending on how the user has defined the size of their SVG
      if (this.element.tagName !== 'svg') {
        throw new Error('Invalid element provided, must be SVG');
      }

      // Get the width and height
      width = parseInt(this.element.viewBox.baseVal.width || clone.getAttribute('data-width') || clone.style.width);
      height = parseInt(this.element.viewBox.baseVal.height || clone.getAttribute('data-height') || clone.style.height);

      // Configure the clone's wrapper attributes
      clone.setAttribute('version', '1.1');
      clone.setAttributeNS(xmlns, 'xmlns', 'http://www.w3.org/2000/svg');
      clone.setAttributeNS(xmlns, 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
      clone.setAttribute('width', width * options.scale);
      clone.setAttribute('height', height * options.scale);
      clone.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
      outer.appendChild(clone);

      // Setup the SVG by adding the XML doctype
      const doctype = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';

      // Combine the doctype and the innerHTML of the cloned SVG to get the final product
      svg = doctype + outer.innerHTML;

      // Create the URI
      const uri = 'data:image/svg+xml;base64,' + helpers.svgToBase64(svg, window.btoa);

      // Run the callback
      callback(uri);
    });
  }
/**
   * Converts the element to a data URI
   *
   * @param {object} options - Configuration options
   * @param {function} callback - The callback to run after the element has been converted
   */
Converts the element to a data URI
@param {object} options - Configuration options
@param {function} callback - The callback to run after the element has been converted
Converts the element to a data URI @param { object } options - Configuration options @param { function } callback - The callback to run after the element has been converted
_toDataURI (options = {}, callback) {
    options.scale = options.scale || 1;
    const xmlns = 'http://www.w3.org/2000/xmlns/';
    this._inlineImages(() => {
      const outer = document.createElement('div');
      const clone = this.element.cloneNode(true);
      let width,
        height,
        svg;
      if (this.element.tagName !== 'svg') {
        throw new Error('Invalid element provided, must be SVG');
      }
      width = parseInt(this.element.viewBox.baseVal.width || clone.getAttribute('data-width') || clone.style.width);
      height = parseInt(this.element.viewBox.baseVal.height || clone.getAttribute('data-height') || clone.style.height);
      clone.setAttribute('version', '1.1');
      clone.setAttributeNS(xmlns, 'xmlns', 'http://www.w3.org/2000/svg');
      clone.setAttributeNS(xmlns, 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
      clone.setAttribute('width', width * options.scale);
      clone.setAttribute('height', height * options.scale);
      clone.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
      outer.appendChild(clone);
      const doctype = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
      svg = doctype + outer.innerHTML;
      const uri = 'data:image/svg+xml;base64,' + helpers.svgToBase64(svg, window.btoa);
      callback(uri);
    });
  }
_toDataURI ( options = { } , callback ) { options . scale = options . scale || 1 ; const xmlns = 'http://www.w3.org/2000/xmlns/' ; this . _inlineImages ( ( ) => { const outer = document . createElement ( 'div' ) ; const clone = this . element . cloneNode ( true ) ; let width , height , svg ; if ( this . element . tagName !== 'svg' ) { throw new Error ( 'Invalid element provided, must be SVG' ) ; } width = parseInt ( this . element . viewBox . baseVal . width || clone . getAttribute ( 'data-width' ) || clone . style . width ) ; height = parseInt ( this . element . viewBox . baseVal . height || clone . getAttribute ( 'data-height' ) || clone . style . height ) ; clone . setAttribute ( 'version' , '1.1' ) ; clone . setAttributeNS ( xmlns , 'xmlns' , 'http://www.w3.org/2000/svg' ) ; clone . setAttributeNS ( xmlns , 'xmlns:xlink' , 'http://www.w3.org/1999/xlink' ) ; clone . setAttribute ( 'width' , width * options . scale ) ; clone . setAttribute ( 'height' , height * options . scale ) ; clone . setAttribute ( 'viewBox' , '0 0 ' + width + ' ' + height ) ; outer . appendChild ( clone ) ; const doctype = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' ; svg = doctype + outer . innerHTML ; const uri = 'data:image/svg+xml;base64,' + helpers . svgToBase64 ( svg , window . btoa ) ; callback ( uri ) ; } ) ; }
Converts the element to a data URI
 @param {object} options - Configuration options
 @param {function} callback - The callback to run after the element has been converted
Converts the element to a data URI @param { object } options - Configuration options @param { function } callback - The callback to run after the element has been converted
// Setup default options // Setup some SVG data // Inline images first // Setup a container <div> // Clone the element // Setup some vars // If the element is an SVG we work out the size of the SVG using a variety of methods, //  depending on how the user has defined the size of their SVG // Get the width and height // Configure the clone's wrapper attributes // Setup the SVG by adding the XML doctype // Combine the doctype and the innerHTML of the cloned SVG to get the final product // Create the URI // Run the callback