Skip to content

Instantly share code, notes, and snippets.

@renan
Created July 6, 2011 09:06
Show Gist options
  • Save renan/1066877 to your computer and use it in GitHub Desktop.
Save renan/1066877 to your computer and use it in GitHub Desktop.
jQuery + innerShiv, checking if it have any html5 tag on it first, see https://github.com/jdbartlett/innershiv/issues/9
(function ($) {
var init = jQuery.fn.init; rootjQuery = jQuery(document);
var html5 = 'abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' ');
$.fn.init = function (selector, context, rootjQuery) {
if (typeof selector == 'string' && selector.indexOf('>') != -1 && selector.indexOf('<') != -1) {
for (var i in html5) {
if (selector.indexOf('<' + html5[i]) != -1) {
return new init(innerShiv(selector, false), context, rootjQuery);
}
}
return new init(selector, context, rootjQuery);
}
return new init(selector, context, rootjQuery);
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment