vtswingkid
13 Nov 2006, 11:20 AM
The following bugs were found when testing with IE6, FIREFOX, OPERA, NETCSAPE
CSS doesn't dynamically load in ie6.
JS scripts would not load dynamically in all browsers.
Duplicates of CSS and JS in DOM.
Removal of whitespace broke CSS loads and JS loads in all browsers
i.e. <script>...</script><script>...</script>
I propose the following changes to update within element.js:
update:function(msg,loadScripts){
var cssFragment='(?:<style>)((\n|\r|.)*?)(?:</style>)';
var jsFragment='(?:<script>)((\n|\r|.)*?)(?:</script>)';
var docHead=document.getElementsByTagName("head")[0];
var html=msg.replace(new RegExp(cssFragment, 'img'),"");
if(html){
html=html.toString();
html=html.replace(new RegExp(jsFragment, 'img'),"");
if(html){
html=html.toString();
this.dom.innerHTML=html;
}
}
var css=msg.match(new RegExp(cssFragment, 'img'));
if(css){
css=css.toString();
var re = /(?:<style.*?id=[\"\'](.*?)[\"\'].*?>)([\S\s]*?)(?:</style>)|(?:<style>)([\S\s]*?)(?:</style>)/ig;
var match;
while(match = re.exec(css)){
if(match[2]||match[3]){
var s0 = document.createElement("style");
var t;
if(match[1]){
var e=document.getElementById(match[1]);
if(e)e.parentNode.removeChild(e);
s0.setAttribute("id", match[1]);
}
s0.setAttribute("type","text/css");
if(match[2])t=match[2];
if(match[3])t=match[3];
if(s0.styleSheet)s0.styleSheet.cssText=t;//IE
else s0.appendChild(document.createTextNode(t));//W3C
docHead.appendChild(s0);
}
}
}
if(!loadScripts)return this;
var js=msg.match(new RegExp(jsFragment, 'img'));
if(!js)return this;
js=js.toString();
var dom = this.dom;
var _parseScripts = function(){
var re = /(?:<script.*?src=[\"\'](.*?)[\"\'].*?>)[\S\s]*?(?:</script>)|(?:<script>)([\S\s]*?)(?:</script>)/ig;
var match;
while(match=re.exec(js)){
if(match[2])eval(match[2]);
else if(match[1]){
var s0=document.createElement("script");
s0.src=match[1];
docHead.appendChild(s0);
}
}
}
setTimeout(_parseScripts,10);
return this;
}[/code]
CSS doesn't dynamically load in ie6.
JS scripts would not load dynamically in all browsers.
Duplicates of CSS and JS in DOM.
Removal of whitespace broke CSS loads and JS loads in all browsers
i.e. <script>...</script><script>...</script>
I propose the following changes to update within element.js:
update:function(msg,loadScripts){
var cssFragment='(?:<style>)((\n|\r|.)*?)(?:</style>)';
var jsFragment='(?:<script>)((\n|\r|.)*?)(?:</script>)';
var docHead=document.getElementsByTagName("head")[0];
var html=msg.replace(new RegExp(cssFragment, 'img'),"");
if(html){
html=html.toString();
html=html.replace(new RegExp(jsFragment, 'img'),"");
if(html){
html=html.toString();
this.dom.innerHTML=html;
}
}
var css=msg.match(new RegExp(cssFragment, 'img'));
if(css){
css=css.toString();
var re = /(?:<style.*?id=[\"\'](.*?)[\"\'].*?>)([\S\s]*?)(?:</style>)|(?:<style>)([\S\s]*?)(?:</style>)/ig;
var match;
while(match = re.exec(css)){
if(match[2]||match[3]){
var s0 = document.createElement("style");
var t;
if(match[1]){
var e=document.getElementById(match[1]);
if(e)e.parentNode.removeChild(e);
s0.setAttribute("id", match[1]);
}
s0.setAttribute("type","text/css");
if(match[2])t=match[2];
if(match[3])t=match[3];
if(s0.styleSheet)s0.styleSheet.cssText=t;//IE
else s0.appendChild(document.createTextNode(t));//W3C
docHead.appendChild(s0);
}
}
}
if(!loadScripts)return this;
var js=msg.match(new RegExp(jsFragment, 'img'));
if(!js)return this;
js=js.toString();
var dom = this.dom;
var _parseScripts = function(){
var re = /(?:<script.*?src=[\"\'](.*?)[\"\'].*?>)[\S\s]*?(?:</script>)|(?:<script>)([\S\s]*?)(?:</script>)/ig;
var match;
while(match=re.exec(js)){
if(match[2])eval(match[2]);
else if(match[1]){
var s0=document.createElement("script");
s0.src=match[1];
docHead.appendChild(s0);
}
}
}
setTimeout(_parseScripts,10);
return this;
}[/code]