mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
return play() result
This commit is contained in:
1 parent
3f21ce9223
commit
2c83ea4760
10 files changed
+52
-18
No files matched your search
@@ -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');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user