压缩字符

This commit is contained in:
Harvey committed 2019-11-27 15:46:55 +08:00
1 parent 2df60a78ff
commit 5f40463713
40 files changed
+385 -481

No files matched your search

+2 -22
View File
@@ -1,6 +1,4 @@
import { hasClass, addClass, removeClass, append, setStyle, setStyles, tooltip } from './dom';
import { has, def } from './property';
import { errorHandle } from './error';
import { hasClass, addClass, removeClass, append, setStyles, tooltip } from './dom';
export default class Component {
constructor(art) {
@@ -15,7 +13,6 @@ export default class Component {
}
set show(value) {
errorHandle(value === false || value === true, 'The show attribute expects a boolean value');
const { $player } = this.art.template;
const className = `art-${this.name}-show`;
if (value) {
@@ -32,10 +29,9 @@ export default class Component {
add(getOption, callback) {
const option = typeof getOption === 'function' ? getOption(this.art) : getOption;
if (!this.$parent || option.disable) return {};
if (!this.$parent || option.disable) return;
this.id += 1;
const name = option.name || `${this.name}${this.id}`;
errorHandle(!has(this, name), `Cannot add a component that already has the same name: ${name}`);
const $ref = document.createElement('div');
$ref.classList.value = `art-${this.name} art-${this.name}-${name}`;
@@ -75,22 +71,6 @@ export default class Component {
callback($ref, this, this.art);
}
def(this, name, {
value: {
get $ref() {
return $ref;
},
set show(value) {
if (value) {
setStyle($ref, 'display', 'block');
} else {
setStyle($ref, 'display', 'none');
}
},
},
});
this.art.emit(`${this.name}:add`, option);
return this[name];
}
}