This is an automated email from the ASF dual-hosted git repository.
jialiang pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new 6c0019ca7f AMBARI-26107: Migrate away from DOMNodeInserted to
MutationObserver (ambari-admin) (#3819)
6c0019ca7f is described below
commit 6c0019ca7f1952126241a0dca89c293c12d312b6
Author: Prabhjyot <[email protected]>
AuthorDate: Mon Sep 2 20:54:59 2024 -0400
AMBARI-26107: Migrate away from DOMNodeInserted to MutationObserver
(ambari-admin) (#3819)
---
.../app/scripts/controllers/SideNavCtrl.js | 29 ++++++++++++++++------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
index 6bf356d796..2e3e820513 100644
---
a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
+++
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
@@ -35,14 +35,27 @@ angular.module('ambariAdminConsole')
}
function initNavigationBar () {
- $('body').on('DOMNodeInserted', '.navigation-bar', function() {
- $('.navigation-bar').navigationBar({
- fitHeight: true,
- collapseNavBarClass: 'fa-angle-double-left',
- expandNavBarClass: 'fa-angle-double-right'
- });
- //initTooltips();
- $('body').off('DOMNodeInserted', '.navigation-bar');
+ const observer = new MutationObserver(mutations => {
+ var targetNode
+ if (mutations.some((mutation) => mutation.type === 'childList' &&
(targetNode = $('.navigation-bar')).length)) {
+ observer.disconnect();
+ //initTooltips();
+ targetNode.navigationBar({
+ fitHeight: true,
+ collapseNavBarClass: 'fa-angle-double-left',
+ expandNavBarClass: 'fa-angle-double-right'
+ });
+ }
+ });
+
+ setTimeout(() => {
+ // remove observer if selected element is not found in 10secs.
+ observer.disconnect();
+ }, 10000)
+
+ observer.observe(document.body, {
+ childList: true,
+ subtree: true
});
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]