How to use the svgo/lib/svgo/jsAPI function in svgo

To help you get started, we’ve selected a few svgo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakearchibald / svgomg / src / js / svgo-worker / index.js View on Github external
function clone(obj) {
    if (typeof obj !== 'object' || obj === null) {
      return obj;
    }

    if (clones.has(obj)) {
      return clones.get(obj);
    }

    let objClone;

    if (obj.constructor === JSAPI) {
      objClone = new JSAPI({}, obj.parentNode);
      clones.set(obj, objClone);

      if (obj.parentNode) {
        objClone.parentNode = clone(obj.parentNode);
      }
      cloneKeys(objClone, obj);
    }
    else if (
      obj.constructor === CSSClassList ||
      obj.constructor === CSSStyleDeclaration ||
      obj.constructor === Object ||
      obj.constructor === Array
    ) {
      objClone = new obj.constructor();
      clones.set(obj, objClone);
      cloneKeys(objClone, obj);
github mapbox / svg-to-geojson / src / web-workers / svgo.js View on Github external
function clone(obj) {
    if (typeof obj !== 'object' || obj === null) {
      return obj;
    }

    if (clones.has(obj)) {
      return clones.get(obj);
    }

    let objClone;

    if (obj.constructor === JSAPI) {
      objClone = new JSAPI({}, obj.parentNode);
      clones.set(obj, objClone);

      if (obj.parentNode) {
        objClone.parentNode = clone(obj.parentNode);
      }
      cloneKeys(objClone, obj);
    }
    else if (
      obj.constructor === CSSClassList ||
      obj.constructor === CSSStyleDeclaration ||
      obj.constructor === Object ||
      obj.constructor === Array
    ) {
      objClone = new obj.constructor();
      clones.set(obj, objClone);
      cloneKeys(objClone, obj);