Loading core/misc/ajax.js +2 −1 Original line number Diff line number Diff line Loading @@ -1716,7 +1716,8 @@ const allUniqueBundleIds = response.data.map(function (style) { const uniqueBundleId = style.href + ajax.instanceIndex; loadjs(style.href, uniqueBundleId, { // Force file to load as a CSS stylesheet using 'css!' flag. loadjs(`css!${style.href}`, uniqueBundleId, { before(path, styleEl) { // This allows all attributes to be added, like media. Object.keys(style).forEach((attributeKey) => { Loading core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module +4 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,10 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInte 'href' => 'my/file.css', 'media' => 'all', ], [ 'href' => 'https://example.com/css?family=Open+Sans', 'media' => 'all', ], ])); return $response; } Loading core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ public function testAjaxCommands() { // Tests the 'add_css' command. $page->pressButton("AJAX 'add_css' command"); $this->assertWaitPageContains('my/file.css'); $this->assertSession()->elementExists('css', 'link[href="my/file.css"]'); $this->assertSession()->elementExists('css', 'link[href="https://example.com/css?family=Open+Sans"]'); // Tests the 'after' command. $page->pressButton("AJAX 'After': Click to put something after the div"); Loading Loading
core/misc/ajax.js +2 −1 Original line number Diff line number Diff line Loading @@ -1716,7 +1716,8 @@ const allUniqueBundleIds = response.data.map(function (style) { const uniqueBundleId = style.href + ajax.instanceIndex; loadjs(style.href, uniqueBundleId, { // Force file to load as a CSS stylesheet using 'css!' flag. loadjs(`css!${style.href}`, uniqueBundleId, { before(path, styleEl) { // This allows all attributes to be added, like media. Object.keys(style).forEach((attributeKey) => { Loading
core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module +4 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,10 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInte 'href' => 'my/file.css', 'media' => 'all', ], [ 'href' => 'https://example.com/css?family=Open+Sans', 'media' => 'all', ], ])); return $response; } Loading
core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ public function testAjaxCommands() { // Tests the 'add_css' command. $page->pressButton("AJAX 'add_css' command"); $this->assertWaitPageContains('my/file.css'); $this->assertSession()->elementExists('css', 'link[href="my/file.css"]'); $this->assertSession()->elementExists('css', 'link[href="https://example.com/css?family=Open+Sans"]'); // Tests the 'after' command. $page->pressButton("AJAX 'After': Click to put something after the div"); Loading