Jan 12 2013
Extending the DOM
- It doesn’t work very well/at all in IE
- It is possible to run into conflict, such as if a framework uses
Document.prototype.hideand a browser then implements a
hidefunction on document elements
- Browsers implement things in wildly different ways
However, I haven’t seen anyone ask these questions. 1) if I wanted to extend the DOM, how would I do it safely? Besides the obvious use of a wrapper, how would I natively add a function, such as
hide to the DOM as a whole, safely? And, 2) If it’s not possible to implement it safely, what are the specific reasons? Can I implement checks, such as checking
typeof Document.prototype.hide == 'undefined' before implementing my own function on the prototype?
In other words, explain to me how I can extend the DOM safely and what I could do to make sure that if a browser were to make the
hide function, what I could do to not make my code have to be completely reworked.