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

fix(compile): compiling replace:true directives in external template #1860

Closed
wants to merge 1 commit 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 @@ -936,7 +936,7 @@ function $CompileProvider($provide) {

directives.unshift(derivedSyncDirective);
afterTemplateNodeLinkFn = applyDirectivesToNode(directives, $compileNode, tAttrs, childTranscludeFn);
afterTemplateChildLinkFn = compileNodes($compileNode.contents(), childTranscludeFn);
afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn);


while(linkQueue.length) {
Expand Down
18 changes: 18 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ describe('$compile', function() {
}
}));

directive('replace', valueFn({
restrict:'CAM',
replace: true,
template: '<span>Hello, {{name}}!</span>'
}));
}
));

Expand Down Expand Up @@ -732,6 +737,19 @@ describe('$compile', function() {
toEqual('<div><span class="i-hello">Hello, Elvis!</span></div>');
}
));


it('should compile template when replacing element in another template',
inject(function($compile, $templateCache, $rootScope) {
$templateCache.put('hello.html', '<div class="replace"></div>');
$rootScope.name = 'Elvis';
element = $compile('<div><b class="hello"></b></div>')($rootScope);

$rootScope.$digest();

expect(sortedHtml(element)).
toEqual('<div><b class="hello"><span class="replace">Hello, Elvis!</span></b></div>');
}));


it('should resolve widgets after cloning in append mode', function() {
Expand Down