From 163347915b9c7a334399c0efbf17341f44bcc65e Mon Sep 17 00:00:00 2001 From: Patrick Nelson Date: Wed, 6 Dec 2023 15:32:18 -0800 Subject: [PATCH] Issue #34: Formatting comment blocks and minor typo. --- index.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 0bf60b1..e2d73df 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,22 @@ import { createSvelteSlots, findSlotParent, unwrap } from './utils.js'; -// Tracks the mapping of case-insensitive attributes to case-sensitive component props on a per-tag basis. Setup as a -// global cache so we can avoid setting up a Proxy on every single component render but also to assist in mapping during -// hits to attributeChangedCallback(). +/** + * Tracks the mapping of case-insensitive attributes to case-sensitive component props on a per-tag basis. Setup as a + * global cache so we can avoid setting up a Proxy on every single component render but also to assist in mapping during + * hits to attributeChangedCallback(). + */ const propMapCache = new Map(); -// Mutation observer must be used to track changes to attributes on our custom elements, since we cannot know the -// component props ahead of time (required if we were to use observedAttributes instead). In this case, only one -// observer is necessary, since each call to .observe() can have a different "attributeFilter" specified. -// NOTE: We can .observe() many separate elements and not have to .disconnect() each one individually, since if the -// element being observed is removed from the DOM and released by the garbage collector, the MutationObserver will -// stop observing the removed element automatically. +/** + * Mutation observer must be used to track changes to attributes on our custom elements, since we cannot know the + * component props ahead of time (required if we were to use observedAttributes instead). In this case, only one + * observer is necessary, since each call to .observe() can have a different "attributeFilter" specified. + * NOTE: We can .observe() many separate elements and don't have to .disconnect() each one individually, since if the + * element being observed is removed from the DOM and released by the garbage collector, the MutationObserver will + * stop observing the removed element automatically. + */ const attributeObserver = new MutationObserver((mutations) => { // Go through each mutation and forward the updated attribute value to the corresponding Svelte prop. mutations.forEach(mutation => {