Skip to content

Instantly share code, notes, and snippets.

@DavidBruant
Created May 27, 2012 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DavidBruant/2815846 to your computer and use it in GitHub Desktop.
Save DavidBruant/2815846 to your computer and use it in GitHub Desktop.
Dynamic DOM prototype
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