Skip to content

Commit f9102c5

Browse files
committed
Move styles to addStyleSheet function
This helps some minifiers which aren’t smart enough to inline the function in the first place.
1 parent 9ffc7aa commit f9102c5

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/html5shiv-printshiv.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,24 @@
5050
/*--------------------------------------------------------------------------*/
5151

5252
/**
53-
* Creates a style sheet with the given CSS text and adds it to the document.
53+
* Creates a style sheet with a shiv CSS text and adds it to the document.
5454
* @private
5555
* @param {Document} ownerDocument The document.
5656
* @param {String} cssText The CSS text.
5757
* @returns {StyleSheet} The style element.
5858
*/
59-
function addStyleSheet(ownerDocument, cssText) {
59+
function addStyleSheet(ownerDocument) {
6060
var p = ownerDocument.createElement('p'),
6161
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
6262

63-
p.innerHTML = 'x<style>' + cssText + '</style>';
63+
p.innerHTML = 'x<style>' +
64+
// corrects block display not defined in IE6/7/8/9
65+
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
66+
// adds styling not present in IE6/7/8/9
67+
'mark{background:#FF0;color:#000}' +
68+
// hides non-rendered elements
69+
'template{display:none}' +
70+
'</style>';
6471
return parent.insertBefore(p.lastChild, parent.firstChild);
6572
}
6673

@@ -221,14 +228,7 @@
221228
var data = getExpandoData(ownerDocument);
222229

223230
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
224-
data.hasCSS = !!addStyleSheet(ownerDocument,
225-
// corrects block display not defined in IE6/7/8/9
226-
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
227-
// adds styling not present in IE6/7/8/9
228-
'mark{background:#FF0;color:#000}' +
229-
// hides non-rendered elements
230-
'template{display:none}'
231-
);
231+
data.hasCSS = !!addStyleSheet(ownerDocument);
232232
}
233233
if (!supportsUnknownElements) {
234234
shivMethods(ownerDocument, data);

src/html5shiv.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,24 @@
5050
/*--------------------------------------------------------------------------*/
5151

5252
/**
53-
* Creates a style sheet with the given CSS text and adds it to the document.
53+
* Creates a style sheet with a shiv CSS text and adds it to the document.
5454
* @private
5555
* @param {Document} ownerDocument The document.
5656
* @param {String} cssText The CSS text.
5757
* @returns {StyleSheet} The style element.
5858
*/
59-
function addStyleSheet(ownerDocument, cssText) {
59+
function addStyleSheet(ownerDocument) {
6060
var p = ownerDocument.createElement('p'),
6161
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
6262

63-
p.innerHTML = 'x<style>' + cssText + '</style>';
63+
p.innerHTML = 'x<style>' +
64+
// corrects block display not defined in IE6/7/8/9
65+
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
66+
// adds styling not present in IE6/7/8/9
67+
'mark{background:#FF0;color:#000}' +
68+
// hides non-rendered elements
69+
'template{display:none}' +
70+
'</style>';
6471
return parent.insertBefore(p.lastChild, parent.firstChild);
6572
}
6673

@@ -221,14 +228,7 @@
221228
var data = getExpandoData(ownerDocument);
222229

223230
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
224-
data.hasCSS = !!addStyleSheet(ownerDocument,
225-
// corrects block display not defined in IE6/7/8/9
226-
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
227-
// adds styling not present in IE6/7/8/9
228-
'mark{background:#FF0;color:#000}' +
229-
// hides non-rendered elements
230-
'template{display:none}'
231-
);
231+
data.hasCSS = !!addStyleSheet(ownerDocument);
232232
}
233233
if (!supportsUnknownElements) {
234234
shivMethods(ownerDocument, data);

0 commit comments

Comments
 (0)