New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for attributes in backdrop_add_css(). #4981
Comments
Hm... Looking at the api page, I see:
Are you sure, that attributes aren't possible? BTW: I'd reduce that to backdrop_add_js() - or is there any need for additional attributes on |
I was looking first at backdrop_add_css https://docs.backdropcms.org/api/backdrop/core%21includes%21common.inc/function/backdrop_add_css/1 because I need to be able to add "integrity" and "crossorigin" attributes (maybe others). So maybe we had changed backdrop_add_js already. That rings a bell. I suppose I can update this issue. |
Aha! Here it is for backdrop_add_css #2877. And I helped with the PR originally made by @quicksketch on the d.org issue. But later on in the issue Pol adds support for CSS as well. I think that threw me off. |
@indigoxela I've got a PR here if you'd like to look. The test could be more robust. I mentioned it could be more like JavaScriptTestCase::testAttributes. I've tested it manually with an external css file and it works well. |
I posted a question to the PR about what |
@herbdool To be honest, I've never had a use case for additional attributes on css files. Can you give me some instructions, how to test that? Which attributes are valid (and useful) for |
@indigoxela you could try to build a link like on this page https://forkaweso.me/Fork-Awesome/get-started
That's how I got drawn into this issue. |
@herbdool many thanks, now I got it. 👍 Subresource integrity. This is how I tested:
The file gets added with the right attributes:
If the hash in the integrity attribute does not match, the browser nags into the console and refuses to load the file. If the hash matches, the browser loads the file and the fa-xx classes work as expected. PR works for me. |
Thanks for testing @indigoxela. I'm going to try expand the tests to account for grouping. See if that works. |
@herbdool I don't see a big value in the support for adding attributes to an entire group. If the same attribute is needed on an entire group, an implementation of |
@quicksketch I've updated the PR. |
@quicksketch I've updated the test. It now matches the test for attributes on JS - tests a custom attribute on internal and external css. |
Looks great @herbdool. Marking this RTBC. I added a |
Merged backdrop/backdrop#3555 into 1.x for 1.19.0. |
Reopening until this gets a change record. Nice work @herbdool and thanks @indigoxela for testing! |
Change record created (but needs review, and likely needs work) |
@jenlampton thanks for the change record. It needs a tweak in the after example. There needs to be an attributes array for the backdrop_add_css() example whereas currently the attributes are mixed in with other elements.
|
Ah thank you! Updated: https://docs.backdropcms.org/change-records/backdrop_add_css-can-now-accept-attributes |
Nice to see this in! |
Description of the need
We should allow for attributes like
integrity
, andcrossorigin
to be passed tobackdrop_add_jsand backdrop_add_css. [Update: this was half done, it turns out.]There's this long standing Drupal issue https://www.drupal.org/project/drupal/issues/1664602 where the latest patches seem to be working well.
I'm feeling like this issue already exists here but I just can't find it.
The text was updated successfully, but these errors were encountered: