You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
don't remove a boolean attribute for `.attr(attrName, '')`
656
701
@@ -1851,6 +1896,7 @@ Please read the [Sandbox Removal Blog Post](http://angularjs.blogspot.com/2016/0
1851
1896
- **jqLite:**
1852
1897
- implement `jqLite(f)` as an alias to `jqLite(document).ready(f)` ([369fb7](https://github.com/angular/angular.js/commit/369fb7f4f73664bcdab0350701552d8bef6f605e))
1853
1898
- don't throw for elements with missing `getAttribute` ([4e6c14](https://github.com/angular/angular.js/commit/4e6c14dcae4a9a30b3610a288ef8d20db47c4417))
1899
+
- don't get/set properties when getting/setting boolean attributes ([7ceb5f](https://github.com/angular/angular.js/commit/7ceb5f6fcc43d35d1b66c3151ce6a71c60309304), [#14126](https://github.com/angular/angular.js/issues/14126))
1854
1900
- don't remove a boolean attribute for `.attr(attrName, '')` ([3faf45](https://github.com/angular/angular.js/commit/3faf4505732758165083c9d21de71fa9b6983f4a))
1855
1901
- remove the attribute for `.attr(attribute, null)` ([4e3624](https://github.com/angular/angular.js/commit/4e3624552284d0e725bf6262b2e468cd2c7682fa))
1856
1902
- return `[]` for `.val()` on `<select multiple>` with no selection ([d882fd](https://github.com/angular/angular.js/commit/d882fde2e532216e7cf424495db1ccb5be1789f8))
@@ -2028,6 +2074,48 @@ var bgColor = elem.css('background-color');
2028
2074
var bgColor = elem.css('backgroundColor');
2029
2075
```
2030
2076
2077
+
- **[7ceb5f](https://github.com/angular/angular.js/commit/7ceb5f6fcc43d35d1b66c3151ce6a71c60309304)**: don't get/set properties when getting/setting boolean attributes
2078
+
2079
+
Previously, all boolean attributes were reflected into the corresponding property when calling a
2080
+
setter and from the corresponding property when calling a getter, even on elements that don't treat
2081
+
those attributes in a special way. Now Angular doesn't do it by itself, but relies on browsers to
2082
+
know when to reflect the property. Note that this browser-level conversion differs between browsers;
2083
+
if you need to dynamically change the state of an element, you should modify the property, not the
2084
+
attribute. See https://jquery.com/upgrade-guide/1.9/#attr-versus-prop- for a more detailed
2085
+
description about a related change in jQuery 1.9.
2086
+
2087
+
This change aligns jqLite with jQuery 3. To migrate the code follow the example below:
2088
+
2089
+
Before:
2090
+
2091
+
CSS:
2092
+
2093
+
```css
2094
+
input[checked="checked"] { ... }
2095
+
```
2096
+
2097
+
JS:
2098
+
2099
+
```js
2100
+
elem1.attr('checked', 'checked');
2101
+
elem2.attr('checked', false);
2102
+
```
2103
+
2104
+
After:
2105
+
2106
+
CSS:
2107
+
2108
+
```css
2109
+
input:checked { ... }
2110
+
```
2111
+
2112
+
JS:
2113
+
2114
+
```js
2115
+
elem1.prop('checked', true);
2116
+
elem2.prop('checked', false);
2117
+
```
2118
+
2031
2119
- **[3faf45](https://github.com/angular/angular.js/commit/3faf4505732758165083c9d21de71fa9b6983f4a)**: don't remove a boolean attribute for `.attr(attrName, '')`
2032
2120
2033
2121
Before, using the `attr` method with an empty string as a value
0 commit comments