Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created October 9, 2014 04:39
Show Gist options
  • Save jonathantneal/a83fcd7d26782fbab58e to your computer and use it in GitHub Desktop.
Save jonathantneal/a83fcd7d26782fbab58e to your computer and use it in GitHub Desktop.
DOM2 polyfill list for all browsers
// Window (Internet Explorer 6 - 7, Opera 11.6, Safari 4 - 5)
(this.Window = this.constructor = function Window() {}).prototype = this;
// Window.chrome (Chrome 14-18, Safari 5.1)
this.Window = this.constructor;
// HTMLDocument (Internet Explorer 6 - 7)
(this.HTMLDocument = this.Document = this.document.constructor = function HTMLDocument() {}).prototype = this.document;
// HTMLDocument.ie8 (Internet Explorer 8)
this.Document = this.HTMLDocument;
// HTMLDocument.ie9 (Internet Explorer 9)
this.HTMLDocument = this.Document;
// HTMLUnknownElement.chrome (Safari 4 - 5.1, Chrome 14)
this.HTMLUnknownElement = this.HTMLElement;
// HTMLUnknownElement.ie8 (Internet Explorer 8)
this.HTMLUnknownElement = this.HTMLGenericElement;
// HTMLElement (Internet Explorer 6 - 7)
(this.HTMLElement = this.Element = function HTMLElement() {}).prototype = this.document.createElement('HTMLElement');
HTMLElement.prototype.attachEvent('onpropertychange', function (event) {
for (var name = event.propertyName, value = prototype[event.propertyName], all = HTMLElement.document.all, index = 0; element = all[index]; ++index) {
if (element !== HTMLElement) {
element[name] = value;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment