diff --git a/lib/metamorph.js b/lib/metamorph.js old mode 100644 new mode 100755 index c46673e..ff42ebd --- a/lib/metamorph.js +++ b/lib/metamorph.js @@ -7,6 +7,14 @@ var K = function(){}, guid = 0, + // At initialization, create a prefix associated with this Metamorph instance. + // This is useful if you have multiple metamorphs in a page, which happens if you + // have a Chrome extension with a content script written in Ember, and navigate to + // a page written in Ember. + ts = (new Date()).valueOf().toString(); + rand = ((Math.random() * 0x10000)|0).toString(); + prefix = ts + rand; + document = window.document, // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges @@ -37,7 +45,7 @@ } self.innerHTML = html; - var myGuid = 'metamorph-'+(guid++); + var myGuid = 'metamorph-' + prefix + '-' + (guid++); self.start = myGuid + '-start'; self.end = myGuid + '-end';