-
Notifications
You must be signed in to change notification settings - Fork 90
/
ember-internals.js
47 lines (41 loc) · 1.02 KB
/
ember-internals.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
This module is intended to encapsulate all the known places where
ember-animated depends on non-public Ember APIs.
See also tests/helpers/ember-testing-internals.js, which does the
same thing but for code that is only needed in the test environment.
*/
import { get } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import Ember from 'ember';
const { getViewBounds } = Ember.ViewUtils;
export function componentNodes(view) {
let bounds = getViewBounds(view);
return {
firstNode: bounds.firstNode,
lastNode: bounds.lastNode
};
}
export function keyForArray(keyPath) {
switch (keyPath) {
case '@index':
return index;
case '@identity':
case undefined:
case null:
return identity;
default:
return (item) => get(item, keyPath);
}
}
function index(item, index) {
return String(index);
}
function identity(item) {
switch (typeof item) {
case 'string':
case 'number':
return String(item);
default:
return guidFor(item);
}
}