← Commit history

fix: an inline data child was lost to the parse race, so src won and the table rendered empty

Ray ·2489e3d45f · ·parent 76a5e22
A custom element upgrades when its OPENING tag is parsed, before its children exist. An inline <script type="application/json"> child is therefore invisible at that moment, readData falls through to src=, and the fetch is committed to before the data sitting right there ever appears. That is exactly what broke adom/repo-ownership. The wiki's ::tag widget frame emits BOTH the inlined data (which is how a PRIVATE page's data reaches an opaque-origin frame at all, per adom/wiki#166) and the author's src=. src won the race, the fetch 404'd from the opaque origin, and the table rendered empty - the precise failure the inlining exists to prevent. Isolated on the real frame, one attribute apart: as the wiki serves it 0 rows same file, src= removed 293 rows with this fix, unmodified 293 rows, 8 headers, 2 warn cells, 1 accent, 293 owner dots load() now waits for DOMContentLoaded when the parser is still running AND it is about to choose src BECAUSE no inline child is visible yet. Data already present still renders immediately; only the case that would otherwise lose is delayed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 file changed +20
widgets/adom-table.js+20
@@ -410,6 +410,26 @@       };        var load = function () {+        // A custom element upgrades when its OPENING tag is parsed, so its children do not+        // exist yet. An inline <script type="application/json"> child is therefore invisible+        // at this moment, readData falls through to src=, and the fetch is committed to before+        // the data that was sitting right there ever appears.+        //+        // That is not theoretical: the wiki's ::tag widget frame emits BOTH an inlined data+        // child (so a PRIVATE page's data reaches an opaque-origin frame at all) and the+        // author's src=. The src won the race, the fetch 404'd from the opaque origin, and the+        // table rendered empty - the exact failure the inlining exists to prevent.+        // Measured on the real frame: with src= 0 rows, with the attribute removed 293.+        //+        // So when the parser is still running and we are about to choose src BECAUSE no inline+        // child is visible yet, wait for parsing to finish and look again. Nothing else is+        // delayed: data already present still renders immediately.+        if (document.readyState === 'loading'+            && el.getAttribute('src')+            && !el.querySelector('script[type="application/json"]')) {+          document.addEventListener('DOMContentLoaded', load, { once: true });+          return;+        }         var d = readData(el);         if (d.error) return state(d.error, true);         if (d.from === 'src') {