sygnal 2.5.0 → 2.6.0

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/jsx.cjs.js CHANGED
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _extend = require('extend');
6
- var snabbdom = require('snabbdom');
7
6
 
8
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
8
 
@@ -23,7 +22,7 @@ const object = (v) => typeof v === 'object' && v !== null;
23
22
 
24
23
  const fun = (v) => typeof v === 'function';
25
24
 
26
- const vnode = (v) => object(v) && 'sel' in v && 'data' in v && 'children' in v && 'text' in v;
25
+ const vnode$1 = (v) => object(v) && 'sel' in v && 'data' in v && 'children' in v && 'text' in v;
27
26
 
28
27
  const svgPropsMap = { svg: 1, circle: 1, ellipse: 1, line: 1, polygon: 1,
29
28
  polyline: 1, rect: 1, g: 1, path: 1, text: 1 };
@@ -135,8 +134,8 @@ const sanitizeData = (data, modules) => considerSvg(rewriteModules(deepifyKeys(d
135
134
  const sanitizeText = (children) => children.length > 1 || !text(children[0]) ? undefined : children[0].toString();
136
135
 
137
136
  const sanitizeChildren = (children) => reduceDeep(children, (acc, child) => {
138
- const vnode$1 = vnode(child) ? child : createTextElement(child);
139
- acc.push(vnode$1);
137
+ const vnode = vnode$1(child) ? child : createTextElement(child);
138
+ acc.push(vnode);
140
139
  return acc
141
140
  }
142
141
  , []);
@@ -180,8 +179,53 @@ const createElementWithModules = (modules) => {
180
179
 
181
180
  const createElement = createElementWithModules(defaultModules);
182
181
 
183
- Object.defineProperty(exports, 'Fragment', {
184
- enumerable: true,
185
- get: function () { return snabbdom.Fragment; }
186
- });
182
+ function vnode(sel, data, children, text, elm) {
183
+ const key = data === undefined ? undefined : data.key;
184
+ return { sel, data, children, text, elm, key };
185
+ }
186
+
187
+ vnode("", {}, [], undefined, undefined);
188
+
189
+ // Bindig `requestAnimationFrame` like this fixes a bug in IE/Edge. See #360 and #409.
190
+ (typeof window !== "undefined" &&
191
+ window.requestAnimationFrame.bind(window)) ||
192
+ setTimeout;
193
+
194
+ /* eslint-disable @typescript-eslint/no-namespace, import/export */
195
+ function Fragment(data, ...children) {
196
+ const flatChildren = flattenAndFilter(children, []);
197
+ if (flatChildren.length === 1 &&
198
+ !flatChildren[0].sel &&
199
+ flatChildren[0].text) {
200
+ // only child is a simple text node, pass as text for a simpler vtree
201
+ return vnode(undefined, undefined, undefined, flatChildren[0].text, undefined);
202
+ }
203
+ else {
204
+ return vnode(undefined, data !== null && data !== void 0 ? data : {}, flatChildren, undefined, undefined);
205
+ }
206
+ }
207
+ function flattenAndFilter(children, flattened) {
208
+ for (const child of children) {
209
+ // filter out falsey children, except 0 since zero can be a valid value e.g inside a chart
210
+ if (child !== undefined &&
211
+ child !== null &&
212
+ child !== false &&
213
+ child !== "") {
214
+ if (Array.isArray(child)) {
215
+ flattenAndFilter(child, flattened);
216
+ }
217
+ else if (typeof child === "string" ||
218
+ typeof child === "number" ||
219
+ typeof child === "boolean") {
220
+ flattened.push(vnode(undefined, undefined, undefined, String(child), undefined));
221
+ }
222
+ else {
223
+ flattened.push(child);
224
+ }
225
+ }
226
+ }
227
+ return flattened;
228
+ }
229
+
230
+ exports.Fragment = Fragment;
187
231
  exports.jsx = createElement;
package/dist/jsx.esm.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import _extend from 'extend';
2
- export { Fragment } from 'snabbdom';
3
2
 
4
3
  const undefinedv = (v) => v === undefined;
5
4
 
@@ -15,7 +14,7 @@ const object = (v) => typeof v === 'object' && v !== null;
15
14
 
16
15
  const fun = (v) => typeof v === 'function';
17
16
 
18
- const vnode = (v) => object(v) && 'sel' in v && 'data' in v && 'children' in v && 'text' in v;
17
+ const vnode$1 = (v) => object(v) && 'sel' in v && 'data' in v && 'children' in v && 'text' in v;
19
18
 
20
19
  const svgPropsMap = { svg: 1, circle: 1, ellipse: 1, line: 1, polygon: 1,
21
20
  polyline: 1, rect: 1, g: 1, path: 1, text: 1 };
@@ -127,8 +126,8 @@ const sanitizeData = (data, modules) => considerSvg(rewriteModules(deepifyKeys(d
127
126
  const sanitizeText = (children) => children.length > 1 || !text(children[0]) ? undefined : children[0].toString();
128
127
 
129
128
  const sanitizeChildren = (children) => reduceDeep(children, (acc, child) => {
130
- const vnode$1 = vnode(child) ? child : createTextElement(child);
131
- acc.push(vnode$1);
129
+ const vnode = vnode$1(child) ? child : createTextElement(child);
130
+ acc.push(vnode);
132
131
  return acc
133
132
  }
134
133
  , []);
@@ -172,4 +171,52 @@ const createElementWithModules = (modules) => {
172
171
 
173
172
  const createElement = createElementWithModules(defaultModules);
174
173
 
175
- export { createElement as jsx };
174
+ function vnode(sel, data, children, text, elm) {
175
+ const key = data === undefined ? undefined : data.key;
176
+ return { sel, data, children, text, elm, key };
177
+ }
178
+
179
+ vnode("", {}, [], undefined, undefined);
180
+
181
+ // Bindig `requestAnimationFrame` like this fixes a bug in IE/Edge. See #360 and #409.
182
+ (typeof window !== "undefined" &&
183
+ window.requestAnimationFrame.bind(window)) ||
184
+ setTimeout;
185
+
186
+ /* eslint-disable @typescript-eslint/no-namespace, import/export */
187
+ function Fragment(data, ...children) {
188
+ const flatChildren = flattenAndFilter(children, []);
189
+ if (flatChildren.length === 1 &&
190
+ !flatChildren[0].sel &&
191
+ flatChildren[0].text) {
192
+ // only child is a simple text node, pass as text for a simpler vtree
193
+ return vnode(undefined, undefined, undefined, flatChildren[0].text, undefined);
194
+ }
195
+ else {
196
+ return vnode(undefined, data !== null && data !== void 0 ? data : {}, flatChildren, undefined, undefined);
197
+ }
198
+ }
199
+ function flattenAndFilter(children, flattened) {
200
+ for (const child of children) {
201
+ // filter out falsey children, except 0 since zero can be a valid value e.g inside a chart
202
+ if (child !== undefined &&
203
+ child !== null &&
204
+ child !== false &&
205
+ child !== "") {
206
+ if (Array.isArray(child)) {
207
+ flattenAndFilter(child, flattened);
208
+ }
209
+ else if (typeof child === "string" ||
210
+ typeof child === "number" ||
211
+ typeof child === "boolean") {
212
+ flattened.push(vnode(undefined, undefined, undefined, String(child), undefined));
213
+ }
214
+ else {
215
+ flattened.push(child);
216
+ }
217
+ }
218
+ }
219
+ return flattened;
220
+ }
221
+
222
+ export { Fragment, createElement as jsx };