Index: E:/workspace/fluid-engage-core/components/mobileHome/js/condenser.js
===================================================================
--- E:/workspace/fluid-engage-core/components/mobileHome/js/condenser.js	(revision 9562)
+++ E:/workspace/fluid-engage-core/components/mobileHome/js/condenser.js	(working copy)
@@ -10,28 +10,26 @@
         script: "src"
     };
     
-    var parseURL = function (tag, tagType) {
-        var urlAtt = tagURLMap[tagType];
-        if (!urlAtt) {
-            return null;
-        }
-        
-        // This logic assumes attribute values start and end with double quotes.
-        // Safe if the markup has been Renderer-generated, otherwise ensure your content is valid XHTML!
-        urlAtt = urlAtt + "=\""; 
-        var attLen = urlAtt.length;
-        var startIdx = tag.indexOf(urlAtt) + attLen;
-        var endIdx = tag.indexOf("\"", startIdx);
-        
-        return tag.substring(startIdx, endIdx);
+    var parseURL = function (tag) {
+        var urlAtt = tagURLMap[tag.nodeName.toLowerCase()];
+        return urlAtt? tag.getAttribute(urlAtt) : null;
     };
     
+    registerDependency = function (that, el, url, volatyle) {
+        that.dependencies[url] = true;
+        if (volatyle) {
+            var id = fluid.allocateSimpleId(el);
+            that.volatileSources[id] = id;
+            }
+        };
+    
     var injectUniqueTag = function (that, injectFn, tag, type) {
-        var tagURL = parseURL(tag, type);
+        var tagURL = parseURL(tag);
         var isLoaded = that.dependencies[tagURL];
+        var isVolatile = $.nodeName(tag, "link");
         if (!isLoaded) {
+            registerDependency(that, tag, tagURL, isVolatile);
             injectFn(tag);
-            that.registerDependency(tagURL);
         }
     };
     
@@ -36,13 +34,13 @@
     };
     
     var createSafariInjectFn = function (container, type) {
-        return function (tagText) {
+        return function (tag) {
             var existing = $(type, container);
             if (existing.length === 0) {
-                container.append(tagText);
+                container.append(tag);
             } else {
                 var lastEl = $(type + ":last", container);
-                lastEl.after(tagText);
+                lastEl.after(tag);
             }
         };
     };
@@ -48,9 +46,8 @@
     };
     
     var createCleanInjectFn = function (container) {
-        return function (tagText) {
-            var tag = $.clean([tagText]);
-            container[0].appendChild(tag[0]);
+        return function (tag) {
+            container[0].appendChild(tag);
         };
     };
     
@@ -57,43 +54,39 @@
     var injectUniqueTags = function (that, container, type, tags) {
         var injectFn = $.browser.safari ? createSafariInjectFn(container, type) : createCleanInjectFn(container);        
         $.each(tags, function (idx, tag) {
-            if (tag) {
-                injectUniqueTag(that, injectFn, tag, type);
-            }
+            var cleaned = $.clean([tag])[0];
+            injectUniqueTag(that, injectFn, cleaned, type);
         });
     };
     
-    var clearElementsOfType = function (container, elementType) {
-        var elements = $(elementType, container);
-        elements.remove();
-    };
+    function clearVolatiles(that, newVols, oldVols) {
+        fluid.transform(oldVols, function(id) {
+            if (!newVols[id]) {
+                var node = fluid.byId(id);
+                var url = parseURL(node);
+                $(node).remove();
+                delete that.dependencies[url];
+            }
+        });
+    }
     
     var inject = function (that, doc) {
         var head = $("head");
-        // TODO: Need to replace this with smart CSS clearing code.
-        // clearElementsOfType(head, "link");
+        var oldVols = fluid.copy(that.volatileSources);
+        that.volatileSources = {};
         injectUniqueTags(that, head, "link", doc.linkTags);
         injectUniqueTags(that, head, "script", doc.scriptTags);
+        clearVolatiles(that, that.volatileSources, oldVols);
         that.container.html(doc.body);
     };
     
-    // TODO: This is no longer used. It's here to remind us of our next step in terms of head normalization
-    // but is probably replaced by server-side code at this point.
-    var urls = function (elements, type) {
-        var urls = {};
-        $.each(elements, function (idx, element) {
-            urls[$(element).attr(tagURLMap[type])] = true; // TODO: this is pretty dorky
-        });
-        
-        return urls;
-    };
-    
     var registerDependencies = function (that, elements, type) {
         elements.each(function (idx, el) {
+            el = fluid.wrap(el);
             var urlAttr = tagURLMap[type];
-            var url = $(el).attr(urlAttr);
+            var url = el.attr(urlAttr);
             if (url) {
-                that.registerDependency(url);
+                registerDependency(that, el, url);
             }
         });
     };
@@ -156,6 +149,7 @@
         that.dependencies = {};
         that.pageStack = [""];
         that.historyPos = 0;
+        that.volatileSources = {};
         
         var setFrag = function (that, newUrl) {
             setFragmentLocation(newUrl);
@@ -202,10 +196,6 @@
             }
         };
         
-        that.registerDependency = function (url) {
-            that.dependencies[url] = true;
-        };
-        
         setupNavigator(that);
         return that;
     };
