-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: calling ms() twice should only create 1 instance, also fix destroy
- calling the same multipleSelect('select') shouldn't duplicate DOM Elements neither instances - also fix instance destroy & add unmount with destroy on all demo examples and validate that no detached DOM elements remained
- Loading branch information
1 parent
cb1e4e3
commit c397f30
Showing
58 changed files
with
721 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms: MultipleSelectInstance[] = []; | ||
|
||
mount() { | ||
multipleSelect('.multiple-select'); | ||
this.ms = multipleSelect('.multiple-select') as MultipleSelectInstance[]; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms.forEach((m) => m.destroy()); | ||
this.ms = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms: MultipleSelectInstance[] = []; | ||
|
||
mount() { | ||
multipleSelect('.multiple-select'); | ||
this.ms = multipleSelect('.multiple-select') as MultipleSelectInstance[]; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms.forEach((m) => m.destroy()); | ||
this.ms = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms: MultipleSelectInstance[] = []; | ||
|
||
mount() { | ||
multipleSelect('select', { | ||
this.ms = multipleSelect('select', { | ||
multiple: true, | ||
multipleWidth: 60, | ||
}); | ||
}) as MultipleSelectInstance[]; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms.forEach((m) => m.destroy()); | ||
this.ms = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms1?: MultipleSelectInstance; | ||
|
||
mount() { | ||
multipleSelect('select'); | ||
this.ms1 = multipleSelect('select') as MultipleSelectInstance; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms1?.destroy(); | ||
this.ms1 = undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms: MultipleSelectInstance[] = []; | ||
|
||
mount() { | ||
multipleSelect('select'); | ||
this.ms = multipleSelect('select') as MultipleSelectInstance[]; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms.forEach((m) => m.destroy()); | ||
this.ms = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
import { MultipleSelect, multipleSelect } from 'multiple-select-vanilla'; | ||
import { MultipleSelectInstance, multipleSelect } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms1!: MultipleSelect; | ||
ms2!: MultipleSelect; | ||
ms1?: MultipleSelectInstance; | ||
ms2?: MultipleSelectInstance; | ||
|
||
mount() { | ||
const elm = document.querySelector('#locale') as HTMLSelectElement; | ||
elm.addEventListener('change', ((event: KeyboardEvent & { target: HTMLSelectElement }) => { | ||
this.updateLocale(event.target.value); | ||
}) as EventListener); | ||
|
||
this.ms1 = multipleSelect(elm) as MultipleSelect; | ||
this.ms2 = multipleSelect('#select') as MultipleSelect; | ||
this.ms1 = multipleSelect(elm) as MultipleSelectInstance; | ||
this.ms2 = multipleSelect('#select') as MultipleSelectInstance; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms1?.destroy(); | ||
this.ms2?.destroy(); | ||
this.ms1 = undefined; | ||
this.ms2 = undefined; | ||
} | ||
|
||
updateLocale(locale: string) { | ||
this.ms2.destroy(); | ||
this.ms2.refreshOptions({ locale }); | ||
this.ms2?.destroy(); | ||
this.ms2?.refreshOptions({ locale }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
ms1?: MultipleSelectInstance; | ||
|
||
mount() { | ||
var data = []; | ||
for (var i = 0; i < 10000; i++) { | ||
data.push({ value: i, text: i }); | ||
// data.push(i); | ||
data.push(i); | ||
} | ||
|
||
multipleSelect('#select', { | ||
this.ms1 = multipleSelect('#select', { | ||
filter: true, | ||
// single: true, | ||
// singleRadio: true, | ||
// filterAcceptOnEnter: true, | ||
data, | ||
}); | ||
}) as MultipleSelectInstance; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms1?.destroy(); | ||
this.ms1 = undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import { multipleSelect } from 'multiple-select-vanilla'; | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
// import 'multiple-select-vanilla/dist/styles/css/themes/bootstrap.css'; | ||
import './example11.scss'; | ||
|
||
export default class Example { | ||
ms: MultipleSelectInstance[] = []; | ||
|
||
mount() { | ||
multipleSelect('select'); | ||
this.ms = multipleSelect('select') as MultipleSelectInstance[]; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms.forEach((m) => m.destroy()); | ||
this.ms = []; | ||
} | ||
} |
Oops, something went wrong.