Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#22888 closed defect (bug)

Block <a> tags are getting stripped from the Editor — at Version 7

Reported by: georgestephanis Owned by:
Milestone: 3.5.1 Priority: high
Severity: major Version: 3.5
Component: Editor Keywords: commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Steps to duplicate:

  1. Make a new post.
  2. Have a single line of text saying 'Foo foo foo'.
  3. Change it to a h1 block.
  4. Select the line.
  5. Add a hyperlink to example.com
  6. Switch to the Text tab.
  7. Switch back to the Visual Editor.


Basically since we've incorporated the HTML5 Schema for TinyMCE, <a> tags have been upgraded to a block-level element. So TinyMCE will wrap the <h1> tag with the <a> tag -- as opposed to the opposite in 3.4.

Then we go in and strip it out (because reasons).

Let's stop stripping out valid tags that we're adding via the editor in 3.5.1

Change History (7)

#1 @nacin
5 years ago

Is this a regression in 3.5?

What's stripping it?

#2 @georgestephanis
5 years ago

It's a regression insofar as the new HTML5 schema in TinyMCE is allowing <a> tags to be wrapped around block level tags, like <h1> (which didn't used to happen) -- but the filter that passes through the code when loading it into the visual editor isn't recognizing that and stripping it out (which always used to happen)

So the change from 3.4.2 isn't that we're doing something new in a given situation per se, we're just letting users get into that situation whereas they couldn't previously.

#3 @nacin
5 years ago

  • Milestone changed from Awaiting Review to 3.5.1
  • Priority changed from normal to high
  • Severity changed from normal to major

#4 @markjaquith
5 years ago

Suggested fix for 3.5.1: just make <a> only accept inline child elements (like before).

#5 @azaozz
5 years ago

Yes, caused by setting all block elements (headers, paragraphs, tables, etc.) as valid children of <a>. +1 to @markjaquith's suggestion.

Also as some elements are both phasing and flow, there's no need to repeat them in the "children" strings (B = phasing, C = flow), or perhaps better to set C = all flow elements as per W3C and only use [C] for elements that can contain flow.

Last edited 5 years ago by azaozz (previous) (diff)

#6 @azaozz
5 years ago

As far as I see no other elements have changed behavior in TinyMCE. <ins> and <del> still can't contain blocks but that's the same as in 3.4.

#7 @SergeyBiryukov
5 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.