Skip to content

Block validation issue  #39051

@delowardev

Description

@delowardev

Description

Previously reported in #38978

In the save function if someone uses an anchor tag (a) with target='_blank' attribute, it shows the Attempt Block Recovery screen on every reload.

Cause:

if there is a target='_blank' in the anchor tag, it adds rel='noopener' in the block.originalContent automatically which causes the block validation error.

Please check the code snippet below:

When there is a target attribute, here block.originalContent gets rel attribute but generatedBlockContent doesn't.

const isValid = isEquivalentHTML(
block.originalContent,
generatedBlockContent,
logger
);

cc: @talldan

Step-by-step reproduction instructions

  1. Create a custom block
  2. In the save function add an anchor tag with target attribute and don't add rel attribute
  3. Save this block in the editor and reload.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress: 5.9.1
  • Gutenberg: 12.7.0-rc.1

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions