Element#set
-
MadRabbit
- State changed from new to resolved
Following the less-surprize principle I've made this method to set the actual attributes directly via the 'setAttribute' method.
NOTE: now it won't set unsupported attributes, like say if you try to assign a 'name' to a DIV element or something like that. So in case if you need to assign some custom properties of yours, you'll have to assign them manually to the instance, not through the 'set' method or the constructor.
The only exception is the TEXTAREA.value property, in order to support textareas simultaneously with any other input element, the 'set' method will assign its value as a property not as an attribute.
-
MadRabbit
- State changed from open to resolved
Ticket revisited,
Evidently the attributes that are not supported as properties does not exist on an element instance, so I used this fact for this case, like that
for (var key in hash) { if (this[key] === undefined) this.setAttribute(key, ''+hash[key]); this[key] = hash[key]; }This way it works both with normal and custom attributes, handles standard attributes that are not available as properties, and it also works faster than previous solution.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.