I do a lot of operations on objects retrieved by querySelector() and
simillar DOM methods, so I thought it would be nice to extend the
built-in Element object with some useful methods and properties.

So far I didn't have any problems when adding new methods to
prototypes, but the things are not so obvious to me when I'm trying to
add new properties.

For example, I would like to add Element.prototype.disabled property
that would be set to true if the given element has class "disabled"
and to false otherwise. My first thought was to alter the constructor
function, but it's not feasible in this case because it's a built-in
object. Another (probably silly) idea was to do this:

Element.prototype.disabled = (function() {
   if (this.hasClass('disabled') {
     return true;
  } else {
     return false;
  }
})();

which didn't work as well.

Could you give me some hints what is the proper way to achieve may goal?

Thanks in advance for any help!

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to