Skip to content

Commit

Permalink
Fix #11994: TabView prevent detached DOM elements on TabClose (#11998)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jun 4, 2024
1 parent b183ca0 commit ff0c381
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1134,17 +1134,20 @@ if (!PrimeFaces.utils) {
jq.removeAttr(attributeName);
}
}

// Remove the element from the DOM and trigger onRemove events for widget.destroy.
// IMPORTANT: This must occur before jq.off() to ensure the on("remove") events remain registered.
if (removeElement) {
jq.remove();
}

// Remove event listeners
jq.off();

// Clear data
if (clearData) {
jq.removeData();
}
// Remove elements itself from memory
if (removeElement) {
jq.remove();
}
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,14 +697,14 @@ PrimeFaces.widget.TabView = PrimeFaces.widget.DeferredWidget.extend({
* @param {number} index 0-based index of the tab to close.
*/
remove: function(index) {
// remove old header and content
var header = this.headerContainer.eq(index),
panel = this.panelContainer.children().eq(index);

header.remove();
panel.remove();

// refresh "chached" selectors
// remove and cleanse all traces of the header and contents of the panel
PrimeFaces.utils.cleanseDomElement(header);
PrimeFaces.utils.cleanseDomElement(panel);

// refresh "cached" selectors
this.headerContainer = this.navContainer.children('li.ui-tabs-header');
this.panelContainer = this.jq.children('.ui-tabs-panels');

Expand Down

0 comments on commit ff0c381

Please sign in to comment.