Early Bird Registration for DrupalCon Atlanta is now open! By registering during our Early Bird Registration window, you’ll save $100. This window ends on 19 January 2025 and will go by quickly, so don’t wait!
Problem
- Stylesheets that have been removed by the theme (via .info) load with AJAX content.
Goal
- Prevent stylesheets that were removed from coming back under all circumstances.
Steps to reproduce
- Remove system.menus.css via a theme's .info file, e.g. add
stylesheets[all][] = system.menus.css
and don't include the file in your theme. - Visit
admin/structure/types/manage/article/display
. - Click the image configuration options.
- Watch system.menu.css come back (and wreck your site design if you have different tab styles).
Note
- The bug does not occur with stylesheets that have been removed via
hook_css_alter()
.
Watch the screencast for a demonstration of the bug in progress:
http://vimeo.com/16672744
Comment | File | Size | Author |
---|---|---|---|
#40 | 967166-40.patch | 9.69 KB | effulgentsia |
#38 | d7core-ajax_css-967166-38.patch | 9.69 KB | KrisBulman |
#35 | 967166-35.patch | 9.8 KB | no_commit_credit |
#35 | interdiff.txt | 1.01 KB | no_commit_credit |
#33 | 967166-ajax-css-32.patch | 9.8 KB | effulgentsia |
Comments
Comment #1
sunAwesome issue summary, thanks! :)
The proper solution would be to re-open #901062: Regression: Themes can no longer remove stylesheets by overriding them in .info files against D7 and introduce the originally proposed stylesheets-remove[] .info file property.
Comment #2
jacineStill no word on that, and I don't think it's going to happen.
Unfortunately this has serious potential to break sites in a bad way.
Comment #3
effulgentsia CreditAttribution: effulgentsia commentedHere's a fix, but a test for it remains challenging until I (or someone else) makes good on the promise in #561858-201: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework.
Comment #4
jacine@effulgentsia Thank you!
The patch solves the problem, the change appears simple enough and the docs are good! Yay :D
I'd mark it RTBC, but I'm not really clear on what needs to happen with regard to the other issue. It seems like a test for this is not even possible and that issue is closed.
Comment #5
jacine#3: 967166-ajax-css-3.patch queued for re-testing.
Comment #6
gmclelland CreditAttribution: gmclelland commentedIs there any fix to prevent this from happening in Drupal 6?
I'm using TAO which strips out core's css using the .info file. When used with Skinr every time I click on Edit Skin it loads an ajax modal popup. When the modal is displayed it reinjects drupal's css causing my theme to break.
Thanks for any help you can provide. I also tried the stylestripper module, but that didn't work.
Comment #7
garrettrayj CreditAttribution: garrettrayj commentedPatch works great. Anything else I can help with to get this into a release version?
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedLooks like a straight up bug fix to me. Any test for this would depend on the other issue. Seems like we should fix the bug now.
Comment #9
rfayD8 first. Let's get these fixed on D8 and into D7.
Comment #10
effulgentsia CreditAttribution: effulgentsia commentedBy the way, #561858-211: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework contains the tests to finish off that issue. Once that's in, a test can be added to this one.
Comment #11
sun.
Comment #12
sun#3: 967166-ajax-css-3.patch queued for re-testing.
Comment #14
mfer CreditAttribution: mfer commentedI was just bit by this. The patch in #3 still applies to D7 w/ an offset.
Comment #15
yoroy CreditAttribution: yoroy commentedA simple reroll would help move things forward here.
Comment #16
aiwata55 CreditAttribution: aiwata55 commented#967166-3: Content rendered via AJAX does not respect stylesheets removed in .info files 967166-ajax-css-3.patch retest.
Comment #17
aiwata55 CreditAttribution: aiwata55 commented#3: 967166-ajax-css-3.patch queued for re-testing.
Comment #20
star-szrPatch attached which applies cleanly to D8 HEAD, and applies to D7 HEAD with an offset.
Comment #21
mac_weber CreditAttribution: mac_weber commentedComment #22
jhoodI applied the patch in #20 and the stylesheets no longer come back.
Comment #23
xjmThe patch looks good to me, and manual testing in #22 confirms that it resolves the issue. Thanks for the reroll and the manual testing!
The next thing we will need is an automated test for the issue. #561858: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework has been committed to 8.x, so the comments above seem to indicate it should be possible to write this test now. The test should fail when applied by itself, and pass when applied together with #20.
Comment #24
xjmOops, marking NW for addition of tests.
Comment #25
samerali CreditAttribution: samerali commented#20: 967166-ajax-css-19.patch queued for re-testing.
Comment #27
xjmThe patch will need to be rerolled against the latested 8.x and for the D8 core/ directory change.
Comment #28
star-szrSome changes over in #1287368: Drupal.settings.ajaxPageState.css gets overwritten affected the patch. I've done a re-roll for D8 and D7 and tried not to step on any toes, but please let me know if I missed anything.
Comment #29
effulgentsia CreditAttribution: effulgentsia commentedThanks! I'll work on adding tests.
Comment #30
xjmSending to the bot.
Comment #32
effulgentsia CreditAttribution: effulgentsia commentedHere's the test only. It should fail. Note that most of the -/+ lines are just a change to indentation.
Comment #33
effulgentsia CreditAttribution: effulgentsia commentedHere's #32 plus the fix in #28, but with a slight reworking of the if statement and code comments. This should pass.
Comment #34
KrisBulman CreditAttribution: KrisBulman commentedTested original problem on the 8.x branch of git and was able to reproduce it following Jacine's steps (tested with system.base.css on bartik for a more drastic effect)
ran the patch
$ git apply -v 967166-ajax-css-32.patch
Followed same reproduction steps and can confirm the css file was not loading.
The faster this gets committed to 8, the sooner it'll get backported and we'll be able to remove the unintuitive hook_css_alter() from our themes in 7 :)
RTBC
Comment #35
no_commit_credit CreditAttribution: no_commit_credit commentedComment #36
xjmThe above fixes two small things:
Leaving at RTBC because these are trivial changes. Thanks!
Comment #37
catchThis looks fine, most of the change is indentation and test additions, committed/pushed to 8.x.
Comment #38
KrisBulman CreditAttribution: KrisBulman commentedd7 reroll
Comment #39
xjmComment #40
effulgentsia CreditAttribution: effulgentsia commented#38 looks good. It's a straight reroll. This patch only fixes this:
These two lines need a leading space, which they already have in what was committed to D8.
Trivial change, so RTBC.
Comment #41
jacineHooray!!! Thanks all :D
Comment #42
webchickCommitted and pushed to 7.x. Thanks!