Summary: | event instanceof MouseEvent throws exception | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> | ||||||||
Component: | JavaScriptCore | Assignee: | Sam Weinig <sam> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | ap, ggaren, mitz, sam | ||||||||
Priority: | P2 | ||||||||||
Version: | 420+ | ||||||||||
Hardware: | Mac | ||||||||||
OS: | OS X 10.4 | ||||||||||
URL: | http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Special_Operators:instanceof_Operator | ||||||||||
Attachments: |
|
Description
Eric Seidel (no email)
2006-09-01 22:44:50 PDT
Created attachment 11787 [details]
A few different instanceof tests
instanceof is a bit more broken than just Element.
I've attached a very simple testcase for instanceof. All six tests should return TRUE, but only the Object test returns TRUE; the others either return FALSE or error.
Comment on attachment 11787 [details] A few different instanceof tests <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>instanceof test</title> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/> </head> <script type="text/javascript"> // <![CDATA[ window.addEventListener('load', function() { document.getElementById('clickme').addEventListener('click', function(evt) { try { alert("Object: " + (evt instanceof Object)); } catch(e) { errstr(e); } try { alert("Event: " + (evt instanceof Event)); } catch(e) { errstr(e); } try { alert("MouseEvent: " + (evt instanceof MouseEvent)); } catch(e) { errstr(e); } try { alert("Element: " + (evt.target instanceof Element)); } catch(e) { errstr(e); } try { alert("HTMLElement: " + (evt.target instanceof HTMLElement)); } catch(e) { errstr(e); } try { alert("HTMLDivElement: " + (evt.target instanceof HTMLDivElement)); } catch(e) { errstr(e); } }, false); }, false); function errstr(e) { var errstr = ""; for(var i in e) { errstr += i + " = " + e[i] + "\n"; } alert(errstr); }; // ]]> </script> <body> <div id="clickme">Click here to test instanceof Object, Event, MouseEvent, Element, HTMLElement, and HTMLDivElement (one alert per test)</div> </body> </html> Created attachment 11788 [details]
Correct testcase.
Whoops. That button did not do what I thought it was going to do. Sorry about the spam.
This is because the global constructors don't have .prototype properties. See also Bug 12686 Comment #6. fixed in r19993. However we still get an error for instanceof MouseEvent because MouseEvent is not a constructor. (In reply to comment #6) > fixed in r19993. However we still get an error for instanceof MouseEvent > because MouseEvent is not a constructor. Same issue still occurs with r29032. Created attachment 18197 [details]
patch
|