• Hi there,
    since Gutenberg version 10.0.0 I am getting about 250 block validation error messages in the console on any page edit screen. Could someone maybe point me to the right direction on how to solve this?

    Error Examples:

    
    Block validation: Expected attribute 'class' of value 'wp-block wp-block-heading has-text-color', saw 'has-text-color'.
    
    Block validation: Block validation failed for 'core/heading' (Object).
    

    And another one:

    
    Content generated by 'save' function:
    
    <h2 class="wp-block wp-block-heading has-text-color" style="color:#ba0c49;font-size:38px">Which treats of the character and pursuits of the famous gentleman Don Quixote of La Mancha</h2>
    
    Content retrieved from post body:
    
    <h2 class="has-text-color" style="font-size:38px;color:#ba0c49">Which treats of the character and pursuits of the famous gentleman Don Quixote of La Mancha</h2>
    

    First I do not know where this “post body” seems to come from. I looked in my database and there is nothing with that string in there.

    I am basically adding the default block classes like so to all blocks (also core blocks):

    
    // make sure all block have a specific block class
    function addCoreClassName(settings, name) {
      return lodash.assign({}, settings, {
        supports: lodash.assign({}, settings.supports, {
          className: true
        }),
      });
    }
    
    wp.hooks.addFilter(
        'blocks.registerBlockType',
        'spk-gutenberg/class-names/core',
        addCoreClassName
    );
    
    // add wp-block to all gutenberg blocks for consistent styling
    function addClassName(props) {
      props.className = 'wp-block ' + props.className;
      return props;
    }
    
    wp.hooks.addFilter(
        'blocks.getSaveContent.extraProps',
        'spk-gutenberg/class-names/base',
        addClassName
    );
    

    Until 10.0.0 this never caused any errors.

    What do I need to make this work without errors? My whole theme styling relies on being able to add additional attributes to any kind of blocks.

    I am grateful for any help.

The topic ‘Block validation errors in console since version 10.0.0’ is closed to new replies.