Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function(initializer) {
// If this is the first initializer being added to a subclass, we are going to reopen the class
// to make sure we have a new `initializers` object, which extends from the parent class' using
// prototypal inheritance. Without this, attempting to add initializers to the subclass would
// pollute the parent class as well as other subclasses.
if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) {
var attrs = {};
attrs[bucketName] = create(this[bucketName]);
this.reopenClass(attrs);
}
Ember.assert("The " + humanName + " '" + initializer.name + "' has already been registered", !this[bucketName][initializer.name]);
Ember.assert("An " + humanName + " cannot be registered without an initialize function", canInvoke(initializer, 'initialize'));
Ember.assert("An " + humanName + " cannot be registered without a name property", initializer.name !== undefined);
this[bucketName][initializer.name] = initializer;
};
}
return function(initializer) {
// If this is the first initializer being added to a subclass, we are going to reopen the class
// to make sure we have a new `initializers` object, which extends from the parent class' using
// prototypal inheritance. Without this, attempting to add initializers to the subclass would
// pollute the parent class as well as other subclasses.
if (this.superclass[bucketName] !== undefined && this.superclass[bucketName] === this[bucketName]) {
var attrs = {};
attrs[bucketName] = create(this[bucketName]);
this.reopenClass(attrs);
}
Ember.assert("The " + humanName + " '" + initializer.name + "' has already been registered", !this[bucketName][initializer.name]);
Ember.assert("An " + humanName + " cannot be registered without an initialize function", canInvoke(initializer, 'initialize'));
Ember.assert("An " + humanName + " cannot be registered without a name property", initializer.name !== undefined);
this[bucketName][initializer.name] = initializer;
};
}
// currying are in the assertion messages.
let { args, defRef, env, symbolTable, lastDefinition, lastName } = this;
let nameOrDef = defRef.value();
let definition = null;
if (nameOrDef && nameOrDef === lastName) {
return lastDefinition;
}
this.lastName = nameOrDef;
if (typeof nameOrDef === 'string') {
assert('You cannot use the input helper as a contextual helper. Please extend Ember.TextField or Ember.Checkbox to use it as a contextual component.', nameOrDef !== 'input');
assert('You cannot use the textarea helper as a contextual helper. Please extend Ember.TextArea to use it as a contextual component.', nameOrDef !== 'textarea');
definition = env.getComponentDefinition([nameOrDef], symbolTable);
assert(`The component helper cannot be used without a valid component name. You used "${nameOrDef}" via (component "${nameOrDef}")`, definition);
} else if (isComponentDefinition(nameOrDef)) {
definition = nameOrDef;
} else {
assert(
`You cannot create a component from ${nameOrDef} using the {{component}} helper`,
nameOrDef
);
return null;
}
let newDef = createCurriedDefinition(definition, args);
this.lastDefinition = newDef;
return newDef;
}
function processComponentInitializationAssertions(component, props) {
assert(`classNameBindings must not have spaces in them: ${component.toString()}`, (() => {
let { classNameBindings } = component;
for (let i = 0; i < classNameBindings.length; i++) {
let binding = classNameBindings[i];
if (binding.split(' ').length > 1) {
return false;
}
}
return true;
})());
assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), (() => {
let { classNameBindings, tagName } = component;
return tagName !== '' || !classNameBindings || classNameBindings.length === 0;
})());
assert('You cannot use `elementId` on a tag-less component: ' + component.toString(), (() => {
deferReadiness() {
Ember.assert("You must call deferReadiness on an instance of Ember.Application", this instanceof Application);
Ember.assert("You cannot defer readiness since the `ready()` hook has already been called.", this._readinessDeferrals > 0);
this._readinessDeferrals++;
},
templateForName(name, type) {
if (!name) { return; }
assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1);
let owner = getOwner(this);
if (!owner) {
throw new EmberError('Container was not found when looking up a views template. ' +
'This is most likely due to manually instantiating an Ember.View. ' +
'See: http://git.io/EKPpnA');
}
return owner.lookup('template:' + name);
}
});
function queryParams({ positional, named }) {
assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0);
return QueryParams.create({
values: assign({}, named.value())
});
}
function aliasIdToElementId(args, props) {
if (args.named.has('id')) {
assert(`You cannot invoke a component with both 'id' and 'elementId' at the same time.`, !args.named.has('elementId'));
props.elementId = props.id;
}
}
Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) {
if (this.resolver && this.resolver.expandLocalLookup) {
assert('fullName must be a proper full name', this.validateFullName(fullName));
assert('options.source must be provided to expandLocalLookup', options && options.source);
assert('options.source must be a proper full name', this.validateFullName(options.source));
let normalizedFullName = this.normalize(fullName);
let normalizedSource = this.normalize(options.source);
return expandLocalLookup(this, normalizedFullName, normalizedSource);
} else if (this.fallback) {
return this.fallback.expandLocalLookup(fullName, options);
} else {
return null;
}
};
get() {
let templateName = get(this, 'templateName');
let template = this.templateForName(templateName, 'template');
assert('You specified the templateName ' + templateName + ' for ' + this + ', but it did not exist.', !templateName || !!template);
return template || get(this, 'defaultTemplate');
},
set(key, value) {