Created attachment 618189 [details]
HTML page demonstrating the bug
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
Build ID: 20120420145725
Steps to reproduce:
I created a style node at runtime and added some style rules to it.
Then I changed the style node's className.
(see attached file for a working demonstration)
The styles did not apply.
It appears, the style rules got deleted.
According to http://forums.mozillazine.org/viewtopic.php?f=25&t=2461781 the same happens if an id is added to the style node.
Note: this works, if the classname is set to the style node before adding the rules.
But: remains a problem, since you can't change the classname.
The styles should apply even if you change the style node's classname.
Hmm. nsHTMLStyleSheet::SetAttr reparses the stylesheet from the textnode contents unconditionally, looks like. Jonas, is there a reason we're doing that instead of just doing it on changes to title/media/type attributes?
Yeah, the current code looks busted. I don't know of any reason we're doing what we're doing.
Created attachment 626702 [details] [diff] [review]
Don't reparse inline stylesheets on random attribute changes.
Closed tree makes a liar of me. Actual changeset: http://hg.mozilla.org/integration/mozilla-inbound/rev/3946bc720e97