Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Remove drupal_add_css() from colour.module – use #attached instead.
Meta issue: http://drupal.org/node/1839338
Comment | File | Size | Author |
---|---|---|---|
#12 | 2010636-12-color_module.patch | 1.35 KB | adammalone |
#9 | 2010636-9.patch | 1.25 KB | Wim Leers |
#2 | 2010636-remove-drupal_add_.patch | 986 bytes | mcjim |
Comments
Comment #1
mcjim CreditAttribution: mcjim commentedComment #2
mcjim CreditAttribution: mcjim commentedThere was a comment in the code to use drupal_add_library, but I've just use #attached.
Comment #3
tstoecklerPlease let's follow the best practice and use drupal_add_library().
Implement hook_library_info() and add the JS and CSS there. I can give you more specific instructions, in case you need any help.
Comment #4
mcjim CreditAttribution: mcjim commentedSpecific instructions would be welcome: the CSS/JS being added seems specific to the theme settings form rather than a general library? I may be misunderstanding something.
Comment #5
mcjim CreditAttribution: mcjim commentedThis is an odd one for sure.
color_library_info() already adds preview.js. The code here is checking to see if there is a preview_js file in the theme and adding that instead of colour/preview.js…
The CSS added is from the theme, also, so neither of these really count as libraries.
So, while this solution might not be perfect, it does help get rid of another call to drupal_add_css/drupal_add_js for now (see #1839338: [meta] Remove drupal_set_*() drupal_add_*() in favour of #attached/response for out-of-band stuff)
Re-setting to needs review to let the test bot have a go, but feel free to change if there is a better approach.
Comment #6
tstoecklerAhh, you're totally right. That approach should totally be improved in 1000 different ways, but that's not for this issue, and as it stands using a library is not possible/sensible in this case.
Thanks for sticking with this and setting me straight!
Comment #7
catch#2: 2010636-remove-drupal_add_.patch queued for re-testing.
Comment #9
Wim LeersStraight reroll.
We can't test this because theme-specific settings are currently broken in D8. #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation
Comment #10
Wim Leers#9 is broken. The CSS and JS no longer ends up on the page. I strongly suspect the root cause for this are the recent changes to the (pre)process layer being removed/working differently and hence
#attached
assets in that phase no longer working… but at the same time #2004286: Defer calls to drupal_get_* functions until printed inside a template by adding a RenderWrapper class has not yet been committed, so I'm not entirely sure. Needs debugging.NR because it *is* possible to test the patch, you just have to clear your caches after installing current D8 head freshly — see #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation for details.
Comment #12
adammaloneTiny tiny rewrite to pass form by reference
Comment #13
Wim LeersWorks great — thanks!
Comment #14
alexpottCommitted 749587e and pushed to 8.x. Thanks!