Open Bug 616171 Opened 14 years ago Updated 2 years ago

Update named item resolution on HTMLDocument to spec changes

Categories

(Core :: DOM: Core & HTML, defect, P5)

defect

Tracking

()

People

(Reporter: myohann, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 AskTbARS/3.9.1.14019 Firefox/3.6.12 (.NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 AskTbARS/3.9.1.14019 Firefox/3.6.12 (.NET CLR 3.5.30729) Sample test code html> <head> <style type="text/css"> <script type="text/javascript"> function test(){ alert("Hello"); } </script> </head> <body> <img id="test" src="<insert_image_here>" onclick="test()" /> </body> </html> Reproducible: Always Steps to Reproduce: 1.<img id="test" src="<insert_image_here>" onclick="test()" /> id=test function name is test 2.click on image 3.Nothing happens Actual Results: Nothin Happens Expected Results: Alert message saying Hello. This code works in IE 8.
Attached file testcase
The button and the span is to show that it works like intended on other elements. * first image calls the functions according to the str. * the second image calls the function with window.link() (this works) * the third image calls alert(typeof(link)) showing that its actually the image element itself (well it only shows that its an object, but anyway) * the forth image uses mouseover to show that its the same there * This is parity opera. * In Chrome the its undefined so the function doesn't work, but its not the image either Though I'm not sure what should happen according to specs, can't find anything about this at all.
I'm going to go out on a limb and confirm this... lets see what happens.
Status: UNCONFIRMED → NEW
Component: General → Event Handling
Ever confirmed: true
OS: Windows XP → All
Product: Firefox → Core
Hardware: x86 → All
Summary: if an element's id attribute is the same as a name of a function and if you call that function on the onclick event the call wouldn't work → The id of an image tag becomes an object in its inline events, preventing global functions with same name from working
Version: unspecified → Trunk
QA Contact: general → events
Per spec, I believe our behavior _was_ correct. I think the spec has changed some. In particular, see http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-content-attributes, the "Lexical Environment Scope" part. In particular, barewords in an inline event handler are first looked up on the node itself, then on its <form>, if any, then on the Document, and finally on the Window. In the attached testcase, document.link3 is an HTMLImageElement in Gecko and in Opera (but |undefined| in Webkit, as you noted, even though the property exists; this is a bug in Webkit which you may want to report as well). The reason it's an HTMLImageElement is due to http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-nameditem and http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-nameditem-filter The filter used to just take all <img> elements with an id attribute; it looks like the "and also has a name" thing has been added. We should do that, I guess.
Component: Event Handling → DOM
QA Contact: events → general
Summary: The id of an image tag becomes an object in its inline events, preventing global functions with same name from working → Update named item resolution on HTMLDocument to spec changes
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: