SIGN IN SIGN UP
angular / angular.js UNCLAIMED

AngularJS - HTML enhanced for web apps!

0 0 0 JavaScript

fix($compile): don't trim white-space in attributes

This allows developers to use white-space in their attributes, for example as value for
input[type=radio], as a separator in ngList, or as a value in any custom directive binding.
It's also consistent with the HTML spec, which allows white-space in attributes, and consistent
with Angular2, which also allows white-space in attributes.

Fixes #5513
Fixes #14539
Closes #5597

BREAKING CHANGE:

White-space in attributes is no longer trimmed automatically. This includes leading and trailing
white-space, and attributes that are purely white-space.

To migrate, attributes that require trimming must now be trimmed manually.

A common cases where stray white-space can cause problems is when
attribute values are compared, for example in an $observer:

Before:
```
$attrs.$observe('myAttr', function(newVal) {
  if (newVal === 'false') ...
});
```

To migrate, the attribute value should be trimmed manually:
```
$attrs.$observe('myAttr', function(newVal) {
  if (newVal.trim() === 'false') ...
});
```

Note that `$parse` trims expressions automatically, so attributes with expressions (e.g. directive
bindings) are unlikely to be affected by stray white-space.
S
Siddique Hameed committed
97bbf86a1979d099802f0d631c17c54b87563b40
Parent: 3ba29c4
Committed by Martin Staffa <mjstaffa@gmail.com> on 6/9/2016, 8:56:31 PM