Last Comment Bug 315857 - <textbox>: Inside the "onfocus" event, the 'this' object refers to the HTMLInputElement and not the texbox XULelement
: <textbox>: Inside the "onfocus" event, the 'this' object refers to the HTMLIn...
: testcase
Product: Core
Classification: Components
Component: XUL (show other bugs)
: Trunk
: x86 Windows XP
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Neil Deakin
Depends on:
  Show dependency treegraph
Reported: 2005-11-10 05:56 PST by Didier Moraine
Modified: 2012-03-04 08:05 PST (History)
4 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Textbox with a onfocus event (614 bytes, application/vnd.mozilla.xul+xml)
2005-11-10 05:57 PST, Didier Moraine
no flags Details

Description Didier Moraine 2005-11-10 05:56:45 PST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 (ax)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 (ax)

There is a difference of context for the 'this' object according to which event you use.
Inside the onclick event, 'this' refers to the <texbox> XULElement.
Inside the onfocus event, 'this' refers to the <html:input> HTMLInputElement part of the texbox binding.

Reproducible: Always

Steps to Reproduce:
1. In a XUL page, create a texbox like this:
<textbox onfocus="alert('onfocus\nthis = ' + this);" onclick="alert('onclick\nthis = ' + this)"/>
2. Click on the textbox.

Expected Results:  
I expect that the 'this' object refers also to the texbox XULElement inside the onfocus event.

This happend in Firefox 1.0.7 and in Firefox 1.5RC1
Comment 1 Didier Moraine 2005-11-10 05:57:51 PST
Created attachment 202505 [details]
Textbox with a onfocus event
Comment 2 Nickolay_Ponomarev 2006-01-06 09:58:59 PST
Confirming, this is similar to bug 248324. This happens because the xul:textbox binding uses
 <html:input ... xbl:inherits="onfocus,onblur,..."/>
Comment 3 Peter Ross 2006-09-21 07:16:15 PDT
This bug has been fixed in firefox

As our workaround for this problem is no longer required.
Comment 4 John Mellor (Jomel) 2010-09-24 18:12:00 PDT
Probably a duplicate of Bug 313573.
Comment 5 2012-03-04 08:05:12 PST
This was resolved partially by bug 334216 (which allowed the event to fire with the right "this" object) and partially by bug 732738 (which removed the bogus version of the event that fired with the wrong "this" object). As I can't duplicate this against both bugs, I won't bother duplicating it against either.

Note You need to log in before you can comment on or make changes to this bug.