-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12942 from btecu/objectAt
[BUGFIX beta] Do not rely prototype extensions (objectAt)
- Loading branch information
Showing
17 changed files
with
88 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { computed } from 'ember-metal/computed'; | |
import { testBoth } from 'ember-metal/tests/props_helper'; | ||
import { ArrayTests } from 'ember-runtime/tests/suites/array'; | ||
import EmberObject from 'ember-runtime/system/object'; | ||
import EmberArray from 'ember-runtime/mixins/array'; | ||
import EmberArray, { objectAt } from 'ember-runtime/mixins/array'; | ||
import { A as emberA } from 'ember-runtime/system/native_array'; | ||
|
||
/* | ||
|
@@ -385,11 +385,16 @@ QUnit.test('modifying the array should also indicate the isDone prop itself has | |
addObserver(each, 'isDone', function() { count++; }); | ||
|
||
count = 0; | ||
var item = ary.objectAt(2); | ||
var item = objectAt(ary, 2); | ||
set(item, 'isDone', !get(item, 'isDone')); | ||
equal(count, 1, '@each.isDone should have notified'); | ||
}); | ||
|
||
QUnit.test('`objectAt` returns correct object', function() { | ||
let arr = ['first', 'second', 'third', 'fourth']; | ||
equal(objectAt(arr, 2), 'third'); | ||
equal(objectAt(arr, 4), undefined); | ||
}); | ||
|
||
testBoth('should be clear caches for computed properties that have dependent keys on arrays that are changed after object initialization', function(get, set) { | ||
var obj = EmberObject.extend({ | ||
|
@@ -399,14 +404,14 @@ testBoth('should be clear caches for computed properties that have dependent key | |
}, | ||
|
||
common: computed('[email protected]', function() { | ||
return get(get(this, 'resources').objectAt(0), 'common'); | ||
return get(objectAt(get(this, 'resources'), 0), 'common'); | ||
}) | ||
}).create(); | ||
|
||
get(obj, 'resources').pushObject(EmberObject.create({ common: 'HI!' })); | ||
equal('HI!', get(obj, 'common')); | ||
|
||
set(get(obj, 'resources').objectAt(0), 'common', 'BYE!'); | ||
set(objectAt(get(obj, 'resources'), 0), 'common', 'BYE!'); | ||
equal('BYE!', get(obj, 'common')); | ||
}); | ||
|
||
|
@@ -428,7 +433,7 @@ testBoth('observers that contain @each in the path should fire only once the fir | |
// Observer fires second time when new object is added | ||
get(obj, 'resources').pushObject(EmberObject.create({ common: 'HI!' })); | ||
// Observer fires third time when property on an object is changed | ||
set(get(obj, 'resources').objectAt(0), 'common', 'BYE!'); | ||
set(objectAt(get(obj, 'resources'), 0), 'common', 'BYE!'); | ||
|
||
equal(count, 2, 'observers should only be called once'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.