Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strictify shiv #149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/html5shiv-printshiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
;(function(window, document) {
'use strict';

/*jshint evil:true */
/** version */
var version = '3.7.0';
Expand Down Expand Up @@ -183,7 +185,7 @@
return createElement(nodeName, ownerDocument, data);
};

ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
ownerDocument.createDocumentFragment = new Function('h,f', 'return function(){' +
'var n=f.cloneNode(),c=n.createElement;' +
'h.shivMethods&&(' +
// unroll the `createElement` calls
Expand Down Expand Up @@ -332,7 +334,7 @@
var node,
nodes = ownerDocument.getElementsByTagName('*'),
index = nodes.length,
reElements = RegExp('^(?:' + getElements().join('|') + ')$', 'i'),
reElements = new RegExp('^(?:' + getElements().join('|') + ')$', 'i'),
result = [];

while (index--) {
Expand All @@ -359,7 +361,9 @@
// copy element attributes to the wrapper
while (index--) {
node = nodes[index];
node.specified && wrapper.setAttribute(node.nodeName, node.nodeValue);
if (node.specified) {
wrapper.setAttribute(node.nodeName, node.nodeValue);
}
}
// copy element styles to the wrapper
wrapper.style.cssText = element.style.cssText;
Expand All @@ -377,7 +381,7 @@
var pair,
parts = cssText.split('{'),
index = parts.length,
reElements = RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
reElements = new RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
replacement = '$1' + shivNamespace + '\\:$2';

while (index--) {
Expand Down Expand Up @@ -440,7 +444,7 @@
collection = ownerDocument.styleSheets,
cssText = [],
index = collection.length,
sheets = Array(index);
sheets = new Array(index);

// convert styleSheets collection to an array
while (index--) {
Expand Down
12 changes: 7 additions & 5 deletions src/html5shiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
;(function(window, document) {
'use strict';

/*jshint evil:true */
/** version */
var version = '3.7.0';
Expand Down Expand Up @@ -37,14 +39,14 @@
//if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
supportsHtml5Styles = ('hidden' in a);

supportsUnknownElements = a.childNodes.length == 1 || (function() {
supportsUnknownElements = a.childNodes.length === 1 || (function() {
// assign a false positive if unable to shiv
(document.createElement)('a');
var frag = document.createDocumentFragment();
return (
typeof frag.cloneNode == 'undefined' ||
typeof frag.createDocumentFragment == 'undefined' ||
typeof frag.createElement == 'undefined'
typeof frag.cloneNode === 'undefined' ||
typeof frag.createDocumentFragment === 'undefined' ||
typeof frag.createElement === 'undefined'
);
}());
} catch(e) {
Expand Down Expand Up @@ -79,7 +81,7 @@
*/
function getElements() {
var elements = html5.elements;
return typeof elements == 'string' ? elements.split(' ') : elements;
return typeof elements === 'string' ? elements.split(' ') : elements;
}

/**
Expand Down