From 2385128abb408800e8b516bba6dc75cf310a1e17 Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Mon, 22 Apr 2019 13:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20playlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/artplayer-plugin-playlist/src/index.js | 8 +++----- packages/artplayer/src/utils/index.js | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/artplayer-plugin-playlist/src/index.js b/packages/artplayer-plugin-playlist/src/index.js index 6a303f3c6..48bf86b0f 100644 --- a/packages/artplayer-plugin-playlist/src/index.js +++ b/packages/artplayer-plugin-playlist/src/index.js @@ -2,7 +2,7 @@ import './index.scss'; function artplayerPluginPlaylist(art) { const { - utils: { append, errorHandle, sleep }, + utils: { append, errorHandle, sleep, inverseClass }, } = art.constructor; const { player, @@ -70,11 +70,9 @@ function artplayerPluginPlaylist(art) { art.on('afterAttachUrl', () => { const index = playlist.findIndex(item => item.url === $video.src); - const $children = Array.from($playlistInner.children); - const $item = $children[index]; + const $item = Array.from($playlistInner.children)[index]; if (index !== -1 && $item) { - $children.forEach(item => item.classList.remove('active')); - $item.classList.add('active'); + inverseClass($item, 'active'); } }); diff --git a/packages/artplayer/src/utils/index.js b/packages/artplayer/src/utils/index.js index 1a4da70f9..b18310b15 100644 --- a/packages/artplayer/src/utils/index.js +++ b/packages/artplayer/src/utils/index.js @@ -99,9 +99,9 @@ export function append(parent, child) { if (child instanceof Element) { parent.appendChild(child); } else { - parent.insertAdjacentHTML('beforeend', child); + parent.insertAdjacentHTML('beforeend', String(child)); } - return parent.lastElementChild; + return parent.lastElementChild || parent.lastChild; } export function remove(child) {