WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#31901 closed defect (bug) (fixed)

JS error while post editing

Reported by: m_i_n Owned by: azaozz
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.2
Component: TinyMCE Keywords: has-patch commit
Focuses: javascript Cc:

Description

Hi,
since version WP 4.2 beta 2 (probably), there is an error in JS console while editing post: http://i.imgur.com/IE96L5K.png (TypeError: c is undefined).
It makes editing post/page basically impossible.
It doesn't occur always, though. Mostly after full page refresh (ctrl+f5), but not always. Often enough to make it impossible to work on posts.
My test environment is:

  • WP 4.2-beta4-32021
  • standard theme (doesn't matter which one)
  • dummy content imported
  • all plugins off

Attachments (1)

31901.patch (1.7 KB) - added by azaozz 4 years ago.

Download all attachments as: .zip

Change History (12)

#1 @ocean90
4 years ago

  • Component changed from General to TinyMCE
  • Focuses ui administration removed
  • Keywords reporter-feedback added

Could you please test with SCRIPT_DEBUG true and report the error again? Does it happen in other browers too?

#2 @m_i_n
4 years ago

It's the same error in other browser (Chrome): http://i.imgur.com/BTu8DNq.png
I've noticed the problem disappears when you activate SCRIPT_DEBUG mode.
So my guess is, it might be caused by JS minification.

Last edited 4 years ago by m_i_n (previous) (diff)

#3 @iseulde
4 years ago

  • Keywords reporter-feedback removed

#4 follow-up: @m_i_n
4 years ago

I've made new test on WP 4.2 RC 1. Clean install, all default. Same problem.
Works fine only with SCRIPT_DEBUG mode on.

#5 in reply to: ↑ 4 @azaozz
4 years ago

  • Milestone changed from Awaiting Review to 4.2

Finally was able to reproduce this. Seems caused by "too fast" loading of the editor when reloading the page :)

Happens in the wpemoji plugin. The reason seems to be that window.twemoji is not defined yet by the time the TinyMCE wpemoji plugin is initialized, as the editor JS is in the browser's memory cache at that point. Calling window.twemoji directly in the plugin's methods seems to fix it.

@azaozz
4 years ago

#6 @azaozz
4 years ago

In 31901.patch: use window.twemoji directly in the TinyMCE "wpemoji" plugin. Gives a chance to the browser to load twemoji.

#7 @Lokimo
4 years ago

#31993 was marked as a duplicate.

#8 @iseulde
4 years ago

Looks good, though ideally window.twemoji needs to be defined in the loader imo.

#9 @azaozz
4 years ago

If we define window.twemoji before loading it, we will have to add dummy functions for all of its methods and keep that in sync when updating/maintaining. Not sure we need to go that way, but lets discuss in 4.3 :)

#10 @ocean90
4 years ago

  • Keywords has-patch commit added

31901.patch works for me too.

#11 @azaozz
4 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 32142:

TinyMCE: use window.twemoji directly in the wpemoji plugin. Gives a chance to the browser to lazy load twemoji.js when reloading the page.
Fixes #31901.

Note: See TracTickets for help on using tickets.