fn = (root, params, info) => {
  if (
    !(Array.isArray(params.classNames) && params.classNames.length !== 0) &&
    !params.className
  ) {
    console.error(ENOCLS);
    return null;
  }
  const classNames = params.classNames || [params.className];
  return {
    element: {
      enter: (node, parentNode) => {
        if (node.name === 'svg' && parentNode.type === 'root') {
          const classList = new Set(
            node.attributes.class == null
              ? null
              : node.attributes.class.split(' '),
          );
          for (const className of classNames) {
            if (className != null) {
              const classToAdd =
                typeof className === 'string'
                  ? className
                  : className(node, info);
              classList.add(classToAdd);
            }
          }
          node.attributes.class = Array.from(classList).join(' ');
        }
      },
    },
  };
}
Add classnames to an outer <svg> element. Example config:

plugins: [
  {
    name: "addClassesToSVGElement",
    params: {
      className: "mySvg"
    }
  }
]

plugins: [
  {
    name: "addClassesToSVGElement",
    params: {
      classNames: ["mySvg", "size-big"]
    }
  }
]

@author April Arcus

@type {import('../lib/types.js').Plugin<AddClassesToSVGElementParams>}