mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 11:21:20 -08:00
Add more valid
This commit is contained in:
1 parent
5f45ad112f
commit
d919471838
7 files changed
+31
-11
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import { hasClass, addClass, removeClass, append, setStyles, tooltip, getStyle, inverseClass } from './dom';
|
||||
import validator from 'option-validator';
|
||||
import { ComponentOption } from '../scheme';
|
||||
import { has, def } from './property';
|
||||
import { errorHandle } from './error';
|
||||
|
||||
@@ -32,6 +34,9 @@ export default class Component {
|
||||
|
||||
add(getOption) {
|
||||
const option = typeof getOption === 'function' ? getOption(this.art) : getOption;
|
||||
option.html = option.html || '';
|
||||
validator(option, ComponentOption);
|
||||
|
||||
if (!this.$parent || !this.name || option.disable) return;
|
||||
const name = option.name || `${this.name}${this.id}`;
|
||||
errorHandle(!has(this, name), `Cannot add an existing name [${name}] to the [${this.name}]`);
|
||||
|
||||
Reference in new issue
Block a user