Fixes #2490 where IE (and WP7) were not properly degrading form inputs via the degradeinputs plugin (and search inputs were not being styled as such)

This commit is contained in:
scottjehl 2011-09-23 19:17:22 -04:00
parent adc1ecc2e6
commit b2d023732a

View file

@ -39,10 +39,13 @@ $( document ).bind( "pagecreate enhance", function( e ){
optType = o.degradeInputs[ type ] || "text";
if ( o.degradeInputs[ type ] ) {
$this.replaceWith(
$( "<div>" ).html( $this.clone() ).html()
.replace( /\s+type=["']?\w+['"]?/, " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\" " )
);
var html = $( "<div>" ).html( $this.clone() ).html(),
// In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
hasType = html.indexOf( " type=" ) > -1,
findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/,
repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" );
$this.replaceWith( html.replace( findstr, repstr ) );
}
});