Last Comment Bug 748692 - Dynamically created style rule gets disabled/removed
: Dynamically created style rule gets disabled/removed
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: x86_64 Windows 7
: -- normal (vote)
: mozilla15
Assigned To: Boris Zbarsky [:bz]
Depends on:
  Show dependency treegraph
Reported: 2012-04-25 02:09 PDT by Thomas Tampe
Modified: 2012-06-02 11:55 PDT (History)
3 users (show)
bzbarsky: in‑testsuite+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

HTML page demonstrating the bug (1.06 KB, text/html)
2012-04-25 02:09 PDT, Thomas Tampe
no flags Details
Don't reparse inline stylesheets on random attribute changes. (7.44 KB, patch)
2012-05-23 23:01 PDT, Boris Zbarsky [:bz]
jonas: review+
Details | Diff | Splinter Review

Description Thomas Tampe 2012-04-25 02:09:08 PDT
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)

Actual results:

The styles did not apply.
It appears, the style rules got deleted.
According to 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.

Expected results:

The styles should apply even if you change the style node's classname.
Comment 1 Boris Zbarsky [:bz] 2012-04-25 07:09:52 PDT
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?
Comment 2 Jonas Sicking (:sicking) No longer reading bugmail consistently 2012-04-25 16:06:32 PDT
Yeah, the current code looks busted. I don't know of any reason we're doing what we're doing.
Comment 3 Boris Zbarsky [:bz] 2012-05-23 23:01:13 PDT
Created attachment 626702 [details] [diff] [review]
Don't reparse inline stylesheets on random attribute changes.
Comment 5 Boris Zbarsky [:bz] 2012-06-01 08:46:20 PDT
Closed tree makes a liar of me.  Actual changeset:

Note You need to log in before you can comment on or make changes to this bug.