tomhuda/metamorph.js — pull request #16 by borismus (2012-09-21 00:37:58+00:00)
Title: Support for multiple metamorphs in the same DOM.

Chrome extensions live in isolated worlds, which means that JS is not shared, but DOM is. If a Chrome extension injects a content script (written in Ember) and you are on a webpage written in Ember, metamorphs will clash.

This is a pretty exotic usecase, but I spent a few hours scratching my head about what caused the weird cross-context magic I was seeing. That said, the change seems harmless and would be pretty beneficial for complex extension developers.

Obviously the random number from 0-10k approach is going to fail once in a while... could be smarter about it (checking the DOM for existing Metamorphs), but not sure that it's worth the complexity.