WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#29767 closed defect (bug) (fixed)

Quicktags instances loop check for instance '0'

Reported by: afercia Owned by: azaozz
Milestone: 4.1 Priority: normal
Severity: normal Version: 4.0
Component: Editor Keywords: has-patch
Focuses: javascript Cc:

Description

While checking for a way to count Quicktags instances, I noticed that in the instances loop the check for the instance '0' was changed in strict equality I guess to make JSHint happy, see 26212:
changed from

if ( inst == 0 ) 

to

if ( inst === 0 )

AFAIK JavaScript Object property keys (names) are always string and this always evaluates to false so in the default Edit Post screen the loop runs 3 times:
0
content
replycontent
Proposed patch checks for a string and uses "Yoda" style. Fixes a small typo in the doc.

Attachments (1)

29767.patch (1.1 KB) - added by afercia 5 years ago.

Download all attachments as: .zip

Change History (4)

@afercia
5 years ago

#1 @afercia
5 years ago

  • Keywords has-patch added

#2 @azaozz
5 years ago

  • Milestone changed from Awaiting Review to 4.1

Patch looks good.

#3 @azaozz
5 years ago

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

In 29889:

Quicktags: fix strict check for instance['0'], props afercia, fixes #29767

Note: See TracTickets for help on using tickets.