Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#29767 closed defect (bug) (fixed)

Quicktags instances loop check for instance '0'

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


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 ) 


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:
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 10 years ago.

Download all attachments as: .zip

Change History (4)

10 years ago

#1 @afercia
10 years ago

  • Keywords has-patch added

#2 @azaozz
10 years ago

  • Milestone changed from Awaiting Review to 4.1

Patch looks good.

#3 @azaozz
10 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.