Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mergeDOMViewBindings(view, props, hash) {
Ember.assert(
"Setting 'attributeBindings' via template helpers is not allowed. " +
"Please subclass Ember.View and set it there instead.",
!hash.attributeBindings
);
if (hash.id) {
props.id = props.elementId = read(hash.id);
}
if (hash.tag) {
props.tagName = read(hash.tag);
}
var classBindings = [];
if (hash['class']) {
if (typeof hash['class'] === 'string') {
props.classNames = hash['class'].split(' ');
} else if (hash['class']._label) {
// label exists for via property paths in the template
// but not for streams with nested sub-expressions
classBindings.push(hash['class']._label);
} else {
propertiesFromHTMLOptions: function(hash, options, env) {
var view = env.data.view;
var classes = read(hash['class']);
var extensions = {
helperName: options.helperName || ''
};
if (hash.id) {
extensions.elementId = read(hash.id);
}
if (hash.tag) {
extensions.tagName = hash.tag;
}
if (classes) {
classes = classes.split(' ');
extensions.classNames = classes;
}
if (hash.classBinding) {
extensions.classNameBindings = hash.classBinding.split(' ');
}
if (hash.classNameBindings) {
export function inputHelper(params, hash, options, env) {
Ember.assert('You can only pass attributes to the `input` helper, not arguments', params.length === 0);
var onEvent = hash.on;
var inputType;
inputType = read(hash.type);
if (inputType === 'checkbox') {
delete hash.type;
Ember.assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" +
" you must use `checked=someBooleanValue` instead.", !hash.hasOwnProperty('value'));
env.helpers.view.helperFunction.call(this, [Checkbox], hash, options, env);
} else {
delete hash.on;
hash.onEvent = onEvent || 'enter';
env.helpers.view.helperFunction.call(this, [TextField], hash, options, env);
}
}
LegacyBindAttrNode.prototype.render = function render(buffer) {
this.isDirty = false;
if (this.isDestroying) {
return;
}
var value = read(this.attrValue);
if (value === undefined) {
value = null;
}
if ((this.attrName === 'value' || this.attrName === 'src') && value === null) {
value = '';
}
Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]),
value === null || value === undefined || typeOf(value) === 'number' || typeOf(value) === 'string' || typeOf(value) === 'boolean' || !!(value && value.toHTML));
if (this.lastValue !== null || value !== null) {
this._deprecateEscapedStyle(value);
this._morph.setContent(value);
this.lastValue = value;
_createNewComponent: function() {
var componentClass = read(this.componentClassStream);
if (!componentClass) {
throw new EmberError('HTMLBars error: Could not find component named "' + read(this._boundComponentOptions.componentNameStream) + '".');
}
var hash = this._boundComponentOptions;
var hashForComponent = {};
var prop;
for (prop in hash) {
if (prop === '_boundComponentOptions' || prop === 'componentClassStream') { continue; }
hashForComponent[prop] = hash[prop];
}
var props = {};
mergeViewBindings(this, props, hashForComponent);
return this.createChildView(componentClass, props);
}
});
AttrNode.prototype.render = function render(buffer) {
this.isDirty = false;
var value = read(this.attrValue);
this._morph.setContent(value);
this.lastValue = value;
};
if (newTestResult !== oldTestResult) {
switch (oldTestResult) {
case true: unsubscribe(this.consequent, this.notify, this); break;
case false: unsubscribe(this.alternate, this.notify, this); break;
case undefined: subscribe(this.test, this.notify, this);
}
switch (newTestResult) {
case true: subscribe(this.consequent, this.notify, this); break;
case false: subscribe(this.alternate, this.notify, this);
}
this.oldTestResult = newTestResult;
}
return newTestResult ? read(this.consequent) : read(this.alternate);
};
function getResolvedQueryParams(linkView, targetRouteName) {
var queryParamsObject = linkView.queryParamsObject;
var resolvedQueryParams = {};
if (!queryParamsObject) { return resolvedQueryParams; }
var values = queryParamsObject.values;
for (var key in values) {
if (!values.hasOwnProperty(key)) { continue; }
resolvedQueryParams[key] = read(values[key]);
}
return resolvedQueryParams;
}
AttrNode.prototype.renderIfDirty = function renderIfDirty(){
if (this.isDirty) {
var value = read(this.attrValue);
if (value !== this.lastValue) {
this._renderer.renderTree(this, this._parentView);
} else {
this.isDirty = false;
}
}
};