Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55484 new defect (bug)

class-wp-editor.php line 1697

Reported by: karin2's profile karin2 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9.2
Component: Editor Keywords:
Focuses: javascript Cc:

Description

Line 1697 of class-wp-editor.php should end with a semicolon.

Otherwise, if the page is compressed errors are in the console and the editor isn't functioning correctly.

Change History (2)

#1 follow-up: @dd32
2 years ago

Welcome to Trac @karin2!

For others, here's the code in question:
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-editor.php?marks=1697-1699&rev=52978#L1692

And here's what it'd look like if compressed..

... window.wpActiveEditor = id;}}}}if ( typeof tinymce !== 'undefined' ) { ...

My undertstanding is that a ; is not required in this case, as it's implicit after } or newlines.

@karin2 Can you provide information as to what browser & error message you're seeing is?

#2 in reply to: ↑ 1 @karin2
2 years ago

Keep in mind that all JavaScript for this area is compressed into one line. Thus causing the error.

Code causing error:


var initialize = function(){...}if (typeof tinymce !== 'undefined'){...


Browsers tested:

Firefox:
98.0.2 (64-bit)


Uncaught SyntaxError: unexpected token: keyword 'if'


Chrome
100.0.4896.60 (64-bit)


Uncaught SyntaxError: Unexpected token 'if'


Most likely all other browsers as well. Since when the JavaScript is compressed, ie: one line, there is no semicolon to define the ending of the statement.

Portions of the TinyMCE editor is broken, as well. Endless loader and the TinyMCE buttons are not displayed.
When the semicolon is applied, as below, the error is gone and everything is working.

The Fix: (Adding Semicolon)


var initialize = function(){....};if (typeof tinymce !== 'undefined'){....


Note: See TracTickets for help on using tickets.