Skip to content

Commit

Permalink
finally figuring out how to stop moment tests in IE9 or lower without…
Browse files Browse the repository at this point in the history
… using jQuery
  • Loading branch information
Alex Vernacchia committed Nov 25, 2013
1 parent 9442bdc commit fd546be
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions test/datepicker-moment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@

require(['jquery', 'fuelux/datepicker'], function ($) {

var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while ( !all[0] ) {
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->';
}
return v > 4 ? v : undef;
}());
function uaMatch( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];

return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
}

var UA = uaMatch( navigator.userAgent );
var runTestsBoolean = true;

if( UA.browser === "msie" ) {
if( parseInt( UA.version, 10 ) <= 9) {
runTestsBoolean = false;
}
}

if( ie > 9 || !Boolean( ie ) ) {
if( runTestsBoolean ) {

var html = '<div>' +
'<div class="datepicker dropdown" id="datepicker1">' +
Expand Down

0 comments on commit fd546be

Please sign in to comment.