-
-
Save rwaldron/2816959 to your computer and use it in GitHub Desktop.
Dynamic DOM prototype
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
var originalNodeListProto = NodeList.prototype; | |
var temporaryNodeListProto = Object.create(NodeList.prototype); | |
temporaryNodeListProto.a = 1; | |
NodeList.prototype = temporaryNodeListProto; | |
var l = document.querySelectorAll('a'); | |
console.log(l.a); // inherited from which prototype? | |
NodeList.prototype = originalNodeListProto; | |
console.log(l.a); // checking if the result is the same than above :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment