From 21730203599313bb61ae4249f4c1cc2e2fe9e2d1 Mon Sep 17 00:00:00 2001
From: Nathaniel <catch@35733.no-reply.drupal.org>
Date: Thu, 17 Nov 2011 16:33:06 +0900
Subject: [PATCH] Issue #1077878 by ericduran, Mark Trapp, JohnAlbin,
 jessebeach, Jacine: Added HTML5shiv to core.

---
 core/CHANGELOG.txt                        |  1 +
 core/includes/common.inc                  |  1 +
 core/misc/html5.js                        |  4 ++++
 core/modules/simpletest/tests/common.test |  1 +
 core/modules/system/system.module         | 14 ++++++++++++++
 5 files changed, 21 insertions(+)
 create mode 100644 core/misc/html5.js

diff --git a/core/CHANGELOG.txt b/core/CHANGELOG.txt
index fd6d2d0ec743..72cff5418e4d 100644
--- a/core/CHANGELOG.txt
+++ b/core/CHANGELOG.txt
@@ -1,6 +1,7 @@
 
 Drupal 8.0, xxxx-xx-xx (development version)
 ----------------------
+- Included the HTML5 Shiv library to support HTML5 elements in IE 8 and below.
 - Included the following Symfony2 components:
     * ClassLoader - PSR-0-compatible autoload routines.
     * HttpFoundation - Abstraction objects for HTTP requests and responses.
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 1bd8b1910e4b..f8d1aab7f194 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3972,6 +3972,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
       // Register all required libraries.
       drupal_add_library('system', 'jquery', TRUE);
       drupal_add_library('system', 'jquery.once', TRUE);
+      drupal_add_library('system', 'html5shiv', TRUE);
     }
 
     switch ($options['type']) {
diff --git a/core/misc/html5.js b/core/misc/html5.js
new file mode 100644
index 000000000000..6692336c18a1
--- /dev/null
+++ b/core/misc/html5.js
@@ -0,0 +1,4 @@
+// iepp v2.1pre @jon_neal & @aFarkas github.com/aFarkas/iepp
+// html5shiv @rem remysharp.com/html5-enabling-script
+// Dual licensed under the MIT or GPL Version 2 licenses
+/*@cc_on(function(a,b){function r(a){var b=-1;while(++b<f)a.createElement(e[b])}if(!window.attachEvent||!b.createStyleSheet||!function(){var a=document.createElement("div");return a.innerHTML="<elem></elem>",a.childNodes.length!==1}())return;a.iepp=a.iepp||{};var c=a.iepp,d=c.html5elements||"abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|subline|summary|time|video",e=d.split("|"),f=e.length,g=new RegExp("(^|\\s)("+d+")","gi"),h=new RegExp("<(/*)("+d+")","gi"),i=/^\s*[\{\}]\s*$/,j=new RegExp("(^|[^\\n]*?\\s)("+d+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),k=b.createDocumentFragment(),l=b.documentElement,m=b.getElementsByTagName("script")[0].parentNode,n=b.createElement("body"),o=b.createElement("style"),p=/print|all/,q;c.getCSS=function(a,b){try{if(a+""===undefined)return""}catch(d){return""}var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,p.test(b)&&h.push(c.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},c.parseCSS=function(a){var b=[],c;while((c=j.exec(a))!=null)b.push(((i.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(g,"$1.iepp-$2")+c[4]);return b.join("\n")},c.writeHTML=function(){var a=-1;q=q||b.body;while(++a<f){var c=b.getElementsByTagName(e[a]),d=c.length,g=-1;while(++g<d)c[g].className.indexOf("iepp-")<0&&(c[g].className+=" iepp-"+e[a])}k.appendChild(q),l.appendChild(n),n.className=q.className,n.id=q.id,n.innerHTML=q.innerHTML.replace(h,"<$1font")},c._beforePrint=function(){if(c.disablePP)return;o.styleSheet.cssText=c.parseCSS(c.getCSS(b.styleSheets,"all")),c.writeHTML()},c.restoreHTML=function(){if(c.disablePP)return;n.swapNode(q)},c._afterPrint=function(){c.restoreHTML(),o.styleSheet.cssText=""},r(b),r(k);if(c.disablePP)return;m.insertBefore(o,m.firstChild),o.media="print",o.className="iepp-printshim",a.attachEvent("onbeforeprint",c._beforePrint),a.attachEvent("onafterprint",c._afterPrint)})(this,document)@*/
diff --git a/core/modules/simpletest/tests/common.test b/core/modules/simpletest/tests/common.test
index 8406ec808c8a..78da5e424547 100644
--- a/core/modules/simpletest/tests/common.test
+++ b/core/modules/simpletest/tests/common.test
@@ -1189,6 +1189,7 @@ class JavaScriptTestCase extends DrupalWebTestCase {
     $javascript = drupal_add_js('core/misc/collapse.js');
     $this->assertTrue(array_key_exists('core/misc/jquery.js', $javascript), t('jQuery is added when a file is added.'));
     $this->assertTrue(array_key_exists('core/misc/drupal.js', $javascript), t('Drupal.js is added when file is added.'));
+    $this->assertTrue(array_key_exists('core/misc/html5.js', $javascript), t('html5.js is added when file is added.'));
     $this->assertTrue(array_key_exists('core/misc/collapse.js', $javascript), t('JavaScript files are correctly added.'));
     $this->assertEqual(base_path(), $javascript['settings']['data'][0]['basePath'], t('Base path JavaScript setting is correctly set.'));
     url('', array('prefix' => &$prefix));
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 334351e4b191..c3f9e09ebcab 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1240,6 +1240,20 @@ function system_library_info() {
     ),
   );
 
+  // HTML5 Shiv.
+  $libraries['html5shiv'] = array(
+    'title' => 'html5shiv',
+    'website' => 'http://code.google.com/p/html5shiv/',
+    'version' => '11',
+    'js' => array(
+      'core/misc/html5.js' => array(
+        'group' => JS_LIBRARY,
+        'weight' => -21,
+        'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE),
+      ),
+    ),
+  );
+
   // Cookie.
   $libraries['jquery.cookie'] = array(
     'title' => 'Cookie',
-- 
GitLab