Fixed XF.DescLoader loses data if only one element is returned

DragonByte Tech

Well-known member
Affected version
2.3.0 RC4
Problem: If XF.DescLoader returns only one parent HTML element, f.ex.
HTML:
                <dl class="pairs pairs--columns pairs--fixedSmall pairs--customField" data-field="min_platform_version">
                    <dt>Minimum Platform Version</dt>
                    <dd>2.2.0</dd>
                </dl>
The wrapper <dl> will be lost due to containerEl.innerHTML = html.innerHTML in onLoad, which causes the resulting display to look different. This line assumes multiple HTML elements were returned, such that they are wrapped in <div class="js-createdContainer">.

Fix:
Diff:
Index: js/xf/form.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/xf/form.js b/js/xf/form.js
--- a/js/xf/form.js
+++ b/js/xf/form.js
@@ -1274,7 +1274,14 @@
                         speed: XF.config.speed.fast,
                         complete ()
                         {
-                            containerEl.innerHTML = html.innerHTML
+                            if (html.classList.contains('js-createdContainer'))
+                            {
+                                containerEl.innerHTML = html.innerHTML
+                            }
+                            else
+                            {
+                                containerEl.innerHTML = html.outerHTML
+                            }
                             XF.Animate.fadeDown(containerEl)
                         },
                     })

---
I don't know if this problem also affects other areas.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.0).

Change log:
Fix XF.DescLoader when a single parent is returned
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom