From 0df7329a6a15947503f891fdfa933770a70559df Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 16 Aug 2010 16:47:39 -0700 Subject: fix for ng:include does not remove partial if src goes to undefined --- src/widgets.js | 2 ++ test/widgetsSpec.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/widgets.js b/src/widgets.js index 87a302fa..a3874a51 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -260,6 +260,8 @@ angularWidget('ng:include', function(element){ compiler.compile(element)(element, childScope); childScope.$init(); }); + } else { + element.html(''); } }); }; diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index ad98e482..bdc8e59d 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -436,6 +436,21 @@ describe("widget", function(){ scope.$init(); expect(element.text()).toEqual('misko'); }); + + it('should remove previously included text if a falsy value is bound to src', function() { + var element = jqLite(''); + var scope = angular.compile(element); + scope.childScope = createScope(); + scope.childScope.name = 'igor'; + scope.url = 'myUrl'; + scope.$xhr.cache.data.myUrl = {value:'{{name}}'}; + scope.$init(); + + scope.url = undefined; + scope.$eval(); + + expect(element.text()).toEqual(''); + }); }); }); -- cgit v1.2.3