-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile): don't add replaced attributes twice to $attrs #14737
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -980,6 +980,29 @@ describe('$compile', function() { | |
})); | ||
|
||
|
||
it('should not set merged attributes twice in $attrs', function() { | ||
var attrs; | ||
|
||
module(function() { | ||
directive('logAttrs', function() { | ||
return { | ||
link: function($scope, $element, $attrs) { | ||
attrs = $attrs; | ||
} | ||
}; | ||
}); | ||
}); | ||
|
||
inject(function($compile, $rootScope) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried removing it - injection seems necessary |
||
element = $compile( | ||
'<div><div log-attrs replace class="myLog"></div><div>')($rootScope); | ||
var div = element.find('div'); | ||
expect(div.attr('class')).toBe('myLog log'); | ||
expect(attrs.class).toBe('myLog log'); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add a test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? Both are handled by the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are different |
||
|
||
|
||
it('should prevent multiple templates per element', inject(function($compile) { | ||
try { | ||
$compile('<div><span replace class="replace"></span></div>'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a breaking (and unnecessary) change 😃
Why not set
dstAttr[key]
forclass
andstyle
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gkalpak - I don't believe this is a BC. The previous behaviour was not to set
distAttr
forclass
andstyle
, so doing so would actually be a BC.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, you are right, it didn't. Any idea why?
It seems like an oversight (bug?)...
Anyway, this is consistent, so no harm 😃