[Webkit-unassigned] [Bug 9336] New: REGRESSION: assigning a click handler with setAttribute does not work.
bugzilla-daemon at opendarwin.org
bugzilla-daemon at opendarwin.org
Tue Jun 6 16:07:28 PDT 2006
http://bugzilla.opendarwin.org/show_bug.cgi?id=9336
Summary: REGRESSION: assigning a click handler with setAttribute
does not work.
Product: WebKit
Version: 420+ (nightly)
Platform: Macintosh
OS/Version: Mac OS X 10.4
Status: NEW
Severity: normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at opendarwin.org
ReportedBy: oster at google.com
I was editing a DOM tree, in Javascript and I noticed that:
newNode.onclick = button.onclick;
did copy the click handler from my old node 'button' to my new one, while
newNode.setAttribute('onclick', button.onclick);
did not. Both forms worked in shipping Safari.
Reduced example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<style type="text/css">
<!--
// This first entry is a sacrifice. The first entry appears to be a no-op,
// but we need it so the following entries will be evaluated.
.sacrificial {
}
.ared {
color: red;
}
.firstwords {
font-size: x-large;
font-variant: small-caps;
}
-->
</style>
<script><!--
// debug this in a javascript page.
function EF_ButtonInputNode(butId){
var button = document.getElementById(butId);
if (button.tagName === 'BUTTON') {
var newNode = document.createElement('input');
newNode.setAttribute('type','button');
newNode.value = button.innerText;
newNode.setAttribute('id', button.id);
newNode.onclick = button.onclick; // <- works in webkit
// newNode.setAttribute('onclick', button.onclick); // <- doesn't work in
webkit
var parent = button.parentElement;
parent.replaceChild(newNode, button);
}
}
function GoLoad(){
var id1 = document.getElementById('p1');
id1.innerHTML = '<b>Hello world from javascript.</b> Css should make the
title <span class="ared">red</span>.';
EF_ButtonInputNode('but1');
}
var helloCount = 1;
function DoHelloThere(){
var id1 = document.getElementById('hello target');
id1.innerHTML += helloCount++ + ' Hello<br>';
}
// --></script>
<title>a</title>
</head>
<body onLoad="GoLoad()">
<p><span class="ared firstwords">This span should be red, smallcaps.</span></p>
<p id="p1">a
</p>
<p id="p2">this is the button I want to change to a standard button:
<button id="but1" class="abutton" onClick="DoHelloThere()">Hello there</button>
</p><p><span id="hello target"></span></p>
</body>
</html>
--
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list