Bug 146823 - [testcase] Adding a unknown event listener makes this script return the wrong onclick value
Summary: [testcase] Adding a unknown event listener makes this script return the wrong...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: 3.5
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-15 16:58 UTC by Aldrik
Modified: 2008-04-26 00:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
The above testcase so you can easily go clicky click (958 bytes, text/html)
2008-04-25 23:04 UTC, A. Spehr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aldrik 2007-06-15 16:58:42 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    Unspecified Linux
OS:                Linux

This is a very strange one, took me a while to track it down...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>addEventListener bug</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<!--

function init(e) {
	if (e && e.type=='DOMContentLoaded') {
		alert('DOM Loaded');
	} else {
		alert(this); // Finding the currect object
		alert(this.onclick); // But not it's onclick value?
	}
}

function addOnclick(el, evt) {
	el.onclick=init;
}

if (document.addEventListener) {
	// Unknown even to Konqueror so should have no effect on the script.
	document.addEventListener('DOMContentLoaded', init, false);
	// But when removed, the script runs as it should.
}

function clickTest() {
	addOnclick(document.getElementsByTagName("p")[0]);
}

window.onload=clickTest;

//-->
</script>
</head>
<body>
<h1>Example</h1>
<p>Click me!</p>
</body>
</html>
Comment 1 Maksim Orlovich 2007-06-15 17:42:35 UTC
Doesn't have to be unknown, any addEventListener would do, I think --- it gets confused because the same listener function is used as both a legacy HTML-style listener and real one.. That code looks bogus, but I don't know what it's trying to do..
Comment 2 Aldrik 2007-06-15 23:22:24 UTC
Right you are any event messes it up (sorry I should have tested with some standard ones). Bogus code? Yeah I was just trying to show the bug, the propper script was a custom event listener & DOMReady script, which I then decided I'd make it trigger the click even of any #bookmark in the URL after the DOMReady scripts had loaded (it works quite nicely if I do say so myself :)).

Anyway none of the other browser I tested in (FF and Opera) have a problem with this. I've already worked around it, I just thought you amazing KDE Dev's (I'm a big fan ;)) would want to know.
Comment 3 Maksim Orlovich 2007-06-16 00:21:53 UTC
By bogus code I meant the one in KHTML, not your example :-)
Comment 4 A. Spehr 2008-04-25 23:04:13 UTC
Created attachment 24507 [details]
The above testcase so you can easily go clicky click

same testcase, easier to click

Is this supposed to work now?
Comment 5 A. Spehr 2008-04-26 00:14:54 UTC
fixed in SVN by vtokarev