return play() result

This commit is contained in:
Harvey committed 2021-12-01 10:39:44 +08:00
1 parent 3f21ce9223
commit 2c83ea4760
10 files changed
+52 -18

No files matched your search

+7 -2
View File
@@ -1,4 +1,4 @@
import { errorHandle, query, addClass } from './utils';
import { errorHandle, query, addClass, replaceElement } from './utils';
export default class Template {
constructor(art) {
@@ -12,11 +12,16 @@ export default class Template {
errorHandle(this.$container, `No container element found by ${art.option.container}`);
}
const type = this.$container.tagName.toLowerCase();
errorHandle(type === 'div', `Unsupported container element type, only support 'div' but got '${type}'`);
errorHandle(
art.constructor.instances.every((ins) => ins.template.$container !== this.$container),
'Cannot mount multiple instances on the same dom element',
);
this.$original = this.$container.cloneNode(true);
if (art.whitelist.state) {
this.desktop();
} else {
@@ -154,7 +159,7 @@ export default class Template {
destroy(removeHtml) {
if (removeHtml) {
this.$container.innerHTML = '';
replaceElement(this.$original, this.$container);
} else {
addClass(this.$player, 'art-destroy');
}