Appending inline critical CSS is broken in AJAX requests since Drupal 10.1.0

Created on 22 September 2023, 9 months ago
Updated 29 December 2023, 6 months ago

Problem/Motivation

Since πŸ“Œ Improve Drupal\Core\Ajax\AddCssCommand to accept an array of CSS assets Fixed , JS/CSS assets are sent in AJAX responses as arrays of attributes instead of rendered HTML strings. Because of this, inline CSS can no longer be added to AJAX responses through AddCssCommand's (see nod_'s comment here β†’ ).

Drupal.AjaxCommands.prototype.add_css(), the JS behaviour that adds the assets to the page, expects an href attribute for every asset, something inline assets don't have.

Steps to reproduce

Try to trigger any AJAX request: can be a Webform submit, a media library modal πŸ› Critical CSS breaks media library button in CKeditor in D10 Needs review , anything.

Proposed resolution

I'm not sure this can be fixed in the Critical CSS module, this might be something that needs to be fixed in Drupal core. AjaxResponseAttachmentsProcessor will need to check which CSS assets have an href attribute: those that do should be added with AddCssCommand, those that don't should be added with AppendCommand (see gapple's comment here β†’ ).

Remaining tasks

  • Check if we can find a temporary workaround for this module.
  • Create a core issue.
πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium DieterHolvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024