验证重名组件

This commit is contained in:
zhw2590582 committed 2019-05-17 21:52:52 +08:00
1 parent 73e58d356e
commit 899307696b
4 files changed
+19 -9

No files matched your search

+2 -1
View File
@@ -1,9 +1,10 @@
import { append, setStyles, setStyle, remove } from './index';
import { append, setStyles, setStyle, remove, errorHandle, hasOwnProperty } from './index';
export default function component(art, parent, target, getOption, callback, title) {
const option = typeof getOption === 'function' ? getOption(art) : getOption;
if (!option.disable) {
const name = option.name || `${title}${parent.id}`;
errorHandle(!hasOwnProperty(parent, name), `Cannot create a component that already has the same name: ${title} -> ${name}`);
const $element = document.createElement('div');
$element.classList.value = `art-${title} art-${title}-${name}`;