mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
fix($compile): retain CSS classes added in cloneAttachFn on asynchronous directives
Previously, classes added to asynchronous directive elements during the clone attach function would not persist after the node is merged with the template, prior to linking. This change corrects this behaviour and brings it in line with synchronous directives. Closes #5439 Closes #5617
This commit is contained in:
@@ -1128,6 +1128,26 @@ describe('$compile', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should copy classes from pre-template node into linked element', function() {
|
||||
module(function() {
|
||||
directive('test', valueFn({
|
||||
templateUrl: 'test.html',
|
||||
replace: true
|
||||
}));
|
||||
});
|
||||
inject(function($compile, $templateCache, $rootScope) {
|
||||
var child;
|
||||
$templateCache.put('test.html', '<p class="template-class">Hello</p>');
|
||||
element = $compile('<div test></div>')($rootScope, function(node) {
|
||||
node.addClass('clonefn-class');
|
||||
});
|
||||
$rootScope.$digest();
|
||||
expect(element).toHaveClass('template-class');
|
||||
expect(element).toHaveClass('clonefn-class');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('delay compile / linking functions until after template is resolved', function(){
|
||||
var template;
|
||||
beforeEach(module(function() {
|
||||
|
||||
Reference in New Issue
Block a user