aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/JSON.js21
-rw-r--r--src/widgets.js2
-rw-r--r--test/widgetsSpec.js17
3 files changed, 28 insertions, 12 deletions
diff --git a/src/JSON.js b/src/JSON.js
index 6fb43f0f..9fb325ef 100644
--- a/src/JSON.js
+++ b/src/JSON.js
@@ -77,19 +77,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("}");
diff --git a/src/widgets.js b/src/widgets.js
index 336813aa..b70c4dcb 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 9134500a..3861ef4f 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -454,6 +454,23 @@ 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('<ng:include src="url" scope="childScope"></ng:include>');
+ var scope = angular.compile(element);
+ scope.childScope = createScope();
+ scope.childScope.name = 'igor';
+ scope.url = 'myUrl';
+ scope.$xhr.cache.data.myUrl = {value:'{{name}}'};
+ scope.$init();
+
+ expect(element.text()).toEqual('igor');
+
+ scope.url = undefined;
+ scope.$eval();
+
+ expect(element.text()).toEqual('');
+ });
});
});