Skip to content

Instantly share code, notes, and snippets.

@SlexAxton
Forked from anonymous/modernizr-2.5.2.min.js
Created February 8, 2012 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SlexAxton/1775195 to your computer and use it in GitHub Desktop.
Save SlexAxton/1775195 to your computer and use it in GitHub Desktop.
Modernizr 2.5.2 that crashes IE7/8
/* Modernizr 2.5.2 (Custom Build) | MIT & BSD
* Build: http://www.modernizr.com/download/#-shiv
*/
;
window.Modernizr = function (a, b, c) {
function t(a) {
i.cssText = a
}
function u(a, b) {
return t(prefixes.join(a + ";") + (b || ""))
}
function v(a, b) {
return typeof a === b
}
function w(a, b) {
return !!~ ("" + a).indexOf(b)
}
function x(a, b, d) {
for (var e in a) {
var f = b[a[e]];
if (f !== c) return d === !1 ? a[e] : v(f, "function") ? f.bind(d || b) : f
}
return !1
}
var d = "2.5.2",
e = {},
f = b.documentElement,
g = "modernizr",
h = b.createElement(g),
i = h.style,
j, k = {}.toString,
l = {},
m = {},
n = {},
o = [],
p = o.slice,
q, r = {}.hasOwnProperty,
s;
!v(r, "undefined") && !v(r.call, "undefined") ? s = function (a, b) {
return r.call(a, b)
} : s = function (a, b) {
return b in a && v(a.constructor.prototype[b], "undefined")
}, Function.prototype.bind || (Function.prototype.bind = function (b) {
var c = this;
if (typeof c != "function") throw new TypeError;
var d = p.call(arguments, 1),
e = function () {
if (this instanceof e) {
var a = function () {};
a.prototype = c.prototype;
var f = new a,
g = c.apply(f, d.concat(p.call(arguments)));
return Object(g) === g ? g : f
}
return c.apply(b, d.concat(p.call(arguments)))
};
return e
});
for (var y in l) s(l, y) && (q = y.toLowerCase(), e[q] = l[y](), o.push((e[q] ? "" : "no-") + q));
return t(""), h = j = null, function (a, b) {
function g(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 h() {
var a = k.elements;
return typeof a == "string" ? a.split(" ") : a
}
function i(a) {
function m() {
var a = j.cloneNode(!1);
return k.shivMethods ? (i(a), a) : a
}
function n(a) {
var b = (c[a] || (c[a] = e(a))).cloneNode(!1);
return k.shivMethods && !d.test(a) ? j.appendChild(b) : b
}
var b, c = {},
e = a.createElement,
f = a.createDocumentFragment,
g = h(),
j = f(),
l = g.length;
while (l--) b = g[l], c[b] = e(b), j.createElement(b);
a.createElement = n, a.createDocumentFragment = m
}
function j(a) {
var b;
return a.documentShived ? a : (k.shivCSS && !e && (b = !! g(a, "article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")), k.shivMethods && !f && (b = !i(a)), b && (a.documentShived = b), a)
}
var c = a.html5 || {},
d = /^<|^(?:button|iframe|input|script|textarea)$/i,
e, f;
(function () {
var c, d = b.createElement("a"),
g = a.getComputedStyle,
h = b.documentElement,
i = b.body || (c = h.insertBefore(b.createElement("body"), h.firstChild));
i.insertBefore(d, i.firstChild), d.hidden = !0, d.innerHTML = "<xyz></xyz>", e = (d.currentStyle || g(d, null)).display == "none", f = d.childNodes.length == 1 ||
function () {
try {
b.createElement("a")
} catch (a) {
return !0
}
var c = b.createDocumentFragment();
return typeof c.cloneNode == "undefined" || typeof c.createDocumentFragment == "undefined" || typeof c.createElement == "undefined"
}(), i.removeChild(d), c && h.removeChild(c)
})();
var k = {
elements: c.elements || "abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
shivCSS: c.shivCSS !== !1,
shivMethods: c.shivMethods !== !1,
type: "default",
shivDocument: j
};
a.html5 = k, j(b)
}(this, b), e._version = d, e
}(this, this.document);
/* Modernizr 2.5.2 (Custom Build) | MIT & BSD
* Build: http://www.modernizr.com/download/#-shiv
*/
;
window.Modernizr = (function( window, document, undefined ) {
var version = '2.5.2',
Modernizr = {},
docElement = document.documentElement,
mod = 'modernizr',
modElem = document.createElement(mod),
mStyle = modElem.style,
inputElem ,
toString = {}.toString, tests = {},
inputs = {},
attrs = {},
classes = [],
slice = classes.slice,
featureName,
_hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
hasOwnProperty = function (object, property) {
return _hasOwnProperty.call(object, property);
};
}
else {
hasOwnProperty = function (object, property) {
return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
};
}
if (!Function.prototype.bind) {
Function.prototype.bind = function bind(that) {
var target = this;
if (typeof target != "function") {
throw new TypeError();
}
var args = slice.call(arguments, 1),
bound = function () {
if (this instanceof bound) {
var F = function(){};
F.prototype = target.prototype;
var self = new F;
var result = target.apply(
self,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return self;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
return bound;
};
}
function setCss( str ) {
mStyle.cssText = str;
}
function setCssAll( str1, str2 ) {
return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
}
function is( obj, type ) {
return typeof obj === type;
}
function contains( str, substr ) {
return !!~('' + str).indexOf(substr);
}
function testDOMProps( props, obj, elem ) {
for ( var i in props ) {
var item = obj[props[i]];
if ( item !== undefined) {
if (elem === false) return props[i];
if (is(item, 'function')){
return item.bind(elem || obj);
}
return item;
}
}
return false;
}
for ( var feature in tests ) {
if ( hasOwnProperty(tests, feature) ) {
featureName = feature.toLowerCase();
Modernizr[featureName] = tests[feature]();
classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
}
}
setCss('');
modElem = inputElem = null;
(function(window, document) {
var options = window.html5 || {};
var reSkip = /^<|^(?:button|iframe|input|script|textarea)$/i;
var supportsHtml5Styles;
var supportsUnknownElements;
(function() {
var fake,
a = document.createElement('a'),
compStyle = window.getComputedStyle,
docEl = document.documentElement,
body = document.body || (fake = docEl.insertBefore(document.createElement('body'), docEl.firstChild));
body.insertBefore(a, body.firstChild);
a.hidden = true;
a.innerHTML = '<xyz></xyz>';
supportsHtml5Styles = (a.currentStyle || compStyle(a, null)).display == 'none';
supportsUnknownElements = a.childNodes.length == 1 || (function() {
try {
(document.createElement)('a');
} catch(e) {
return true;
}
var frag = document.createDocumentFragment();
return (
typeof frag.cloneNode == 'undefined' ||
typeof frag.createDocumentFragment == 'undefined' ||
typeof frag.createElement == 'undefined'
);
}());
body.removeChild(a);
fake && docEl.removeChild(fake);
}()); function addStyleSheet(ownerDocument, cssText) {
var p = ownerDocument.createElement('p'),
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
p.innerHTML = 'x<style>' + cssText + '</style>';
return parent.insertBefore(p.lastChild, parent.firstChild);
}
function getElements() {
var elements = html5.elements;
return typeof elements == 'string' ? elements.split(' ') : elements;
}
function shivMethods(ownerDocument) {
var nodeName,
cache = {},
docCreateElement = ownerDocument.createElement,
docCreateFragment = ownerDocument.createDocumentFragment,
elements = getElements(),
frag = docCreateFragment(),
index = elements.length;
function createDocumentFragment() {
var node = frag.cloneNode(false);
return html5.shivMethods ? (shivMethods(node), node) : node;
}
function createElement(nodeName) {
var node = (cache[nodeName] || (cache[nodeName] = docCreateElement(nodeName))).cloneNode(false);
return html5.shivMethods && !reSkip.test(nodeName) ? frag.appendChild(node) : node;
}
while (index--) {
nodeName = elements[index];
cache[nodeName] = docCreateElement(nodeName);
frag.createElement(nodeName);
}
ownerDocument.createElement = createElement;
ownerDocument.createDocumentFragment = createDocumentFragment;
} function shivDocument(ownerDocument) {
var shived;
if (ownerDocument.documentShived) {
return ownerDocument;
}
if (html5.shivCSS && !supportsHtml5Styles) {
shived = !!addStyleSheet(ownerDocument,
'article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}' +
'audio{display:none}' +
'canvas,video{display:inline-block;*display:inline;*zoom:1}' +
'[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}' +
'mark{background:#FF0;color:#000}'
);
}
if (html5.shivMethods && !supportsUnknownElements) {
shived = !shivMethods(ownerDocument);
}
if (shived) {
ownerDocument.documentShived = shived;
}
return ownerDocument;
} var html5 = {
'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' '),
'shivCSS': !(options.shivCSS === false),
'shivMethods': !(options.shivMethods === false),
'type': 'default',
'shivDocument': shivDocument
}; window.html5 = html5;
shivDocument(document);
}(window, document));
Modernizr._version = version;
return Modernizr;
})(this, this.document);
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment