From 2821cacb377b9013d128743dc287760e8e10a1ae Mon Sep 17 00:00:00 2001 From: Michael Stramel Date: Tue, 21 Jul 2020 14:21:35 -0500 Subject: [PATCH 1/2] Switch lock array to set operations (#131) * Switch lock array to set operations * Remove falsy/null check from lockBodyScrolling function --- src/utilities/scroll.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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'); } } From 38ce5e4a31cd16faf0b12f3ea9398b2208381b10 Mon Sep 17 00:00:00 2001 From: Andrew Desmarais Date: Tue, 21 Jul 2020 15:21:54 -0400 Subject: [PATCH 2/2] Small typo in example (#130) --- docs/getting-started/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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.