thunderous 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -166,15 +166,19 @@ var html = (strings, ...values) => {
166
166
  const textList = child.data.split(signalBindingRegex);
167
167
  textList.forEach((text, i) => {
168
168
  const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
169
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : null;
170
- const newText = signal !== null ? signal() : text;
171
- const newNode = new Text(newText);
169
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
170
+ const newValue = signal !== void 0 ? signal() : text;
171
+ const newNode = (() => {
172
+ if (typeof newValue === "string") return new Text(newValue);
173
+ if (newValue instanceof DocumentFragment) return newValue;
174
+ return new Text("");
175
+ })();
172
176
  if (i === 0) {
173
177
  child.replaceWith(newNode);
174
178
  } else {
175
179
  element.insertBefore(newNode, child.nextSibling);
176
180
  }
177
- if (signal !== null) {
181
+ if (signal !== void 0 && newNode instanceof Text) {
178
182
  createEffect(() => {
179
183
  newNode.data = signal();
180
184
  });
@@ -190,8 +194,8 @@ var html = (strings, ...values) => {
190
194
  let hasNull = false;
191
195
  for (const text of textList) {
192
196
  const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
193
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : null;
194
- const value = signal !== null ? signal() : text;
197
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
198
+ const value = signal !== void 0 ? signal() : text;
195
199
  if (value === null) hasNull = true;
196
200
  newText += value;
197
201
  }
package/dist/index.js CHANGED
@@ -124,15 +124,19 @@ var html = (strings, ...values) => {
124
124
  const textList = child.data.split(signalBindingRegex);
125
125
  textList.forEach((text, i) => {
126
126
  const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
127
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : null;
128
- const newText = signal !== null ? signal() : text;
129
- const newNode = new Text(newText);
127
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
128
+ const newValue = signal !== void 0 ? signal() : text;
129
+ const newNode = (() => {
130
+ if (typeof newValue === "string") return new Text(newValue);
131
+ if (newValue instanceof DocumentFragment) return newValue;
132
+ return new Text("");
133
+ })();
130
134
  if (i === 0) {
131
135
  child.replaceWith(newNode);
132
136
  } else {
133
137
  element.insertBefore(newNode, child.nextSibling);
134
138
  }
135
- if (signal !== null) {
139
+ if (signal !== void 0 && newNode instanceof Text) {
136
140
  createEffect(() => {
137
141
  newNode.data = signal();
138
142
  });
@@ -148,8 +152,8 @@ var html = (strings, ...values) => {
148
152
  let hasNull = false;
149
153
  for (const text of textList) {
150
154
  const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
151
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : null;
152
- const value = signal !== null ? signal() : text;
155
+ const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
156
+ const value = signal !== void 0 ? signal() : text;
153
157
  if (value === null) hasNull = true;
154
158
  newText += value;
155
159
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thunderous",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",