Skip to content
Merged
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
12 changes: 9 additions & 3 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,16 @@ export class GridStack {

// check for content changing
if (w.content) {
let sub = el.querySelector('.grid-stack-item-content');
if (sub && sub.innerHTML !== w.content) {
sub.innerHTML = w.content;
let toRemove = el.querySelectorAll('.grid-stack-item-content > :not(.grid-stack-nested, style)');
Copy link
Member Author

@adumesny adumesny Jul 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this doesn't work if you have content='foo' instead of content='<div>foo</div>' as in your jsfiddle example

const subGrid = el.querySelector('.grid-stack-item-content > .grid-stack-nested')
const itemContent = el.querySelector('.grid-stack-item-content');
if (toRemove) {
toRemove.forEach(child => itemContent.removeChild(child));
}
const tempEl = document.createElement("div");
tempEl.innerHTML = w.content;
tempEl.childNodes.forEach(childNode => itemContent.insertBefore(childNode, subGrid));

delete w.content;
}

Expand Down