*
* @param {string} identifier arbitrary string to group and identify callbacks
* @param {function} callback callback function
- * @return {boolean} false if callback is not a function
*/
add: function(identifier, callback) {
if (typeof callback !== 'function') {
throw new TypeError("Expected a valid callback as second argument for identifier '" + identifier + "'.");
- return false;
}
if (!this._dictionary.has(identifier)) {
}
this._dictionary.get(identifier).push(callback);
-
- return true;
},
/**
set: function(key, value) {
if (typeof key !== "string") {
throw new TypeError("Only strings can be used as keys, rejected '" + + "' (" + typeof key + ").");
- return;
}
if (_hasMap) this._dictionary.set(key, value);
var dropdown = DOMTraverse.parentByClass(button, 'dropdown');
if (dropdown === null) {
- throw "Invalid dropdown passed, button '" + DOMUtil.identify(button) + "' does not have a parent with .dropdown.";
- return;
+ throw new Error("Invalid dropdown passed, button '" + DOMUtil.identify(button) + "' does not have a parent with .dropdown.");
}
var menu = DOMTraverse.nextByClass(button, 'dropdownMenu');
if (menu === null) {
- throw "Invalid dropdown passed, button '" + DOMUtil.identify(button) + "' does not have a menu as next sibling.";
- return;
+ throw new Error("Invalid dropdown passed, button '" + DOMUtil.identify(button) + "' does not have a menu as next sibling.");
}
// move menu into global container
initFragment: function(dropdown, menu) {
var containerId = DOMUtil.identify(dropdown);
if (_dropdowns.has(dropdown)) {
- throw "Dropdown identified by '" + DOMUtil.identify(dropdown) + "' has already been registered.";
- return;
+ throw new Error("Dropdown identified by '" + DOMUtil.identify(dropdown) + "' has already been registered.");
}
_dropdowns.set(containerId, dropdown);
setAlignmentById: function(containerId) {
var dropdown = _dropdowns.get(containerId);
if (dropdown === null) {
- throw "Unknown dropdown identifier '" + containerId + "'.";
- return;
+ throw new Error("Unknown dropdown identifier '" + containerId + "'.");
}
var menu = _menus.get(containerId);
}
if (this._tabs.has(name)) {
- throw "Tab names must be unique, li[data-name='" + name + "'] (tab menu id: '" + this._containerId + "') exists more than once.";
- return false;
+ throw new Error("Tab names must be unique, li[data-name='" + name + "'] (tab menu id: '" + this._containerId + "') exists more than once.");
}
var container = this._containers.get(name);
if (container === null) {
- throw "Expected content element for li[data-name='" + name + "'] (tab menu id: '" + this._containerId + "').";
- return false;
+ throw new Error("Expected content element for li[data-name='" + name + "'] (tab menu id: '" + this._containerId + "').");
}
else if (container.parentNode !== this._container) {
- throw "Expected content element '" + name + "' (tab menu id: '" + this._containerId + "') to be a direct children.";
- return false;
+ throw new Error("Expected content element '" + name + "' (tab menu id: '" + this._containerId + "') to be a direct children.");
}
// check if tab holds exactly one children which is an anchor element
if (tab.childElementCount !== 1 || tab.children[0].nodeName !== 'A') {
- throw "Expected exactly one <a> as children for li[data-name='" + name + "'] (tab menu id: '" + this._containerId + "').";
- return false;
+ throw new Error("Expected exactly one <a> as children for li[data-name='" + name + "'] (tab menu id: '" + this._containerId + "').");
}
this._tabs.set(name, tab);
}
if (!this._tabs.size) {
- throw "Expected at least one tab (tab menu id: '" + this._containerId + "').";
- return false;
+ throw new Error("Expected at least one tab (tab menu id: '" + this._containerId + "').");
}
if (this._isLegacy) {
}
if (tab === null) {
- throw "Expected a valid tab name (tab menu id: '" + this._containerId + "').";
- return;
+ throw new Error("Expected a valid tab name (tab menu id: '" + this._containerId + "').");
}
}