From be2afb52c1fdeaa6063bc86b64d1901a06aa0d88 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 16 Nov 2020 15:19:28 +0800 Subject: [PATCH] MDL-67513 core: Only move modal to body if currently attached A previous change as part of this commitset was intended to move the modal to the document.body, but where the modal had been destroyed it was instead added back to the body. --- lib/amd/build/modal.min.js | Bin 9692 -> 9741 bytes lib/amd/build/modal.min.js.map | Bin 48164 -> 48392 bytes lib/amd/build/modal_backdrop.min.js | Bin 1321 -> 1371 bytes lib/amd/build/modal_backdrop.min.js.map | Bin 6849 -> 7079 bytes lib/amd/src/modal.js | 6 ++++-- lib/amd/src/modal_backdrop.js | 6 ++++-- 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/amd/build/modal.min.js b/lib/amd/build/modal.min.js index 5aef006412e39bbfd506d6ea281a2db6f7153ac5..91677e841b5bc4dc1888c43001297ce190459b7e 100644 GIT binary patch delta 68 zcmccP-RrZVT-Go%O(RhwB|o_|H#M(BFDXBzQd2K2GcQG>BqOs}FFmy+C_leMLsL^P XCp9me(*_+&RvmXoN6*PRmRi<+I-ZV>Sx!36j*i7nI^K?s-o?&3{*I15I5sE+XYBETRP{tOxCmX-~_TgfC8>AldCMZG@{>z*Q}asnlJZk3HTBXm^HMZQGBS(x(o;)< p^7BhHG$-q=lASEMNNe)q6|$4_XR=P7KZ|v8&SH_x`HQwn0ssU7Q;+}v delta 127 zcmeD9#kAxH(*_;O$%d9%llNIFu(&$9I!=CW>1J)}RO+PT>}cXt;$-fot@!l>Fq<+|;}hy`=n%)AsO9i^Pqy!4Wc%`+Jnv9ap7J34w!w&u{ZPSx>rbj)(nadvbp zcGB^7bo9=1((!k6^wDv3bS!ZKk;TsWPCCAhj)u-4RoN~;(%I5E%XzXbhcAz_7m%Cd z1QM*AJds0^v3T-o4p|FhCy=>5APu1=VBKLrqntf}0&XC+o{k_B{msD^J30bIoWp=b z#U{=|f%^Qsl6-}dj8uiB{FF+Cy!@0@h0HXC%o2snVuj+8%$yvB#FCQ47rq9ZyF` zAE1O|sKMkwPANfSClJTc5lA|R0f~~$HJpV4Qb~!)*$Vl2CHV>^8L0|M`6-nOdHE@+ UdNFyE)1=HM{}2_MyjSWK0L#lJSpWb4 diff --git a/lib/amd/src/modal.js b/lib/amd/src/modal.js index 3ca46d8a270..118d67902e1 100644 --- a/lib/amd/src/modal.js +++ b/lib/amd/src/modal.js @@ -735,8 +735,10 @@ define([ this.getRoot().removeClass('show').addClass('hide'); } - // Ensure the modal is moved onto the body node. - $(document.body).append(this.getRoot()); + // Ensure the modal is moved onto the body node if it is still attached to the DOM. + if ($(document.body).find(this.getRoot()).length) { + $(document.body).append(this.getRoot()); + } this.root.trigger(ModalEvents.hidden, this); }.bind(this)); diff --git a/lib/amd/src/modal_backdrop.js b/lib/amd/src/modal_backdrop.js index 9cc7448c3d2..1cbc1fd3960 100644 --- a/lib/amd/src/modal_backdrop.js +++ b/lib/amd/src/modal_backdrop.js @@ -142,8 +142,10 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'], this.getRoot().removeClass('show').addClass('hide'); } - // Ensure the modal is moved back onto the body node. - $(document.body).append(this.getRoot()); + // Ensure the modal is moved onto the body node if it is still attached to the DOM. + if ($(document.body).find(this.getRoot()).length) { + $(document.body).append(this.getRoot()); + } }; /** -- 2.43.0