WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#17368 closed defect (bug) (fixed)

Visual editor (TinyMCE) should respect empty html tags with attributes

Reported by: designsimply Owned by: azaozz
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.2
Component: TinyMCE Keywords: needs-patch
Focuses: Cc:

Description

The visual editor (TinyMCE) is no longer respecting empty html tags with attributes such as <br class="spacer_" /> or padded <p> tags like <p>&nbsp;</p>.

Steps to reproduce:

  1. Open a new post on a WordPress trunk install.
  2. Add the example code from below.
  3. Switch back and forth between the Visual and HTML editor tabs.
  • Expected: I expect the html in the example code to be preserved, i.e. the extra line break and empty paragraph spacing to be respected as long as they have attributes.
  • Actual: Padding is being removed when it shouldn't.

Example code:

<p>We should preserve padded Ps.</p>
<p>&nbsp;</p>
<p>And empty html tags with attributes.</p>
<p class="spacer_"></p>
<p>one</p>
<br class="spacer_" />
<p>two</p>
<br class="spacer_" />
<br class="spacer_" />
<p>three</p>
<br class="spacer_" />
<br class="spacer_" />
<br class="spacer_" />
<p>stop</p>

Tested with r17848 on Chrome 11 beta and Firefox 4.0.1.

Change History (4)

#1 @azaozz
6 years ago

  • Owner set to azaozz
  • Status changed from new to reviewing

#2 @ocean90
6 years ago

  • Milestone changed from Awaiting Review to 3.2

Output after a switch from HTML to Visual and back with example code from designsimply:

Trunk:

We should preserve padded Ps.

And empty html tags with attributes.

one

two

<br class="spacer_" />
three

<br class="spacer_" />
<br class="spacer_" />
stop

3.1.2:

We should preserve padded Ps.

&nbsp;

And empty html tags with attributes.
<p class="spacer_">&nbsp;</p>
one

<br class="spacer_" />

two

<br class="spacer_" />
<br class="spacer_" />

three

<br class="spacer_" />
<br class="spacer_" />
<br class="spacer_" />

stop

#3 @azaozz
6 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In [18064]:

Fix regression: the visual editor removes empty paragraphs, fix CSS for the spellchecker button, fixes #17368

#4 @azaozz
6 years ago

This is probably due to TinyMCE switching to new DOM serialization engine. The patch restores keeping of empty paragraphs in the visual editor but they are padded with &nbsp; when saving or switching to the HTML editor.

Note: See TracTickets for help on using tickets.