Skip to content
This repository
Browse code

revert prop to attr changes Fixes: #3670

  • Loading branch information...
commit c1e230f650a27d26142ba52a42dfa1940e85a46c 1 parent 27a7095
John Bender authored February 29, 2012
25  js/jquery.mobile.forms.checkboxradio.js
@@ -60,10 +60,10 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
60 60
 		});
61 61
 
62 62
 		// Wrap the input + label in a div
63  
-		var wrapper = document.createElement('div');		
64  
-		wrapper.className = 'ui-' + inputtype;	
  63
+		var wrapper = document.createElement('div');
  64
+		wrapper.className = 'ui-' + inputtype;
65 65
 		input[0].parentNode.insertBefore(wrapper,input[0]);
66  
-		wrapper.appendChild(input[0]);				
  66
+		wrapper.appendChild(input[0]);
67 67
 		wrapper.appendChild(label[0]);
68 68
 
69 69
 		label.bind({
@@ -80,8 +80,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
80 80
 				}
81 81
 
82 82
 				self._cacheVals();
83  
-				input.attr( "checked", inputtype === "radio" && true || !input.attr( "checked" ) );
84  
-				//input.prop( "checked", inputtype === "radio" && true || !input.attr( "checked" ) );
  83
+
  84
+				input.prop( "checked", inputtype === "radio" && true || !input.prop( "checked" ) );
85 85
 
86 86
 				// trigger click handler's bound directly to the input as a substitute for
87 87
 				// how label clicks behave normally in the browsers
@@ -93,7 +93,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
93 93
 				// Input set for common radio buttons will contain all the radio
94 94
 				// buttons, but will not for checkboxes. clearing the checked status
95 95
 				// of other radios ensures the active button state is applied properly
96  
-				self._getInputSet().not( input ).removeAttr( "checked" );
  96
+				self._getInputSet().not( input ).prop( "checked", false );
97 97
 
98 98
 				self._updateAll();
99 99
 				return false;
@@ -113,11 +113,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
113 113
 					// Adds checked attribute to checked input when keyboard is used
114 114
 					if ( $this.is( ":checked" ) ) {
115 115
 
116  
-						$this.attr( "checked", "checked" );
117  
-						self._getInputSet().not($this).removeAttr( "checked" );
  116
+						$this.prop( "checked", true);
  117
+						self._getInputSet().not($this).prop( "checked", false );
118 118
 					} else {
119 119
 
120  
-						$this.removeAttr( "checked" );
  120
+						$this.prop( "checked", false );
121 121
 					}
122 122
 
123 123
 					self._updateAll();
@@ -161,7 +161,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
161 161
 
162 162
 			// NOTE getAttribute is used here to deal with an issue with the :checked
163 163
 			//      selector. see #3597
164  
-			if ( this.getAttribute( "checked" ) || self.inputtype === "checkbox" ) {
  164
+			if ( $this.prop( "checked" ) || self.inputtype === "checkbox" ) {
165 165
 				$this.trigger( "change" );
166 166
 			}
167 167
 		})
@@ -175,8 +175,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
175 175
 
176 176
 		// input[0].checked expando doesn't always report the proper value
177 177
 		// for checked='checked'
178  
-
179  
-		if ( input[ 0 ].getAttribute( "checked" ) ) {
  178
+		if ( $( input[ 0 ] ).prop( "checked" ) ) {
180 179
 			label.addClass( this.checkedClass ).removeClass( this.uncheckedClass );
181 180
 			icon.addClass( this.checkedicon ).removeClass( this.uncheckedicon );
182 181
 		} else {
@@ -192,7 +191,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
192 191
 	},
193 192
 
194 193
 	disable: function() {
195  
-		this.element.attr( "disabled", true ).parent().addClass( "ui-disabled" );
  194
+		this.element.prop( "disabled", true ).parent().addClass( "ui-disabled" );
196 195
 	},
197 196
 
198 197
 	enable: function() {
8  tests/unit/checkboxradio/checkboxradio_core.js
@@ -88,11 +88,11 @@
88 88
 			},
89 89
 
90 90
 			function(){
91  
-				ok( $radioBtns.last()[0].getAttribute( 'checked' ) == "checked" );
  91
+				ok( $radioBtns.last().prop( 'checked' ), "last input is checked" );
92 92
 				ok( $radioBtns.last().siblings( 'label' ).hasClass( 'ui-radio-on' ),
93 93
 					"last input label is an active button" );
94 94
 
95  
-				ok( $radioBtns.first()[0].getAttribute( 'checked' ) !== "checked" );
  95
+				ok( !$radioBtns.first().prop( 'checked' ), "first input label is not active" );
96 96
 				ok( !$radioBtns.first().siblings( 'label' ).hasClass( 'ui-radio-on' ),
97 97
 					"first input label is not active" );
98 98
 
@@ -102,11 +102,11 @@
102 102
 			},
103 103
 
104 104
 			function(){
105  
-				ok( $radioBtns.first()[0].getAttribute( 'checked' ) == "checked");
  105
+				ok( $radioBtns.first().prop( 'checked' ));
106 106
 				ok( $radioBtns.first().siblings( 'label' ).hasClass( 'ui-radio-on' ),
107 107
 					"first input label is an active button" );
108 108
 
109  
-				ok( $radioBtns.last()[0].getAttribute( 'checked' ) !== "checked");
  109
+				ok( !$radioBtns.last().prop( 'checked' ));
110 110
 				ok( !$radioBtns.last().siblings( 'label' ).hasClass( 'ui-radio-on' ),
111 111
 					"last input label is not active" );
112 112
 

0 notes on commit c1e230f

Please sign in to comment.
Something went wrong with that request. Please try again.