Verified Commit 62498926 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3400359 by el7cosmos, dinazaur, alexpott, ReINFaTe: External fonts...

Issue #3400359 by el7cosmos, dinazaur, alexpott, ReINFaTe: External fonts cannot be loaded via add_css ajax command
parent a2f51b88
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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) => {
+4 −0
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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");