I posted about this issue before, but didn't root-cause it as I *thought* a fix was on the way in the July CTP. I was wrong.
If you read the post I linked to above, you will see a snippet of the following method (from the Atlas.js file):
this._updateStyleSheet = function(cssText)
{
var head = document.getElementsByTagName('HEAD')[0];
var styles = document.styleSheets;
var styleSheet = styles[styles.length - 1];
if (Sys.Runtime.get_hostType() == Sys.HostType.InternetExplorer)
{
styleSheet.cssText = cssText;
}
else
{
for (var i = styleSheet.cssRules.length - 1; i >= 0; i--)
{
styleSheet.deleteRule(i);
}
var ruleLines =cssText.split('}');
for (var j =0;j <ruleLines.length;j++)
{
var rule =ruleLines[j];
var index =rule.indexOf('{');
var style =rule.substr(index +1).trim();
if (style.length !=0)
{
var selector =rule.substring(0,index).trim();
styleSheet.insertRule(selector +'{'+style +'}', styleSheet.cssRules.length);
}
}
}
}
The line in red is the root cause of the issue, and the symptom (a
NS_ERROR_DOM_BAD_URI exception) is caused by the line in
blue.
Now, here's the issue... some Firefox plugins (i.e. - the
CoComment Extension) will load an external stylesheet after the page has been downloaded, putting the plugin's stylesheet at the end of the
document.styleSheets array.
This is a problem as the _updateStyleSheet
method expects the last item of the array to be some stylesheet specific to the Atlas framework. But due to the plugin, it isn't at the end (at index
styles.length-1), but rather it is two from the end (at index
styles.length-2).
With the CoComment plugin this causes an issue because we don't seem to have access to the URI, and
styleSheet.cssRules will throw the mentioned exception. I would suggest that instead of blindly assuming the Atlas specific styleSheet is at the end of the array, the
_updateStyleSheet method should go thru the array (from end to start) looking for a specific attribute of the
<script> tag ... or better yet, the ID!
This should be considered a big issue as I'm sure there are plenty of other plugins/extensions for Firefox (and likely other browsers) that will cause the same issue.
Also... is this the right place to report such bugs, or is there a bug-tracker that the Atlas team uses and /or I can contact them directly?
steve harman
Member
128 Points
38 Posts
Browser Plugins Cause javaScript Exception in Async Callback Handler...
Aug 02, 2006 02:32 AM|LINK
If you read the post I linked to above, you will see a snippet of the following method (from the Atlas.js file):
this._updateStyleSheet = function(cssText)
{
var head = document.getElementsByTagName('HEAD')[0];
var styles = document.styleSheets;
var styleSheet = styles[styles.length - 1];
if (Sys.Runtime.get_hostType() == Sys.HostType.InternetExplorer)
{
styleSheet.cssText = cssText;
}
else
{
for (var i = styleSheet.cssRules.length - 1; i >= 0; i--)
{
styleSheet.deleteRule(i);
}
var ruleLines =cssText.split('}');
for (var j =0;j <ruleLines.length;j++)
{
var rule =ruleLines[j];
var index =rule.indexOf('{');
var style =rule.substr(index +1).trim();
if (style.length !=0)
{
var selector =rule.substring(0,index).trim();
styleSheet.insertRule(selector +'{'+style +'}', styleSheet.cssRules.length);
}
}
}
}
The line in red is the root cause of the issue, and the symptom (a NS_ERROR_DOM_BAD_URI exception) is caused by the line in blue.
Now, here's the issue... some Firefox plugins (i.e. - the CoComment Extension) will load an external stylesheet after the page has been downloaded, putting the plugin's stylesheet at the end of the document.styleSheets array.
This is a problem as the _updateStyleSheet method expects the last item of the array to be some stylesheet specific to the Atlas framework. But due to the plugin, it isn't at the end (at index styles.length-1), but rather it is two from the end (at index styles.length-2).
With the CoComment plugin this causes an issue because we don't seem to have access to the URI, and styleSheet.cssRules will throw the mentioned exception. I would suggest that instead of blindly assuming the Atlas specific styleSheet is at the end of the array, the _updateStyleSheet method should go thru the array (from end to start) looking for a specific attribute of the <script> tag ... or better yet, the ID!
This should be considered a big issue as I'm sure there are plenty of other plugins/extensions for Firefox (and likely other browsers) that will cause the same issue.
Also... is this the right place to report such bugs, or is there a bug-tracker that the Atlas team uses and /or I can contact them directly?
Thanks in advance!