Open Bug 248324 Opened 21 years ago Updated 3 years ago

in onclosetab attribute (event handler) of tabs 'this' refers to the close button, not the <tabs> element

Categories

(Core :: XUL, defect)

defect

Tracking

()

People

(Reporter: laurent, Unassigned)

References

()

Details

(Keywords: testcase)

User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.7) Gecko/20040614 Firefox/0.9 Build Identifier: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.7b) Gecko/20040316 Look at http://xulfr.org/sources/bugs/onclosetab/testbugtab.xul. Click on the button, on right, to close the tab 'test'. So it generate a 'closetab' event and execute the script in onclosetab attribute of the tabs element. in this code, 'this' doesn't represent tabs object but a toolbarbutton object (in fact, the button which generate closetab event). It's not logic and it's a bad thing in a xbl (we must do parentNode.parentNode.parentNode.... to access to tabs object :-/ ) Reproducible: Always Steps to Reproduce: see source code at http://xulfr.org/sources/bugs/onclosetab/testbugtab.xul Expected Results: in onclosetab attribute, 'this' must be represent tabs object instead of the button which generate closetab event.
This is an automated message, with ID "auto-resolve01". This bug has had no comments for a long time. Statistically, we have found that bug reports that have not been confirmed by a second user after three months are highly unlikely to be the source of a fix to the code. While your input is very important to us, our resources are limited and so we are asking for your help in focussing our efforts. If you can still reproduce this problem in the latest version of the product (see below for how to obtain a copy) or, for feature requests, if it's not present in the latest version and you still believe we should implement it, please visit the URL of this bug (given at the top of this mail) and add a comment to that effect, giving more reproduction information if you have it. If it is not a problem any longer, you need take no action. If this bug is not changed in any way in the next two weeks, it will be automatically resolved. Thank you for your help in this matter. The latest beta releases can be obtained from: Firefox: http://www.mozilla.org/projects/firefox/ Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html Seamonkey: http://www.mozilla.org/projects/seamonkey/
I see the same behaviour that reporter describes, on SeaMonkey Linux. (Sorry if in fact it's not a but)
Same behavior on Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a1) Gecko/20050927 Firefox/1.6a1
OS: Windows NT → All
Confirming, this happens because the onclosetab attribute is simply forwarded to the close-button's oncommand attribute: http://lxr.mozilla.org/seamonkey/source/toolkit/content/widgets/tabbox.xml#441 For the same reason attaching a 'closetab' handler using addEventListener will not work. If desired, this could be fixed by registering a 'oncommand' handler for the close-button and doing the usual initEvent/dispatchEvent/new Function(...).call() sequence - that's how most of our custom XBL attribute handlers work. Neil?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
Hardware: PC → All
Summary: in onclosetab attribute of tabs : 'this' doesn't represent tabs element → in onclosetab attribute (event handler) of tabs 'this' refers to the close button, not the <tabs> element
(In reply to comment #0) >It's not logic and it's a bad thing in a > xbl (we must do >parentNode.parentNode.parentNode.... to access to tabs object That's not strictly true, you can use document.getBindingParent(this) (In reply to comment #4) >If desired, this could be fixed by registering a 'oncommand' handler >for the close-button and doing the usual initEvent/dispatchEvent/new >Function(...).call() sequence This is getting repetitive - we could really do with a method to create and dispatch a custom event on a XUL element.
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: xptoolkit.widgets
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.