Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Commit

Permalink
make sure stylesheet, don't delete node, just update url
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallen23 committed Apr 24, 2012
1 parent 99d3732 commit f6f906d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/browser-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,16 @@

var refreshStylesheet = function(url, node) {
var timestamp = new Date().getTime();
var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', url + '?t=' + timestamp);
var head = document.getElementsByTagName('head')[0];
head.insertBefore(link, node.nextSibling);
node.setAttribute('href', url + '?=' + timestamp);
console.log('Refreshing: '+url);
setTimeout(function() {
document.getElementsByTagName('head')[0].removeChild(node);
}, 100);
};

var refreshStylesheets = function(files) {
var cssNodes = document.getElementsByTagName('link');
for (var i = 0, c = cssNodes.length; i < c; i++) {
var node = cssNodes[i];
if (node.getAttribute('rel') != 'stylesheet')
continue;
var path = node.getAttribute('href').split('?')[0];
for (var a = 0, b = files.length; a < b; a++) {
var file = files[a];
Expand Down

0 comments on commit f6f906d

Please sign in to comment.