Issue #3089469 by zrpnr, bnjmnm, xjm: Remove html5shiv in Drupal 9

merge-requests/2419/head
Alex Pott 2019-10-24 11:32:09 +01:00
parent bdf48170cd
commit 4a1345b76f
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
6 changed files with 31 additions and 79 deletions

View File

@ -1,4 +0,0 @@
/**
* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);

View File

@ -345,19 +345,6 @@ drupal.vertical-tabs:
- core/drupal.form
- core/matchmedia
html5shiv:
# Block the page from being loaded until html5shiv is initialized.
header: true
remote: https://github.com/aFarkas/html5shiv
version: "3.7.3"
license:
name: GNU-GPL-2.0-or-later
url: http://www.gnu.org/licenses/gpl-2.0.html
gpl-compatible: true
js:
assets/vendor/html5shiv/html5shiv.min.js: { weight: -22, browsers: { IE: 'lte IE 8', '!IE': false }, minified: true }
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/3086383
jquery:
remote: https://github.com/jquery/jquery
version: "3.4.1"

View File

@ -15,10 +15,6 @@ class Html extends RenderElement {
public function getInfo() {
return [
'#theme' => 'html',
// HTML5 Shiv
'#attached' => [
'library' => ['core/html5shiv'],
],
];
}

View File

@ -34,34 +34,25 @@ class NoJavaScriptAnonymousTest extends BrowserTestBase {
// Test frontpage.
$this->drupalGet('');
$this->assertNoJavaScriptExceptHtml5Shiv();
$this->assertNoJavaScript();
// Test node page.
$this->drupalGet('node/1');
$this->assertNoJavaScriptExceptHtml5Shiv();
$this->assertNoJavaScript();
// Test user profile page.
$this->drupalGet('user/' . $user->id());
$this->assertNoJavaScriptExceptHtml5Shiv();
$this->assertNoJavaScript();
}
/**
* Passes if no JavaScript is found on the page except the HTML5 shiv.
*
* The HTML5 shiv is necessary for e.g. the <article> tag which Drupal 8 uses
* to work in older browsers like Internet Explorer 8.
* Passes if no JavaScript is found on the page.
*/
protected function assertNoJavaScriptExceptHtml5Shiv() {
protected function assertNoJavaScript() {
// Ensure drupalSettings is not set.
$settings = $this->getDrupalSettings();
$this->assertTrue(empty($settings), 'drupalSettings is not set.');
// Ensure the HTML5 shiv exists.
$this->assertRaw('html5shiv/html5shiv.min.js', 'HTML5 shiv JavaScript exists.');
// Ensure no other JavaScript file exists on the page, while ignoring the
// HTML5 shiv.
$this->assertSession()->responseNotMatches('/(?<!html5shiv\.min)\.js/');
$this->assertSession()->responseNotMatches('/\.js/');
}
}

View File

@ -31,56 +31,47 @@ class AjaxPageStateTest extends BrowserTestBase {
$this->adminUser = $this->drupalCreateUser(array_keys(\Drupal::service('user.permissions')
->getPermissions()));
// Log in so there are more libraries to test with otherwise only html5shiv
// is the only one in the source we can easily test for.
// Log in so there are more libraries to test for.
$this->drupalLogin($this->adminUser);
}
/**
* Default functionality without the param ajax_page_state[libraries].
*
* The libraries html5shiv and drupalSettings are loaded default from core
* The libraries active-link and drupalSettings are loaded default from core
* and available in code as scripts. Do this as the base test.
*/
public function testLibrariesAvailable() {
$this->drupalGet('node', []);
$this->assertRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
'The html5shiv library from core should be loaded.'
);
$this->assertRaw(
'/core/misc/drupalSettingsLoader.js',
'The drupalSettings library from core should be loaded.'
);
// The active link library from core should be loaded.
$this->assertSession()->responseContains('/core/misc/active-link.js');
// The drupalSettings library from core should be loaded.
$this->assertSession()->responseContains('/core/misc/drupalSettingsLoader.js');
}
/**
* Give ajax_page_state[libraries]=core/html5shiv to exclude the library.
* Give ajax_page_state[libraries]=core/drupalSettings to exclude the library.
*
* When called with ajax_page_state[libraries]=core/html5shiv the library
* When called with ajax_page_state[libraries]=core/drupalSettings the library
* should be excluded as it is already loaded. This should not affect other
* libraries so test if drupalSettings is still available.
* libraries so test if active-link is still available.
*/
public function testHtml5ShivIsNotLoaded() {
public function testDrupalSettingsIsNotLoaded() {
$this->drupalGet('node',
[
"query" =>
[
'ajax_page_state' => [
'libraries' => 'core/html5shiv',
'libraries' => 'core/drupalSettings',
],
],
]
);
$this->assertNoRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
'The html5shiv library from core should be excluded from loading'
);
// The drupalSettings library from core should be excluded from loading.
$this->assertSession()->responseNotContains('/core/misc/drupalSettingsLoader.js');
$this->assertRaw(
'/core/misc/drupalSettingsLoader.js',
'The drupalSettings library from core should be loaded.'
);
// The active-link library from core should be loaded.
$this->assertSession()->responseContains('/core/misc/active-link.js');
}
/**
@ -91,29 +82,21 @@ class AjaxPageStateTest extends BrowserTestBase {
*/
public function testMultipleLibrariesAreNotLoaded() {
$this->drupalGet('node',
['query' => ['ajax_page_state' => ['libraries' => 'core/html5shiv,core/drupalSettings']]]
);
$this->assertResponse(200);
$this->assertNoRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
'The html5shiv library from core should be excluded from loading.'
['query' => ['ajax_page_state' => ['libraries' => 'core/drupal,core/drupalSettings']]]
);
$this->assertSession()->statusCodeEquals(200);
// The drupal library from core should be excluded from loading.
$this->assertSession()->responseNotContains('/core/misc/drupal.js');
$this->assertNoRaw(
'/core/misc/drupalSettingsLoader.js',
'The drupalSettings library from core should be excluded from loading.'
);
// The drupalSettings library from core should be excluded from loading.
$this->assertSession()->responseNotContains('/core/misc/drupalSettingsLoader.js');
$this->drupalGet('node');
$this->assertRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
'The html5shiv library from core should be included in loading.'
);
// The drupal library from core should be included in loading.
$this->assertSession()->responseContains('/core/misc/drupal.js');
$this->assertRaw(
'/core/misc/drupalSettingsLoader.js',
'The drupalSettings library from core should be included in loading.'
);
// The drupalSettings library from core should be included in loading.
$this->assertSession()->responseContains('/core/misc/drupalSettingsLoader.js');
}
}

View File

@ -190,7 +190,6 @@ trait DeprecationListenerTrait {
'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/html5shiv" asset library is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/3086383',
'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',
];