Permalink
Browse files

Fixes #2490 where IE (and WP7) were not properly degrading form input…

…s via the degradeinputs plugin (and search inputs were not being styled as such)
  • Loading branch information...
1 parent adc1ecc commit b2d023732a22ace5d141ba9c226842aec79ef04d scottjehl committed Sep 23, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 js/jquery.mobile.degradeInputs.js
@@ -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 ) );
}
});

0 comments on commit b2d0237

Please sign in to comment.