Skip to content

Commit d70a244

Browse files
committed
Issue #10: WIP: Fixing incomplete comment.
1 parent 8231c07 commit d70a244

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

index.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { createSvelteSlots, findSlotParent, unwrap } from './utils.js';
1212
*/
1313
// eslint-disable-next-line no-unused-vars
1414
function renderElements(timestamp) {
15+
// This is key: Fetches elements in document order so we can render top-down (for context).
1516
let renderQueue = document.querySelectorAll('[data-svelte-retag-render]');
1617
if (renderQueue.length === 0) {
1718
// TODO: Consider build of svelte-retag so we can drop console.logs() when publishing without having to comment out. See: https://github.com/vitejs/vite/discussions/7920
@@ -70,7 +71,8 @@ export default function(opts) {
7071
* it's difficult to know what the correct/final slot content will be until after the parser has rendered the DOM for
7172
* us.
7273
*
73-
* When performing shadow DOM rendering, it provides an un-styled container where we can attach
74+
* When performing shadow DOM rendering, it provides an un-styled container where we can attach the Svelte component
75+
* once it begins rendering.
7476
*/
7577
if (!window.customElements.get('svelte-retag')) {
7678
window.customElements.define('svelte-retag', class extends HTMLElement {
@@ -148,7 +150,7 @@ export default function(opts) {
148150

149151
// If compiled as IIFE/UMD and executed early, then the document is likely to be in the process of loading
150152
// and thus actively parsing tags, including not only this tag but also nested content (which may not yet be
151-
// available yet).
153+
// available).
152154
const isLoading = (document.readyState === 'loading');
153155

154156
// Setup the special <svelte-retag> wrapper if not already present (which can happen when
@@ -241,7 +243,8 @@ export default function(opts) {
241243
// construct/connectedCallback on this one).
242244
this._restoreLightSlots();
243245

244-
// Lastly, unwinding everything in reverse: Remove the special <svelte-tag> wrapper.
246+
// Lastly, unwinding everything in reverse: Remove the "light" DOM root (the special <svelte-tag> wrapper) which
247+
// is only added during connectedCallback(), unlike shadow DOM which is attached in construct.
245248
this.removeChild(this._root);
246249
}
247250
}
@@ -312,8 +315,10 @@ export default function(opts) {
312315
}
313316

314317
/**
315-
* To support context, this traverses the DOM to find potential parent svelte-retag elements which may contain
316-
* context necessary to render this component. See context functions at: https://svelte.dev/docs/svelte#setcontext
318+
* To support context, this traverses the DOM to find potential parent elements (also managed by svelte-retag) which
319+
* may contain context necessary to render this component.
320+
*
321+
* See context functions at: https://svelte.dev/docs/svelte#setcontext
317322
*
318323
* @returns {Map|null}
319324
*/
@@ -476,6 +481,8 @@ export default function(opts) {
476481
*
477482
* IMPORTANT: Since this custom element is the "root", these slots must be removed (which is done in THIS method).
478483
*
484+
* TODO: Problematic name. We are "getting" but we're also mangling/mutating state (which *is* necessary). "Get" may be confusing here; is there a better name?
485+
*
479486
* @returns {SlotList}
480487
*/
481488
_getLightSlots() {

0 commit comments

Comments
 (0)