Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

In attribute variable inside directive, attribute does not has right value #5513

Closed
Ciget opened this issue Dec 22, 2013 · 4 comments
Closed

Comments

@Ciget
Copy link

Ciget commented Dec 22, 2013

When i create my directive to use with autoNumeric, try to use variable attr inside compile function, like this:
compile: function(tElm, tAttrs)

So, problem is, when i put in html data-a-sep attribute with value " " (space), when i try to get this value from directive by using this:
tAttrs.aSep it returns me empty, NOT a SPACE.

As for me - it`s a bug. Or i miss something?

Thanks a lot.

@ghost ghost assigned tbosch Dec 28, 2013
@tbosch
Copy link
Contributor

tbosch commented Dec 28, 2013

Hi,
could you add a jsfiddle or plunker?

@Ciget
Copy link
Author

Ciget commented Dec 28, 2013

http://plnkr.co/edit/n4gF2w7SI7T6HJFbUNGO?p=preview

console.log("sep value:["+tAttrs.aSep+"]"); return sep value:[] instead of sep value:[ ]

siddii added a commit to siddii/angular.js that referenced this issue Jan 2, 2014
siddii added a commit to siddii/angular.js that referenced this issue Jan 2, 2014
@siddii
Copy link
Contributor

siddii commented Jan 2, 2014

Created a plunkr for the fix from my local build - http://plnkr.co/edit/ai1CKh?p=preview

@Ciget
Copy link
Author

Ciget commented Jan 2, 2014

Thank you so much

@btford btford removed the gh: issue label Aug 20, 2014
Narretz pushed a commit to Narretz/angular.js that referenced this issue Jun 8, 2016
BREAKING CHANGE:

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

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.

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:

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

Note that `$parse` trims expressions automatically, so attributes with expressions (e.g. directive
bindings) are unlikely to be affected by stray white-space.

Fixes angular#5513
Fixes angular#14539
Closes angular#5597

ngList test
Narretz pushed a commit to Narretz/angular.js that referenced this issue Jun 8, 2016
BREAKING CHANGE:

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

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.

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:

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

Note that `$parse` trims expressions automatically, so attributes with expressions (e.g. directive
bindings) are unlikely to be affected by stray white-space.

Fixes angular#5513
Fixes angular#14539
Closes angular#5597

ngList test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants