Skip to content

Instantly share code, notes, and snippets.

@clarkbw
Created February 21, 2013 00:24
Show Gist options
  • Save clarkbw/5000940 to your computer and use it in GitHub Desktop.
Save clarkbw/5000940 to your computer and use it in GitHub Desktop.
Because you can't easily find a stylesheet in XUL by it's ID you have to look for the data attribute and compare that with what I created as the `css` variable.
function findStylesheet(document, name) {
var uri = data.url(name + ".css"),
css = "href=\"" + uri + "\" type=\"text/css\"",
ORDERED_NODE_SNAPSHOT_TYPE = 7, // XPathResult doesn't exist in context
xpath = null;
xpath = document.evaluate("//processing-instruction(\"xml-stylesheet\")",
document,
document.createNSResolver(document),
ORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; xpath && i < xpath.snapshotLength; i += 1) {
if (xpath.snapshotItem(i).data === css) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment