Fix performance for very large number of options

This commit is contained in:
Talia 2025-01-09 14:21:00 +01:00
parent 3b85734049
commit 360e34e1fc
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E
2 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,8 @@
{
"name": "@darkwiiplayer/better-select",
"module": "BetterSelect.js",
"type": "module"
"browser": "src/BetterSelect.js",
"type": "module",
"license": "MIT",
"version": "1.0.2",
"url": "https://darkwiiplayer.github.io/BetterSelect/"
}

View file

@ -41,10 +41,13 @@ const css = template(string => {
})
const childObserver = new MutationObserver(mutations => {
for (const mutation of mutations) {
if (mutation.target instanceof BetterSelect)
mutation.target.mutationCallback()
const targets = new Set()
for (const {target} of mutations) {
if (target instanceof BetterSelect)
targets.add(target)
}
for (const target of targets)
target.mutationCallback()
})
export class BetterSelect extends HTMLElement {