From bb8122c42c94673bac786d118a240594f06eabac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=CC=81bor=20Hojtsy?= <gabor@hojtsy.hu>
Date: Thu, 31 Oct 2019 14:35:42 +0100
Subject: [PATCH] Issue #3089472 by zrpnr, nod_, bnjmnm: Remove matchmedia in
 Drupal 9

---
 core/.eslintrc.json                           |  1 -
 .../matchMedia/matchMedia.addListener.min.js  |  1 -
 .../vendor/matchMedia/matchMedia.min.js       |  1 -
 core/core.libraries.yml                       | 23 -------------------
 core/modules/ckeditor/ckeditor.libraries.yml  |  2 --
 core/modules/toolbar/toolbar.libraries.yml    |  2 --
 .../Listeners/DeprecationListenerTrait.php    |  2 --
 core/themes/claro/claro.libraries.yml         |  3 ---
 core/themes/seven/seven.libraries.yml         |  3 ---
 9 files changed, 38 deletions(-)
 delete mode 100644 core/assets/vendor/matchMedia/matchMedia.addListener.min.js
 delete mode 100644 core/assets/vendor/matchMedia/matchMedia.min.js

diff --git a/core/.eslintrc.json b/core/.eslintrc.json
index b9a78d16e412..9ecf723effa9 100644
--- a/core/.eslintrc.json
+++ b/core/.eslintrc.json
@@ -15,7 +15,6 @@
     "drupalTranslations": true,
     "jQuery": true,
     "_": true,
-    "matchMedia": true,
     "Backbone": true,
     "Modernizr": true,
     "Popper": true,
diff --git a/core/assets/vendor/matchMedia/matchMedia.addListener.min.js b/core/assets/vendor/matchMedia/matchMedia.addListener.min.js
deleted file mode 100644
index fbdba377da27..000000000000
--- a/core/assets/vendor/matchMedia/matchMedia.addListener.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(){if(window.matchMedia&&window.matchMedia("all").addListener){return false}var e=window.matchMedia,i=e("only all").matches,n=false,t=0,a=[],r=function(i){clearTimeout(t);t=setTimeout(function(){for(var i=0,n=a.length;i<n;i++){var t=a[i].mql,r=a[i].listeners||[],o=e(t.media).matches;if(o!==t.matches){t.matches=o;for(var s=0,l=r.length;s<l;s++){r[s].call(window,t)}}}},30)};window.matchMedia=function(t){var o=e(t),s=[],l=0;o.addListener=function(e){if(!i){return}if(!n){n=true;window.addEventListener("resize",r,true)}if(l===0){l=a.push({mql:o,listeners:s})}s.push(e)};o.removeListener=function(e){for(var i=0,n=s.length;i<n;i++){if(s[i]===e){s.splice(i,1)}}};return o}})();
diff --git a/core/assets/vendor/matchMedia/matchMedia.min.js b/core/assets/vendor/matchMedia/matchMedia.min.js
deleted file mode 100644
index 5daa955fc488..000000000000
--- a/core/assets/vendor/matchMedia/matchMedia.min.js
+++ /dev/null
@@ -1 +0,0 @@
-window.matchMedia||(window.matchMedia=function(){"use strict";var e=window.styleMedia||window.media;if(!e){var t=document.createElement("style"),i=document.getElementsByTagName("script")[0],n=null;t.type="text/css";t.id="matchmediajs-test";i.parentNode.insertBefore(t,i);n="getComputedStyle"in window&&window.getComputedStyle(t,null)||t.currentStyle;e={matchMedium:function(e){var i="@media "+e+"{ #matchmediajs-test { width: 1px; } }";if(t.styleSheet){t.styleSheet.cssText=i}else{t.textContent=i}return n.width==="1px"}}}return function(t){return{matches:e.matchMedium(t||"all"),media:t||"all"}}}());
diff --git a/core/core.libraries.yml b/core/core.libraries.yml
index 4de4aef9813d..c571394eedca 100644
--- a/core/core.libraries.yml
+++ b/core/core.libraries.yml
@@ -320,7 +320,6 @@ drupal.vertical-tabs:
     - core/drupal
     - core/drupalSettings
     - core/drupal.form
-    - core/matchmedia
 
 jquery:
   remote: https://github.com/jquery/jquery
@@ -860,26 +859,6 @@ jquery.ui.widget:
   dependencies:
     - core/jquery.ui
 
-matchmedia:
-  remote: https://github.com/paulirish/matchMedia.js
-  version: &matchmedia_version 0.2.0
-  license: &matchmedia_license
-    name: MIT
-    url: https://github.com/paulirish/matchMedia.js/blob/0.2.0/LICENSE.txt
-    gpl-compatible: true
-  js:
-    assets/vendor/matchMedia/matchMedia.min.js: { minified: true }
-  deprecated: &matchmedia_deprecated The "%library_id%" asset library is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/3086653
-
-matchmedia.addListener:
-  version: *matchmedia_version
-  license: *matchmedia_license
-  js:
-    assets/vendor/matchMedia/matchMedia.addListener.min.js: { minified: true }
-  dependencies:
-    - core/matchmedia
-  deprecated: *matchmedia_deprecated
-
 modernizr:
   # Block the page from being loaded until Modernizr is initialized.
   header: true
@@ -913,8 +892,6 @@ picturefill:
     gpl-compatible: true
   js:
     assets/vendor/picturefill/picturefill.min.js: { weight: -10, minified: true }
-  dependencies:
-    - core/matchmedia
 
 popperjs:
   version: "1.15.0"
diff --git a/core/modules/ckeditor/ckeditor.libraries.yml b/core/modules/ckeditor/ckeditor.libraries.yml
index 27b44afb1442..a4d517fa1469 100644
--- a/core/modules/ckeditor/ckeditor.libraries.yml
+++ b/core/modules/ckeditor/ckeditor.libraries.yml
@@ -14,8 +14,6 @@ drupal.ckeditor:
     - core/drupal.displace
     - core/ckeditor
     - editor/drupal.editor
-    # Ensure to run after core/matchmedia.
-    - core/matchmedia
 
 drupal.ckeditor.plugins.drupalimagecaption:
   version: VERSION
diff --git a/core/modules/toolbar/toolbar.libraries.yml b/core/modules/toolbar/toolbar.libraries.yml
index dcef0841bb62..2306bf33198e 100644
--- a/core/modules/toolbar/toolbar.libraries.yml
+++ b/core/modules/toolbar/toolbar.libraries.yml
@@ -25,8 +25,6 @@ toolbar:
     - core/drupal.ajax
     - core/drupal.announce
     - core/backbone
-    - core/matchmedia
-    - core/matchmedia.addListener
     - core/jquery.once
     - core/drupal.displace
     - toolbar/toolbar.menu
diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
index 1be70ba4862b..95f4984c4aa0 100644
--- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -190,8 +190,6 @@ public static function getSkippedDeprecations() {
       'The "core/jquery.ui.controlgroup" asset library is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/3067969',
       // @todo Remove in https://www.drupal.org/project/drupal/issues/3082655
       'Drupal\Tests\BrowserTestBase::$defaultTheme is required in drupal:9.0.0 when using an install profile that does not set a default theme. See https://www.drupal.org/node/2352949, which includes recommendations on which theme to use.',
-      'The "core/matchmedia" asset library is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/3086653',
-      'The "core/matchmedia.addListener" asset library is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/3086653',
       // The following deprecation is listed for Twig 2 compatibility when unit
       // testing using \Symfony\Component\ErrorHandler\DebugClassLoader.
       'The "Twig\Environment::getTemplateClass()" method is considered internal. It may change without further notice. You should not extend it from "Drupal\Core\Template\TwigEnvironment".',
diff --git a/core/themes/claro/claro.libraries.yml b/core/themes/claro/claro.libraries.yml
index 1ab96c8ca84d..f341e45b4d5a 100644
--- a/core/themes/claro/claro.libraries.yml
+++ b/core/themes/claro/claro.libraries.yml
@@ -98,7 +98,6 @@ drupal.nav-tabs:
   js:
     js/nav-tabs.js: {}
   dependencies:
-    - core/matchmedia
     - core/jquery
     - core/drupal
     - core/jquery.once
@@ -110,8 +109,6 @@ drupal.responsive-detail:
   js:
     js/responsive-details.js: {}
   dependencies:
-    - core/matchmedia
-    - core/matchmedia.addListener
     - core/jquery
     - core/jquery.once
     - core/collapse
diff --git a/core/themes/seven/seven.libraries.yml b/core/themes/seven/seven.libraries.yml
index 645f4d3439d8..651477efb209 100644
--- a/core/themes/seven/seven.libraries.yml
+++ b/core/themes/seven/seven.libraries.yml
@@ -76,7 +76,6 @@ drupal.nav-tabs:
   js:
     js/nav-tabs.js: {}
   dependencies:
-    - core/matchmedia
     - core/jquery
     - core/drupal
     - core/jquery.once
@@ -88,8 +87,6 @@ drupal.responsive-detail:
   js:
     js/responsive-details.js: {}
   dependencies:
-    - core/matchmedia
-    - core/matchmedia.addListener
     - core/jquery
     - core/jquery.once
     - core/collapse
-- 
GitLab