ember-source
Version:
A JavaScript framework for creating ambitious web applications
47 lines (42 loc) • 1.74 kB
JavaScript
import '../../../meta/lib/meta.js';
import '../../../../../shared-chunks/mandatory-setter-DHZe7-kW.js';
import '../../../../debug/index.js';
import '../../../../../@glimmer/destroyable/index.js';
import '../../../../../@glimmer/validator/index.js';
import '../../../../../shared-chunks/debug-to-string-CFb7h0lY.js';
import '../../../../../@glimmer/global-context/index.js';
import '../../../../../shared-chunks/reference-C3TKDRnP.js';
import '../../../../../shared-chunks/capabilities-O_xc7Yqk.js';
import { g as get } from '../../../../../shared-chunks/observers-Bj9qLVau.js';
import '../../../environment/index.js';
import Mixin from '../../../../object/mixin.js';
import { assert } from '../../../../debug/lib/assert.js';
import inspect from '../../../../debug/lib/inspect.js';
/**
@module ember
*/
/**
@class ActionSupport
@namespace Ember
@private
*/
const ActionSupport = Mixin.create({
send(actionName, ...args) {
(!(!this.isDestroying && !this.isDestroyed) && assert(`Attempted to call .send() with the action '${actionName}' on the destroyed object '${this}'.`, !this.isDestroying && !this.isDestroyed));
let action = this.actions && this.actions[actionName];
if (action) {
let shouldBubble = action.apply(this, args) === true;
if (!shouldBubble) {
return;
}
}
let target = get(this, 'target');
if (target) {
(!(typeof target.send === 'function') && assert(`The \`target\` for ${this} (${target}) does not have a \`send\` method`, typeof target.send === 'function'));
target.send(...arguments);
} else {
(!(action) && assert(`${inspect(this)} had no action handler for: ${actionName}`, action));
}
}
});
export { ActionSupport as default };