Using object wrappers to extend the JavaScripts DOM?
<p>I'm trying to add simple functions to the JavaScript DOM, e.g. an <code>addClass</code> function, I implemented this first with the following code:</p>

<pre><code>Element.prototype.addClass = function(className) {
    this.className += ' ' + className;
}; 
</code></pre>

<p>However after much reading (<a href="http://perfectionkills.com/whats-wrong-with-extending-the-dom/" rel="nofollow">http://perfectionkills.com/whats-wrong-with-extending-the-dom/</a> was good) it seems this is a terrible way to extend the DOM for a number of reasons.</p>

<p>The above article states:</p>

<blockquote>
  <p>One of the most common alternatives to this whole mess of DOM
  extension is <strong>object wrappers</strong></p>
</blockquote>

<p>Which is fine, apparently the general consensus is to use Object wrappers if you want to extend the DOM. The problem is I can't find any good examples anywhere on how you actually use object wrappers to extend the DOM ...</p>

<p>Can anybody give me an example of how to do so? Maybe using the above code?</p>
