Reputation: 679
I have a question about DOMAttrModified. Which changes to an HTML Element properties triggers the DOMAttrModified event (specifically interested in Firefox, but an answer that applies to other browsers might suffice too)?
I have the following test case :
var elem = document.createElement('input');
document.body.appendChild(elem);
elem.id = 'inputId'; // triggers DOMAttrModified
elem.type = 'text'; // triggers DOMAttrModified
elem.value = 'inputValue'; // DOES NOT trigger DOMAttrModified
elem.lang = 'en'; // triggers DOMAttrModified
If I change elem.value to elem.defaultValue, then a DOMAttrModified does get triggered. Is there a comprehensive list somewhere? So far I have found HTMLInputElement's 'value' and 'checked' and HTMLOptionElement's 'selected' property not trigerring DOMAttrModified. Are there any other?
The answer at DOMAttrModified visual attributes does NOT seem to be completely correct, as 'value' is also an attribute.
Thanks, Sunil
Upvotes: 1
Views: 2285
Reputation: 809
Please also note that NO DOMAttrModified events will be fired when the 'disabled' attribute is set. So if your event is not firing, that could be the reason. This also goes for the IE-only 'onPropertyChange' event.
Upvotes: 3
Reputation: 35064
The DOM value
property doesn't change the HTML value
markup attribute. The DOM defaultValue
does. DOMAttrModified
fires when markup attributes change, so on setAttribute
/removeAttribute
calls and on any property set that changes an attribute.
Upvotes: 3