Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11994: TabView prevent detached DOM elements on TabClose #11998

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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