vincentlcy
vincentlcy

Reputation: 1217

How to test against HTML5 fallback with Modernizr

For example, I used Modernizr which fallback to jqueryUI 's datepicker if HTML5's date input type is not supported (sadly true in general )

It is implemented like this post

Besides full-blown browser-automation test / manual starting up my safari, are there simple mechanism that we can mock up Modernizr to test against these fallbacks?

as this scenario the fallback solution jqueryui does actually function in most and my development browser (Chrome)

Upvotes: 0

Views: 409

Answers (2)

Patrick
Patrick

Reputation: 13974

You should not be trying to disable the test in chrome, you should test in the browsers it fails in. A polyfill may work wonderfully in chrome, but fail in IE. At that point, you have just confirmed that a polyfill works in a browser that will never need it.

Upvotes: 2

Lasse
Lasse

Reputation: 1656

Wy not just comment out the if statement?

If you have more than 1 of those, I guess you could simply overwrite the value of Modernizr.inputtypes.date to false at the beginning of your JS:

Modernizr.inputtypes.date = false;
if(!Modernizr.inputtypes.date){
    //fallback here
}

Upvotes: 2

Related Questions