Skip to content

Commit 9e67da4

Browse files
committed
Corrected an issue where properties inherited from __proto__ show up in ng:repeat.
Closses angular#112
1 parent 5fc2b96 commit 9e67da4

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
- Change API angular.compile(..) to angular.compile(element)([scope], [cloneAttachFn])
1717
- remove ng:watch directives since it encourages logic in the UI.
1818

19+
### Bug Fixes
20+
- Corrected an issue where properties inherited from __proto__ show up in ng:repeat.
21+
1922
<a name="0.9.11"><a/>
2023
# <angular/> 0.9.11 snow-maker (2011-02-08) #
2124

src/widgets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ angularWidget('@ng:repeat', function(expression, element){
927927
}
928928

929929
for (key in collection) {
930-
if (!is_array || collection.hasOwnProperty(key)) {
930+
if (collection.hasOwnProperty(key)) {
931931
if (index < childCount) {
932932
// reuse existing child
933933
childScope = children[index];

test/widgetsSpec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,18 @@ describe("widget", function(){
727727
expect(element.text()).toEqual('misko:swe;shyam:set;');
728728
});
729729

730+
it('should not ng:repeat over parent properties', function(){
731+
var Class = function(){};
732+
Class.prototype.abc = function(){};
733+
Class.prototype.value = 'abc';
734+
735+
var scope = compile('<ul><li ng:repeat="(key, value) in items" ng:bind="key + \':\' + value + \';\' "></li></ul>');
736+
scope.items = new Class();
737+
scope.items.name = 'value';
738+
scope.$eval();
739+
expect(element.text()).toEqual('name:value;');
740+
});
741+
730742
it('should error on wrong parsing of ng:repeat', function(){
731743
var scope = compile('<ul><li ng:repeat="i dont parse"></li></ul>');
732744

0 commit comments

Comments
 (0)