From b2d023732a22ace5d141ba9c226842aec79ef04d Mon Sep 17 00:00:00 2001 From: scottjehl Date: Fri, 23 Sep 2011 19:17:22 -0400 Subject: [PATCH] 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) --- js/jquery.mobile.degradeInputs.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/jquery.mobile.degradeInputs.js b/js/jquery.mobile.degradeInputs.js index 8f4a0245..aeec2c43 100644 --- a/js/jquery.mobile.degradeInputs.js +++ b/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( - $( "
" ).html( $this.clone() ).html() - .replace( /\s+type=["']?\w+['"]?/, " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\" " ) - ); + var html = $( "
" ).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 ) ); } });