AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
823 stars 168 forks source link

Block: Web components' `class` gets incorrectly transformed to `classname` #849

Closed arjendejong12 closed 8 months ago

arjendejong12 commented 11 months ago

I'm using the following web component in my view: <iconify-icon icon="<?php echo $icon; ?>" class="<?php echo $icon_classes; ?>"></iconify-icon> In the Gutenberg editor, this gets incorrectly transformed to:

image

The classes are not applied to the web component. Is this something that can be fixed in the plugin? Thanks!

arjendejong12 commented 8 months ago

Fixed this by using the acf_blocks_parse_node_attr JS filter:

acf.addFilter("acf_blocks_parse_node_attr", function (shortcut, nodeAttr) {
  if (nodeAttr.name === "class" && nodeAttr.value.indexOf("iconify") !== -1) {
    return {
      name: nodeAttr.name,
      value: nodeAttr.value,
    };
  }

  return shortcut;
});