From 9899959d695a97ddbb3e9a626a769efa714bffe7 Mon Sep 17 00:00:00 2001 From: iminar Date: Mon, 16 Aug 2010 10:48:00 -0700 Subject: removing useless catch that causes troubles when FF throws exceptions within the loop but outside of the try/catch clause --- src/JSON.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/JSON.js b/src/JSON.js index 0d2fbca4..ba3d700e 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -81,19 +81,16 @@ function toJsonArray(buf, obj, pretty, stack){ keys.sort(); for ( var keyIndex = 0; keyIndex < keys.length; keyIndex++) { var key = keys[keyIndex]; - try { - var value = obj[key]; - if (typeof value != 'function') { - if (comma) { - buf.push(","); - if (pretty) buf.push(pretty); - } - buf.push(angular['String']['quote'](key)); - buf.push(":"); - toJsonArray(buf, value, childPretty, stack); - comma = true; + var value = obj[key]; + if (typeof value != 'function') { + if (comma) { + buf.push(","); + if (pretty) buf.push(pretty); } - } catch (e) { + buf.push(angular['String']['quote'](key)); + buf.push(":"); + toJsonArray(buf, value, childPretty, stack); + comma = true; } } buf.push("}"); -- cgit v1.2.3 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 From d8e86291c4a92395988f50d883200cdab12f726e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 16 Aug 2010 22:56:12 -0700 Subject: adding an expectation to widgetsSpec.js for ng:include --- test/widgetsSpec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index bdc8e59d..0e9b52ce 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -446,6 +446,8 @@ describe("widget", function(){ scope.$xhr.cache.data.myUrl = {value:'{{name}}'}; scope.$init(); + expect(element.text()).toEqual('igor'); + scope.url = undefined; scope.$eval(); -- cgit v1.2.3