diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index 31bc901b..2026552f 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -48,7 +48,7 @@ To import individual Shoelace components, use this syntax. import { SlButton, SlDropdown } from '@shoelace-style/shoelace/dist/custom-elements'; customElements.define('sl-button', SlButton); -customElements.define('sl-dropdown', SlButton); +customElements.define('sl-dropdown', SlDropdown); ``` For convenience, the bundle also exports a `defineCustomElements()` method. When this method is called, it will automatically define all Shoelace components in the bundle. @@ -59,4 +59,4 @@ import { defineCustomElements } from '@shoelace-style/shoelace/dist/custom-eleme defineCustomElements(); ``` -While convenient, importing all components like this will make your bundle larger. For best results, only import the components you're actually going to use. \ No newline at end of file +While convenient, importing all components like this will make your bundle larger. For best results, only import the components you're actually going to use. diff --git a/src/utilities/scroll.ts b/src/utilities/scroll.ts index 8bf7f00c..3a558d90 100644 --- a/src/utilities/scroll.ts +++ b/src/utilities/scroll.ts @@ -1,25 +1,23 @@ import { getOffset } from './offset'; -let locks = []; +const locks = new Set(); // // Prevents body scrolling. Keeps track of which elements requested a lock so multiple levels of locking are possible // without premature unlocking. // export function lockBodyScrolling(lockingEl: HTMLElement) { - if (lockingEl && !locks.includes(lockingEl)) { - locks.push(lockingEl); - document.body.classList.add('sl-scroll-lock'); - } + locks.add(lockingEl); + document.body.classList.add('sl-scroll-lock'); } // // Unlocks body scrolling. Scrolling will only be unlocked once all elements that requested a lock call this method. // export function unlockBodyScrolling(lockingEl: HTMLElement) { - locks = locks.filter(el => el !== lockingEl); + locks.delete(lockingEl); - if (locks.length === 0) { + if (locks.size === 0) { document.body.classList.remove('sl-scroll-lock'); } }