Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1339 closed defect (fixed)

Xinha config autofocus setting doesn't work correctly when specifying an ID

Reported by: nicholasbs Owned by: gogo
Priority: normal Milestone: 0.96
Component: Xinha Core Version: trunk
Severity: normal Keywords:


Setting xinha_config.autofocus to any non-empty string (e.g., "foo") will autofocus all editors, when it should only autofocus the editor whose text area has the ID "foo".

Change History (4)

comment:1 Changed 12 years ago by nicholasbs

Fixed in r1130

comment:2 Changed 12 years ago by nicholasbs

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

comment:3 Changed 12 years ago by mokhet

I totally disagree with this revision r1130.

Changing from

if ( variable )


if ( variable == true )

is not going to change anything. Anyone with a minimum javascript clue will see how futile this revision is.

comment:4 Changed 12 years ago by nicholasbs

I've tested this change in Firefox, IE, and Safari, and it does indeed make a difference. Previously, the condition would pass if xinha_config.autofocus was 'foo' (i.e., a non-empty string that evaluates to true), and this happened regardless of whether or not the ID actually matched. With r1130, the test xinha_config.autofocus == true fails (i.e., is false) when autofocus is set to "foo".

The only potential issue I can see is that since it uses == instead of ===, if a page includes multiple editors, and one of those editors has an ID of "1", then setting autofocus to '1' will pass, even for the editors with other IDs.

Am I missing something else here?

Note: See TracTickets for help on using tickets.