Part of #2073819: [META] Remove direct calls to drupal_add_css() and #2073823: [META] Remove drupal_add_js() calls.
Follows the same pattern that was used elsewhere, e.g. in #1969916: Remove drupal_add_js/css from seven.theme.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | update_drupal_add_css-2095311-2.patch | 2.15 KB | wim leers |
| #1 | drupal_add_css-2095311-1.patch | 734 bytes | wim leers |
Comments
Comment #1
wim leersTo verify that all still works correctly:
admin/reports/updatesupdate.admin.cssis still being addedComment #1.0
wim leersUpdated issue summary.
Comment #2
wim leersReroll, now provides a library. Same testing plan as described in #1.
Comment #4
wim leers2: update_drupal_add_css-2095311-2.patch queued for re-testing.
Comment #5
sdboyer commentedyup.
Comment #6
webchickGosh, really? :( We seriously need every module that has even 2 pitiful lines of CSS to add to an arbitrary page to define:
- A "Library" definition (12 lines of code) for said CSS, even though that CSS will never, ever, ever be used outside of that one page?
- An "assets" array (another 8 lines of code) to render said CSS to the page?
This seems like a pretty huge step backwards, DX-wise. :( Esp. given we lost the ability to add CSS files in .info.yml files with one line of code, too.
Can we please get a (major) follow-up filed first, in order to talk about how we can possibly make this far less painful on people? I'm all about this stuff being able to be cached, but this is crazy-cakes, IMO.
Comment #7
nod_@webchick: A solution which has various beneficial side effects is #1996238: Replace hook_library_info() by *.libraries.yml file.
I'm told sdboyer has something up his sleeve in #1762204: Introduce Assetic compatibility layer for core's internal handling of assets to make that easier as well.
Comment #8
sdboyer commentedi do indeed have something up my sleeve for this that could make it easier, but it's still a matter of some discussion as to whether it's a good idea. see Wim's second item in #1762204-159: Introduce Assetic compatibility layer for core's internal handling of assets.
he and i are gonna talk about it tomorrow, but as it is, the new system would allow direct declaration of such one-off assets without requiring a library hook (or yaml, if #1996238: Replace hook_library_info() by *.libraries.yml file goes in). problem is, assets declared in such a way cannot be declared as a dependency.
Comment #9
webchickI actually think this is totally fine, and was my main objection to this patch. It escalates what is probably some of the least-maintained CSS in the entire code base to the level of a "library" same as jQuery, Autocomplete, etc. are. It makes the work of a module developer harder to suss out what's important and not, because the equivalent of
print_r(module_invoke_all('library_info'));contains not only actual library libraries, but also this kind of one-off code. There is no reason anyone, ever, would want to depend on this for their own admin interface (only possible use case I can think of is Upgrade Status, and it declares its own CSS). So the extra 8+ lines of code (whether it's in PHP or YAML) feels totally superfluous to me.+100 on a way to declare assets ad-hoc for the "I want these 20 lines of CSS on one admin page in the whole system" use case.
Comment #10
wim leersLooking at this patch again, the reason I declared it as a "library" is because it's used in two locations. If the asset is being added "ad-hoc" in multiple locations, then it's no longer ad-hoc: if it's split into two, or if an accompanying JS file is added, it's too easy to forget to add it in other locations as well.
IOW: "if reuse, then library".
Finally, if the criterium really was "must make sense to reuse in completely different situation", then the majority of libraries in Drupal core would actually not qualify to be a library.
If the "multiple uses" argument doesn't convince you, I'll get rid of the library, but I don't see the downside or harm in doing so.
Comment #11
andypostI think the misuse of library the primary point of confusion. If we rename library to asset it will make more sense.
Patch still applies cleanly and blocks #2073819: [META] Remove direct calls to drupal_add_css()
Comment #12
webchickNo, it's not a point of confusion. It's a point of verbosity. The word "asset" vs. "library" makes absolutely no difference if you still need 20+ lines of code to add a single stupid CSS file that does nothing of great importance. :)
And the patch only shows one instance of this file, not two, unless I'm mistaken.Nevermind, I am. :)However, I guess this is what we're stuck with for now until/unless the new fancy assets library is in, so...
Committed and pushed to 8.x.