Open saulocastelo opened 10 years ago
This is nice. :)
Except... isn't it going to get sheets twice if both document.styleSheets
and $("head").find('style')
methods work?
For reference: original issue is #223
And @SimpleAsCouldBe: yes, the code produces the styles list twice. This is not a grave issue as the calling code does this (click 'expand' to see the 'break;' line in the github diff view):
var sheets = getAllStyleSheets();
for (var i = 0; i < sheets.length; i++) {
if ((sheets[i].ownerNode || sheets[i].owningElement) == $style[0]) {
stylesheet = sheets[i];
break;
}
}
so only one instance is picked and worked with.
I will submit a better way to do this because the getAllStyleSheets function should not return repeated styles. Just wait.
Done. Take a look.
Is there a way to accomplish this by testing capability instead of user agent?
navigator.userAgent.toLowerCase().indexOf('chrome')
A UA test is fragile here because:
I agree, I already have an idea, just wait.
Guys, i was thinking about the function createCssRules, you are appending the rule directly to the head tag. So we don't even need to test if the bug exists, we should just read the rules directly from the head tag.
Did you guys agree? If so, I will make the changes and commit.
Sorry my delay, I was very busy.
testing this locally with a few grids on the page, and re-rendering them a few times, this fix doesn't seem to work :(
Can you send me your test page?
Signed-off-by: Saulo Castelo Sampaio saulocastelo@gmail.com