carbon-components
Version:
Carbon Components is a component library for IBM Cloud
44 lines (39 loc) • 1.16 kB
JavaScript
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['exports'], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.getLaunchingDetails = mod.exports;
}
})(this, function (exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getLaunchingDetails;
function getLaunchingDetails(evt) {
if (!evt || typeof evt === 'function') {
return {
launchingElement: null,
launchingEvent: null
};
}
var launchingElement = evt.delegateTarget || evt.currentTarget || evt;
var launchingEvent = evt.currentTarget && evt;
if (launchingElement && !launchingElement.nodeType) {
throw new TypeError('DOM Node should be given for launching element.');
}
if (launchingEvent && !launchingEvent.type) {
throw new TypeError('DOM event should be given for launching event.');
}
return {
launchingElement: launchingElement,
launchingEvent: launchingEvent
};
}
});