question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TinyMCE stripping empty <div>s inside <td>s

See original GitHub issue

Using WordPress trunk (4.5-alpha-36510) with TinyMCE 4.3.3 (2016-01-14).

TinyMCE is stripping empty <div>s inside s.

Before:

<table>
<tr>
<td>
<div class="bar" style="width:100%; background-color:#ff2700"></div>
</td>
</table>

After:

<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>

Outside a table, this is preserved as expected.

<div class="bar" style="width:100%; background-color:#ff2700"></div>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Daijoboucommented, Mar 10, 2016

I have this problem too with a custom empty span but with a class. Tinymce should only remove empty tags which have not a class in it.

0reactions
spockecommented, May 24, 2018

You can configure it to retain everything: http://fiddle.tinymce.com/Zsgaab by default we remove empty elements since they serve little purpose and is hard to edit in a WYSIWYG environment when there is no way to place the caret inside them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Div/span in table-td is removed. Pasting in TinyMCE
As said in the comments: TinyMCE removes all empty elements, so add some content to the elements and TinyMCE wouldn't remove the elements ......
Read more >
Content filtering options | Docs - TinyMCE
This example string tells TinyMCE to remove all elements that are not a 'a, strong, div or br' element, convert 'b' elements to...
Read more >
How to Prevent Empty DIVs from being Removed in ... - TinyMCE
Okay, I've narrowed the problem down to the mceInsertContent function. mceInsertContent is removing the empty div. If I manually copy/page the empty divs...
Read more >
Empty div containers are automatically removed in TinyMCE
// Remove these if they are empty by default each(split('ol,ul,li,sub,sup,blockquote,tr,div,span,font,a,table,tbody'), function(name) { elements ...
Read more >
[SOLVED] TinyMCE is removing DIVS from the code
When any of the page content is edited using the TinyMCE editor and saved the DIVS are removed. It may be because the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found