Skip to content

Commit 92e8651

Browse files
committed
Singletons are great memory savers
1 parent 41078a5 commit 92e8651

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

simpletoast.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
(() => {
55
if (window !== window.top) return;
6-
const version = buildVersion(1, 10, 0);
6+
const version = buildVersion(1, 10, 1);
77
if (window.SimpleToast) {
88
if (SimpleToast.version) {
99
if (SimpleToast.version >= version.number) return;
@@ -127,17 +127,16 @@
127127
}
128128

129129
function noop() {}
130-
const blankToast = {
130+
const blankToast = Object.freeze({
131131
setText: noop,
132132
exists: () => false,
133133
close: noop,
134-
};
134+
});
135135
function Toast({title, text, footer, className, css = {}, buttons, timeout, onClose} = {}) {
136136
if (typeof arguments[0] === 'string') {
137137
text = arguments[0];
138138
}
139-
const safeToast = Object.assign({}, blankToast);
140-
if (!text) return safeToast;
139+
if (!text) return blankToast;
141140
const id = count++;
142141
const el = document.createElement('div');
143142
if (className) {
@@ -235,7 +234,8 @@
235234
if (timeout) {
236235
startTimeout();
237236
}
238-
Object.keys(safeToast).forEach((key) => safeToast[key] = toast[key]);
237+
const safeToast = {};
238+
Object.keys(blankToast).forEach((key) => safeToast[key] = toast[key]);
239239
return safeToast;
240240
}
241241

0 commit comments

Comments
 (0)