Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
@module ember
@submodule ember-views
*/
import { assert } from 'ember-metal/debug';
import { Mixin } from 'ember-metal/mixin';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import setProperties from 'ember-metal/set_properties';
import { A as emberA } from 'ember-runtime/system/native_array';
import { getOwner, setOwner, OWNER } from 'container/owner';
const EMPTY_ARRAY = [];
export default Mixin.create({
/**
Array of child views. You should never edit this array directly.
@property childViews
@type Array
@default []
@private
*/
childViews: EMPTY_ARRAY,
init() {
this._super(...arguments);
// setup child views. be sure to clone the child views array first
// 2.0TODO: Remove Ember.A() here
this.childViews = emberA(this.childViews.slice());
/**
@module ember
@submodule ember-views
*/
import { Mixin } from 'ember-metal/mixin';
import require from 'require';
// Circular dep
var _renderView;
/**
@class TemplateRenderingSupport
@namespace Ember
@private
*/
var TemplateRenderingSupport = Mixin.create({
/**
Called on your view when it should push strings of HTML into a
`Ember.RenderBuffer`. Most users will want to override the `template`
or `templateName` properties instead of this method.
By default, `Ember.View` will look for a function in the `template`
property and invoke it with the value of `context`. The value of
`context` will be the view's controller unless you override it.
@method renderBlock
@param {Ember.RenderBuffer} buffer The render buffer
@private
*/
renderBlock(block, renderNode) {
if (_renderView === undefined) {
@submodule ember-views
*/
import { Mixin } from "ember-metal/mixin";
import AttrNode from "ember-views/attr_nodes/attr_node";
import { defineProperty } from "ember-metal/properties";
import { canSetNameOnInputs } from "ember-views/system/platform";
import { read } from "ember-metal/streams/utils";
import { set } from "ember-metal/property_set";
var EMPTY_ARRAY = [];
/**
@class AttributeBindingsSupport
@namespace Ember
*/
var AttributeBindingsSupport = Mixin.create({
concatenatedProperties: ['attributeBindings'],
/**
A list of properties of the view to apply as attributes. If the property is
a string value, the value of that string will be applied as the attribute.
```javascript
// Applies the type attribute to the element
// with the value "button", like <div type="button">
Ember.View.extend({
attributeBindings: ['type'],
type: 'button'
});
```
If the value of the property is a Boolean, the name of that property is</div>
import { Mixin } from 'ember-metal/mixin';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
export default Mixin.create({
linkChild(instance) {
instance.container = this.container;
if (get(instance, 'parentView') !== this) {
// linkChild should be idempotent
set(instance, 'parentView', this);
instance.trigger('parentViewDidChange');
}
instance.ownerView = this.ownerView;
},
unlinkChild(instance) {
set(instance, 'parentView', null);
instance.trigger('parentViewDidChange');
}
});
// because they are so common.
/**
The NativeArray mixin contains the properties needed to to make the native
Array support Ember.MutableArray and all of its dependent APIs. Unless you
have `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Array` set to
false, this will be applied automatically. Otherwise you can apply the mixin
at anytime by calling `Ember.NativeArray.activate`.
@class NativeArray
@namespace Ember
@uses Ember.MutableArray
@uses Ember.Observable
@uses Ember.Copyable
*/
var NativeArray = Mixin.create(MutableArray, Observable, Copyable, {
// because length is a built-in property we need to know to just get the
// original property.
get: function(key) {
if (key==='length') return this.length;
else if ('number' === typeof key) return this[key];
else return this._super(key);
},
objectAt: function(idx) {
return this[idx];
},
// primitive for array support.
replace: function(idx, amt, objects) {
import { Mixin } from "ember-metal/mixin";
import SimpleStream from "ember-metal/streams/simple";
var ViewStreamSupport = Mixin.create({
init() {
this._super.apply(this, arguments);
this._scopeStream = new SimpleStream(this).getKey('context');
},
getStream(path) {
var stream = this._scopeStream.get(path);
stream._label = path;
return stream;
}
});
export default ViewStreamSupport;
var states = cloneStates(viewStates);
merge(states._default, {
rerenderIfNeeded() { return this; }
});
merge(states.inDOM, {
rerenderIfNeeded(view) {
if (view.normalizedValue() !== view._lastNormalizedValue) {
view.rerender();
}
}
});
export default Mixin.create({
_states: states,
normalizedValue() {
var value = this.lazyValue.value();
var valueNormalizer = get(this, 'valueNormalizerFunc');
return valueNormalizer ? valueNormalizer(value) : value;
},
rerenderIfNeeded() {
this.currentState.rerenderIfNeeded(this);
}
});
@module ember
@submodule ember-views
*/
import { Mixin } from "ember-metal/mixin";
import View from "ember-views/views/view";
import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";
import { computed } from "ember-metal/computed";
/**
@class EmptyViewSupport
@namespace Ember
@private
*/
export default Mixin.create({
/**
This provides metadata about what kind of empty view class this
collection would like if it is being instantiated from another
system (like Handlebars)
@private
@property emptyViewClass
*/
emptyViewClass: View,
/**
An optional view to display if content is set to an empty array.
@property emptyView
@type Ember.View
@default null
var states = cloneStates(viewStates);
merge(states._default, {
rerenderIfNeeded: K
});
merge(states.inDOM, {
rerenderIfNeeded: function(view) {
if (view.normalizedValue() !== view._lastNormalizedValue) {
view.rerender();
}
}
});
var NormalizedRerenderIfNeededSupport = Mixin.create({
_states: states,
normalizedValue: function() {
var value = this.lazyValue.value();
var valueNormalizer = get(this, 'valueNormalizerFunc');
return valueNormalizer ? valueNormalizer(value) : value;
},
rerenderIfNeeded: function() {
this.currentState.rerenderIfNeeded(this);
},
});
/**
`Ember._BoundView` is a private view created by the Handlebars
`{{bind}}` helpers that is used to keep track of bound properties.
import { get } from "ember-metal/property_get";
import { Mixin } from "ember-metal/mixin";
import { computed } from "ember-metal/computed";
import RSVP from "ember-runtime/ext/rsvp";
/**
@module ember
@submodule ember-runtime
*/
/**
@class Deferred
@namespace Ember
*/
export default Mixin.create({
/**
Add handlers to be called when the Deferred object is resolved or rejected.
@method then
@param {Function} resolve a callback function to be called when done
@param {Function} reject a callback function to be called when failed
*/
then(resolve, reject, label) {
var deferred, promise, entity;
entity = this;
deferred = get(this, '_deferred');
promise = deferred.promise;
function fulfillmentHandler(fulfillment) {
if (fulfillment === promise) {