Subj : Re: Sharing Javascript objects between different XUL windows. To : Peter Wilson From : Brendan Eich Date : Wed Dec 22 2004 10:10 pm Peter Wilson wrote: > I am writing an editor which presents a view of a DOM object. In another > tool window I cache a map of tree elements to the source nodes in the > original DOM object. > The intention is that when a user selects a tree element in the tool I > can map it back into the original DOM node using the Map. > > It seems that when I switch focus away from the tool back to the main > window all the objects in the map are quietly converted to different > object. When I later retrieve (by id) objects from the cache the > returned object is not === to the original DOM node. Otherwise it has > all the properties of the expected node (it is not == either). > > Anyone got any ides what is going on? This technique used to work > several years ago when I first wrote this code. > > Any other pointers to sharing objects between windows? Are you using JavaScript only, or C++ and the DOM APIs (or even the C SpiderMonkey JS Engine API)? What other objects does a given DOM node turn into? Another DOM object, or an arbitrary object? If you're using the C API and failing to protect referenced objects from being GC'd, that might explain things -- but I'd expect you to see crashes too. /be .