mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
ng:repeat ignores prototype keys
This commit is contained in:
parent
00bb790392
commit
228b54aa2e
3 changed files with 9 additions and 4 deletions
2
java
Executable file
2
java
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java $@
|
||||
|
|
@ -162,8 +162,9 @@ angularWidget("@ng:repeat", function(expression, element){
|
|||
var children = [], currentScope = this;
|
||||
this.$onEval(function(){
|
||||
var index = 0, childCount = children.length, childScope, lastElement = reference,
|
||||
collection = this.$tryEval(rhs, reference);
|
||||
collection = this.$tryEval(rhs, reference), is_array = isArray(collection);
|
||||
for ( var key in collection) {
|
||||
if (is_array && !collection.hasOwnProperty(key)) break;
|
||||
if (index < childCount) {
|
||||
// reuse existing child
|
||||
childScope = children[index];
|
||||
|
|
|
|||
|
|
@ -93,15 +93,17 @@ describe("directives", function(){
|
|||
it('should ng:repeat over array', function(){
|
||||
var scope = compile('<ul><li ng:repeat="item in items" ng:init="suffix = \';\'" ng:bind="item + suffix"></li></ul>');
|
||||
|
||||
scope.$set('items', ['misko', 'shyam']);
|
||||
Array.prototype.extraProperty = "should be ignored";
|
||||
scope.items = ['misko', 'shyam'];
|
||||
scope.$eval();
|
||||
expect(element.text()).toEqual('misko;shyam;');
|
||||
delete Array.prototype.extraProperty;
|
||||
|
||||
scope.$set('items', ['adam', 'kai', 'brad']);
|
||||
scope.items = ['adam', 'kai', 'brad'];
|
||||
scope.$eval();
|
||||
expect(element.text()).toEqual('adam;kai;brad;');
|
||||
|
||||
scope.$set('items', ['brad']);
|
||||
scope.items = ['brad'];
|
||||
scope.$eval();
|
||||
expect(element.text()).toEqual('brad;');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue