23 lines
579 B
JavaScript
Raw Normal View History

2021-12-19 19:11:04 -08:00
import merge from 'lodash/merge';
2021-12-04 15:39:20 -08:00
class Options {
2021-12-14 17:06:09 +00:00
setOptions(...args) {
const options = merge({}, this.options, ...args);
this.options = options;
2021-12-14 17:06:09 +00:00
2021-10-04 17:05:34 -07:00
if (this.addEvent) {
const optionsKeys = Object.keys(options);
for (let index = 0; index < optionsKeys.length; index++) {
const option = optionsKeys[index];
if (typeof (options[option]) === 'function' && (/^on[A-Z]/).test(option)) {
this.addEvent(option, options[option]);
delete options[option];
2021-12-14 17:06:09 +00:00
}
2021-10-04 17:05:34 -07:00
}
2021-07-16 11:41:58 -03:00
}
2021-10-04 17:05:34 -07:00
return this;
2021-12-04 15:39:20 -08:00
}
}
2021-07-16 11:41:58 -03:00
export default Options;