Created
May 17, 2010 09:39
-
-
Save os0x/403594 to your computer and use it in GitHub Desktop.
JavaScript: リストを配列のように扱う(for Chrome5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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