Skip to content

Instantly share code, notes, and snippets.

@os0x
Created May 17, 2010 09:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save os0x/403594 to your computer and use it in GitHub Desktop.
Save os0x/403594 to your computer and use it in GitHub Desktop.
JavaScript: リストを配列のように扱う(for Chrome5)
(function extend_NodeList(proto){
if(Object.defineProperty){
Object.getOwnPropertyNames(Array.prototype).filter(function(prop){
return typeof Array.prototype[prop] === 'function';
}).forEach(extend_by_array);
}
function extend_by_array(name){
if (name in NodeList.prototype){
return;
}
Object.defineProperty(NodeList.prototype, name,{
value : function() {
return Array.prototype[name].apply(this, arguments);
},
writable : true,
enumerable : false,
configurable : true
});
}
})(NodeList.prototype);
// document.getElementsByTagName('a').filter(function(a){return a.host!=location.host});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment