Converting To Blocks Looses Existing Anchor Tag Parameters
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)
- Have an anchor tag in an unconverted HTML block with taget="_blank" or rel="nofollow"
- Convert to blocks
- View as HTML
- 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
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.
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 🙂
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.