From 0e715362914822dc9b0f8d6e4518feb9969ef712 Mon Sep 17 00:00:00 2001
From: Lauri Eskola <lauri.eskola@acquia.com>
Date: Thu, 23 Jan 2020 12:11:34 +0200
Subject: [PATCH] Issue #3100147 by gapple, longwave: Remove @import parsing
 from Drupal.AjaxCommands.prototype.add_css

---
 core/misc/ajax.es6.js | 18 ------------------
 core/misc/ajax.js     | 10 ----------
 2 files changed, 28 deletions(-)

diff --git a/core/misc/ajax.es6.js b/core/misc/ajax.es6.js
index 905559c921a5..518e2a1f99dd 100644
--- a/core/misc/ajax.es6.js
+++ b/core/misc/ajax.es6.js
@@ -1532,10 +1532,6 @@
     /**
      * Command to add css.
      *
-     * Uses the proprietary addImport method if available as browsers which
-     * support that method ignore @import statements in dynamically added
-     * stylesheets.
-     *
      * @param {Drupal.Ajax} [ajax]
      *   {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
      * @param {object} response
@@ -1546,21 +1542,7 @@
      *   The XMLHttpRequest status.
      */
     add_css(ajax, response, status) {
-      // Add the styles in the normal way.
       $('head').prepend(response.data);
-      // Add imports in the styles using the addImport method if available.
-      let match;
-      const importMatch = /^@import url\("(.*)"\);$/gim;
-      if (
-        document.styleSheets[0].addImport &&
-        importMatch.test(response.data)
-      ) {
-        importMatch.lastIndex = 0;
-        do {
-          match = importMatch.exec(response.data);
-          document.styleSheets[0].addImport(match[1]);
-        } while (match);
-      }
     },
 
     /**
diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index 7df250198765..06d13d4738de 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -629,16 +629,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
     },
     add_css: function add_css(ajax, response, status) {
       $('head').prepend(response.data);
-
-      var match = void 0;
-      var importMatch = /^@import url\("(.*)"\);$/gim;
-      if (document.styleSheets[0].addImport && importMatch.test(response.data)) {
-        importMatch.lastIndex = 0;
-        do {
-          match = importMatch.exec(response.data);
-          document.styleSheets[0].addImport(match[1]);
-        } while (match);
-      }
     },
     message: function message(ajax, response) {
       var messages = new Drupal.Message(document.querySelector(response.messageWrapperQuerySelector));
-- 
GitLab