2021-12-19 19:11:04 -08:00
|
|
|
import merge from 'lodash/merge';
|
2021-12-17 17:13:47 +00:00
|
|
|
|
2021-12-04 15:39:20 -08:00
|
|
|
class Options {
|
2021-12-14 17:06:09 +00:00
|
|
|
setOptions(...args) {
|
2021-12-17 17:13:47 +00:00
|
|
|
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) {
|
2021-12-20 20:54:31 +00:00
|
|
|
const optionsKeys = Object.keys(options);
|
|
|
|
for (let index = 0; index < optionsKeys.length; index++) {
|
|
|
|
const option = optionsKeys[index];
|
2022-07-12 18:58:11 -07:00
|
|
|
if (typeof options[option] === 'function' && /^on[A-Z]/.test(option)) {
|
2021-12-20 20:54:31 +00:00
|
|
|
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;
|