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

Make directives copy attributes with spaces (Fix for issue 5513) #5597

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {

nName = directiveNormalize(name.toLowerCase());
attrsMap[nName] = name;
attrs[nName] = value = trim(attr.value);
attrs[nName] = value = attr.value;
if (getBooleanAttrName(node, nName)) {
attrs[nName] = true; // presence means true
}
Expand Down
8 changes: 8 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,14 @@ describe('$compile', function() {
expect(componentScope.attrAlias).toEqual(componentScope.attr);
}));

it('should copy simple attribute value with spaces', inject(function() {
compile('<div><span my-component attr=" some text ">');

expect(componentScope.attr).toEqual(' some text ');
expect(componentScope.attrAlias).toEqual(' some text ');
expect(componentScope.attrAlias).toEqual(componentScope.attr);
}));

it('should set up the interpolation before it reaches the link function', inject(function() {
$rootScope.name = 'misko';
compile('<div><span my-component attr="hello {{name}}">');
Expand Down