gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Converting To Blocks Looses Existing Anchor Tag Parameters

Open ChrisEdwardsCE opened this issue 8 years ago • 3 comments

Issue Overview

When converting an existing post to blocks, all anchor tag parameters are lost (with the exception of href). For example, target="_blank" is removed and also rel="nofollow" is removed. When converting to blocks, all existing HTML for an anchor tag should remain during a conversion to blocks.

Steps to Reproduce (for bugs)

  1. Have an anchor tag in an unconverted HTML block with taget="_blank" or rel="nofollow"
  2. Convert to blocks
  3. View as HTML
  4. Notice the target and rel have been removed.

Expected Behavior

When converting to blocks, all existing HTML for an anchor tag should remain during a conversion to blocks.

Current Behavior

When converting an existing post to blocks, all anchor tag parameters are lost (with the exception of href). For example, target="_blank" is removed and also rel="nofollow" is removed.

Possible Solution

Screenshots / Video

Related Issues and/or PRs

Todos

  • [ ] Tests
  • [ ] Documentation

ChrisEdwardsCE avatar Jan 16 '18 05:01 ChrisEdwardsCE

I also noticed converting from Classic Post to Blocks also loses class names.

Test

Create Classic Post with:

<p class="foo"> This is my foo paragraph. </p>

<table class="bar"> 
<tr><td> Foo </td><td> Bar </td></tr>
</table>

Open post in editor and convert to blocks, both class names are lost.

mkaz avatar Apr 05 '18 16:04 mkaz

Well also other attributes, for example ARIA roles and properties, get stripped out. For example, this:

Some text
<div role="aside">something here</div>
<span aria-hidden="true">hidden from AT</span>

is converted to:

<p>Some text something here
</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>hidden from AT</p>
<!-- /wp:paragraph -->

Maybe time to rename this issue 🙂

afercia avatar Jul 13 '18 06:07 afercia

I've closed this issue with #8125, as that addresses the target and rel attributes.

For the broader issue of howe we manage miscellaneous attributes (eg, ARIA), let's continue the conversation on #6878.

pento avatar Jul 25 '18 00:07 pento