function fn(root, params) {
  const stylesheet = collectStylesheet(root);
  const attributesInStylesheet = extractAttributesInStylesheet(stylesheet);

  return {
    element: {
      enter: (node) => {
        const elemConfig = elems[node.name];
        if (!elemConfig) {
          return;
        }

        // Special cases

        // Removing deprecated xml:lang is safe when the lang attribute exists.
        if (
          elemConfig.attrsGroups.has('core') &&
          node.attributes['xml:lang'] &&
          !attributesInStylesheet.has('xml:lang') &&
          node.attributes['lang']
        ) {
          delete node.attributes['xml:lang'];
        }

        // General cases

        elemConfig.attrsGroups.forEach((attrsGroup) => {
          processAttributes(
            node,
            attrsGroupsDeprecated[attrsGroup],
            params,
            attributesInStylesheet,
          );
        });

        processAttributes(
          node,
          elemConfig.deprecated,
          params,
          attributesInStylesheet,
        );
      },
    },
  };
}
Remove deprecated attributes.

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