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

Commit 2a3a449

Browse files
committed
merge
2 parents 894ffad + d8e8629 commit 2a3a449

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

src/JSON.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,16 @@ function toJsonArray(buf, obj, pretty, stack){
7777
keys.sort();
7878
for ( var keyIndex = 0; keyIndex < keys.length; keyIndex++) {
7979
var key = keys[keyIndex];
80-
try {
81-
var value = obj[key];
82-
if (typeof value != $function) {
83-
if (comma) {
84-
buf.push(",");
85-
if (pretty) buf.push(pretty);
86-
}
87-
buf.push(angular['String']['quote'](key));
88-
buf.push(":");
89-
toJsonArray(buf, value, childPretty, stack);
90-
comma = true;
80+
var value = obj[key];
81+
if (typeof value != $function) {
82+
if (comma) {
83+
buf.push(",");
84+
if (pretty) buf.push(pretty);
9185
}
92-
} catch (e) {
86+
buf.push(angular['String']['quote'](key));
87+
buf.push(":");
88+
toJsonArray(buf, value, childPretty, stack);
89+
comma = true;
9390
}
9491
}
9592
buf.push("}");

src/widgets.js

+2
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

+17
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,23 @@ describe("widget", function(){
454454
scope.$init();
455455
expect(element.text()).toEqual('misko');
456456
});
457+
458+
it('should remove previously included text if a falsy value is bound to src', function() {
459+
var element = jqLite('<ng:include src="url" scope="childScope"></ng:include>');
460+
var scope = angular.compile(element);
461+
scope.childScope = createScope();
462+
scope.childScope.name = 'igor';
463+
scope.url = 'myUrl';
464+
scope.$xhr.cache.data.myUrl = {value:'{{name}}'};
465+
scope.$init();
466+
467+
expect(element.text()).toEqual('igor');
468+
469+
scope.url = undefined;
470+
scope.$eval();
471+
472+
expect(element.text()).toEqual('');
473+
});
457474
});
458475
});
459476

0 commit comments

Comments
 (0)