From ea0481afdbade7a4aa59971f623747161062120e Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Fri, 6 Oct 2017 16:31:01 +0000 Subject: [PATCH] Media: Fix MEJS error when removing a media player. This fixes a bug introduced by the upgrade to MediaElement.js, where code calling `wp.media.mixin.removePlayer()` would result in a JS error. Props rafa8626, afercia. Fixes #41787. git-svn-id: https://develop.svn.wordpress.org/trunk@41781 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-audiovideo.js | 12 +++++++----- src/wp-includes/js/media/audiovideo.manifest.js | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/js/media-audiovideo.js b/src/wp-includes/js/media-audiovideo.js index cb2abd57ae..e939d49454 100644 --- a/src/wp-includes/js/media-audiovideo.js +++ b/src/wp-includes/js/media-audiovideo.js @@ -129,18 +129,20 @@ wp.media.mixin = { } if ( ! t.isDynamic ) { - t.$node.remove(); + t.node.remove(); } - if ( 'native' !== t.media.pluginType ) { - t.$media.remove(); + if ( 'html5' !== t.media.rendererName ) { + t.media.remove(); } delete window.mejs.players[t.id]; t.container.remove(); - t.globalUnbind(); - delete t.node.player; + t.globalUnbind('resize', t.globalResizeCallback); + t.globalUnbind('keydown', t.globalKeydownCallback); + t.globalUnbind('click', t.globalClickCallback); + delete t.media.player; }, /** diff --git a/src/wp-includes/js/media/audiovideo.manifest.js b/src/wp-includes/js/media/audiovideo.manifest.js index 1b4bef7831..7981aa75ac 100644 --- a/src/wp-includes/js/media/audiovideo.manifest.js +++ b/src/wp-includes/js/media/audiovideo.manifest.js @@ -60,18 +60,20 @@ wp.media.mixin = { } if ( ! t.isDynamic ) { - t.$node.remove(); + t.node.remove(); } - if ( 'native' !== t.media.pluginType ) { - t.$media.remove(); + if ( 'html5' !== t.media.rendererName ) { + t.media.remove(); } delete window.mejs.players[t.id]; t.container.remove(); - t.globalUnbind(); - delete t.node.player; + t.globalUnbind('resize', t.globalResizeCallback); + t.globalUnbind('keydown', t.globalKeydownCallback); + t.globalUnbind('click', t.globalClickCallback); + delete t.media.player; }, /**