-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathcore_view.js
88 lines (72 loc) · 2.06 KB
/
core_view.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import {
ActionHandler,
Evented,
FrameworkObject,
deprecateUnderscoreActions
} from 'ember-runtime';
import { initViewElement } from '../system/utils';
import { cloneStates, states } from './states';
/**
`Ember.CoreView` is an abstract class that exists to give view-like behavior
to both Ember's main view class `Ember.Component` and other classes that don't need
the full functionality of `Ember.Component`.
Unless you have specific needs for `CoreView`, you will use `Ember.Component`
in your applications.
@class CoreView
@namespace Ember
@extends Ember.Object
@deprecated Use `Ember.Component` instead.
@uses Ember.Evented
@uses Ember.ActionHandler
@private
*/
const CoreView = FrameworkObject.extend(Evented, ActionHandler, {
isView: true,
_states: cloneStates(states),
init() {
this._super(...arguments);
this._state = 'preRender';
this._currentState = this._states.preRender;
initViewElement(this);
if (!this.renderer) {
throw new Error(`Cannot instantiate a component without a renderer. Please ensure that you are creating ${this} with a proper container/registry.`);
}
},
/**
If the view is currently inserted into the DOM of a parent view, this
property will point to the parent of the view.
@property parentView
@type Ember.View
@default null
@private
*/
parentView: null,
instrumentDetails(hash) {
hash.object = this.toString();
hash.containerKey = this._debugContainerKey;
hash.view = this;
return hash;
},
/**
Override the default event firing from `Ember.Evented` to
also call methods with the given name.
@method trigger
@param name {String}
@private
*/
trigger(name, ...args) {
this._super(...arguments);
let method = this[name];
if (typeof method === 'function') {
return method.apply(this, args);
}
},
has(name) {
return typeof this[name] === 'function' || this._super(name);
}
});
deprecateUnderscoreActions(CoreView);
CoreView.reopenClass({
isViewFactory: true
});
export default CoreView;