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

Commit 0df7329

Browse files
committed
fix for ng:include does not remove partial if src goes to undefined
1 parent 59401b8 commit 0df7329

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/widgets.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ angularWidget('ng:include', function(element){
260260
compiler.compile(element)(element, childScope);
261261
childScope.$init();
262262
});
263+
} else {
264+
element.html('');
263265
}
264266
});
265267
};

test/widgetsSpec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,21 @@ describe("widget", function(){
436436
scope.$init();
437437
expect(element.text()).toEqual('misko');
438438
});
439+
440+
it('should remove previously included text if a falsy value is bound to src', function() {
441+
var element = jqLite('<ng:include src="url" scope="childScope"></ng:include>');
442+
var scope = angular.compile(element);
443+
scope.childScope = createScope();
444+
scope.childScope.name = 'igor';
445+
scope.url = 'myUrl';
446+
scope.$xhr.cache.data.myUrl = {value:'{{name}}'};
447+
scope.$init();
448+
449+
scope.url = undefined;
450+
scope.$eval();
451+
452+
expect(element.text()).toEqual('');
453+
});
439454
});
440455
});
441456

0 commit comments

Comments
 (0)