Skip to content

Commit 3c7521c

Browse files
authored
Switch to a WeakMap to avoid memory leak
1 parent 96fe21e commit 3c7521c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/vhtml.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let DOMAttributeNames = {
99
htmlFor: 'for'
1010
};
1111

12-
let sanitized = {};
12+
let sanitized = new WeakMap();
1313

1414
/** Hyperscript reviver that constructs a sanitized HTML string. */
1515
export default function h(name, attrs) {
@@ -47,14 +47,14 @@ export default function h(name, attrs) {
4747
for (let i=child.length; i--; ) stack.push(child[i]);
4848
}
4949
else {
50-
s += sanitized[child]===true ? child : esc(child);
50+
s += sanitized.has(child) ? child : esc(child);
5151
}
5252
}
5353
}
5454

5555
s += name ? `</${name}>` : '';
5656
}
5757

58-
sanitized[s] = true;
58+
sanitized.set(s, true);
5959
return s;
6060
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy