Closed Bug 394568 Opened 18 years ago Closed 17 years ago

DOMAttrModified doesn't fire for certain attributes of an HTML input

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: franz.erlendorf, Unassigned)

Details

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6 When I add an event listener for "DOMAttrModified" on an input, it doesn't fire for attributes like "value" or "checked". Reproducible: Always
It fires when the attributes are set with SetAttribute(), but not otherwise.
(In reply to comment #1) > It fires when the attributes are set with SetAttribute(), but not otherwise. > Are you thinking that typing into the field changes the value attribute? It doesn't.
Confirmed, try this HTML page (tested on Firefox 2.0.0.9, Mac OS X Tiger): <html> <head> </head> <body> <p>Typical form <form action="http://freshmeat.net" onsubmit=""> <input id="username" name="username" type="text" value="testuser"> <input id="password" name="password" type="password" value="testpass"> <input type="submit"/> </form> </body> <script type="text/javascript"> function onAttributeChanged(event) { alert("The attribute for " + event.target.id + " changed!"); } function onTimeout() { document.getElementById("username").setAttribute("value", "whatever"); document.getElementById("password").value = ""; } setTimeout(onTimeout, 3000); document.getElementById("username").addEventListener("DOMAttrModified", onAttributeChanged, false); document.getElementById("password").addEventListener("DOMAttrModified", onAttributeChanged, false); </script> </html>
Oops, forget to mention: I observed that an alert popped up for username (which was changed using setAttribute) but not for password (which was changed using value).
> I observed that an alert popped up for username (which was changed using > setAttribute) but not for password (which was changed using value). > That's correct behaviour then.
> That's correct behaviour then. According to the DOM standard, the event is "Fired after an Attr has been modified on a node" (http://www.w3.org/TR/DOM-Level-2-Events/events.html). If an attribute of the DOM changed (and formElement.value = "..." does change the DOM), then the event should be fired.
(In reply to comment #7) > and formElement.value = "..." does change the DOM No, it does not.
OS: Windows Vista → All
Hardware: PC → All
Attached file testcase
Per DOM Level 2 HTML setting .value or .checked don't change the attribute values
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: