Skip to content

Instantly share code, notes, and snippets.

@composite
Created December 23, 2013 23:58
Show Gist options
  • Select an option

  • Save composite/8106842 to your computer and use it in GitHub Desktop.

Select an option

Save composite/8106842 to your computer and use it in GitHub Desktop.
IE's document.all emulation for ECMAScript 5 Standard supported browser. DON'T USE AT THE PRODUCTION. TEST OR BENCHMARK PURPOSE ONLY. ESPECIALLY, don't use document.all ! NEVER! DON'T EVER!
Object.defineProperty(document, "all", {
get: function(){
var dup = {};
return (function(all){
for(var i=0,len=all.length;i<len;i++){
var id = all[i].id, name = all[i].name;
if(id && dup[id] != 'id'){
all[id] = all[i];
dup[id] = 'id';
}
if(name && !dup[name]){
all[name] = document.getElementsByName(name);
dup[name] = 'name';
}
}
return all;
})(document.getElementsByTagName('*'));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment