- Affected version
- 2.3.3
While technically
This is noticeable for custom bb-code which has
Using
Use of setting
Note:
xf-init
is executed, any event listeners are lost probably resulting in the results of xf-init
being GC'ed. The problem is the use of innerHTML
to copy data into the DOM, as this creates new nodes and doesn't move/copy the existing nodes.This is noticeable for custom bb-code which has
xf-init
handlers, and xf-init
is executed on content which is then dropped.
Code:
function toPreview (previewHtml)
{
const previewBox = getPreviewBox()
const apply = function (previewHtml)
{
...
previewBox.innerHTML = previewHtml.querySelector('.bbWrapper').innerHTML
XF.display(previewBox)
}
if (typeof previewHtml == 'string')
{
...
}
else
{
...
XF.ajax(
'POST',
XF.canonicalizeUrl(href),
formData,
data =>
{
XF.setupHtmlInsert(data.html, html =>
{
XF.activate(html)
apply(html)
})
},
)
}
}
Using
previewBox.replaceChildren(...previewHtml.querySelector('.bbWrapper').children)
instead of previewBox.innerHTML =
will work.Use of setting
innerHTML
probably needs auditing to see if there are any other cases this impacts.Note:
XF.setupHtmlInsert()
calls XF.Activate()
on html
so if replaceChildren()
is called by itself then the XF.Activate()
will be ineffective as there is no contents.
Last edited: