solid-js 1.4.1 → 1.4.2
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/html/dist/html.cjs +34 -17
- package/html/dist/html.js +34 -17
- package/package.json +2 -2
- package/types/render/component.d.ts +8 -14
package/html/dist/html.cjs
CHANGED
|
@@ -179,15 +179,15 @@ const attrName = "[ " + spaces + "]+" + almostEverything;
|
|
|
179
179
|
const tagName = "<([A-Za-z$#]+[A-Za-z0-9:_-]*)((?:";
|
|
180
180
|
const attrPartials = "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
|
|
181
181
|
const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spaces + "]*/?>)", "g");
|
|
182
|
-
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(['\"(]
|
|
182
|
+
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
|
|
183
183
|
const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
|
|
184
184
|
const marker = "<!--#-->";
|
|
185
185
|
const reservedNameSpaces = new Set(["class", "on", "oncapture", "style", "use", "prop", "attr"]);
|
|
186
186
|
function attrReplacer($0, $1, $2, $3) {
|
|
187
187
|
return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
|
|
188
188
|
}
|
|
189
|
-
function replaceAttributes($0, $1, $2
|
|
190
|
-
return $1 + ($2
|
|
189
|
+
function replaceAttributes($0, $1, $2) {
|
|
190
|
+
return $1 + ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"');
|
|
191
191
|
}
|
|
192
192
|
function fullClosing($0, $1, $2) {
|
|
193
193
|
return VOID_ELEMENTS.test($1) ? $0 : "<" + $1 + $2 + "></" + $1 + ">";
|
|
@@ -236,9 +236,8 @@ function createHTML(r, {
|
|
|
236
236
|
cache.set(statics, templates);
|
|
237
237
|
return templates;
|
|
238
238
|
}
|
|
239
|
-
function parseKeyValue(tag, name, isSVG, isCE, options) {
|
|
240
|
-
let
|
|
241
|
-
expr = `!doNotWrap ? exprs[${count}]() : exprs[${count}]`,
|
|
239
|
+
function parseKeyValue(tag, name, value, isSVG, isCE, options) {
|
|
240
|
+
let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
|
|
242
241
|
parts,
|
|
243
242
|
namespace;
|
|
244
243
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
@@ -263,7 +262,7 @@ function createHTML(r, {
|
|
|
263
262
|
if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
|
-
function parseAttribute(tag, name, isSVG, isCE, options) {
|
|
265
|
+
function parseAttribute(tag, name, value, isSVG, isCE, options) {
|
|
267
266
|
if (name.slice(0, 2) === "on") {
|
|
268
267
|
if (!name.includes(":")) {
|
|
269
268
|
const lc = name.slice(2).toLowerCase();
|
|
@@ -281,9 +280,18 @@ function createHTML(r, {
|
|
|
281
280
|
exprs: []
|
|
282
281
|
}),
|
|
283
282
|
count = options.counter;
|
|
284
|
-
parseKeyValue(tag, name, isSVG, isCE, childOptions);
|
|
285
|
-
options.decl.push(`_fn${count} = doNotWrap => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
286
|
-
|
|
283
|
+
parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
|
|
284
|
+
options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
285
|
+
if (value === "###") {
|
|
286
|
+
options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
|
|
287
|
+
} else {
|
|
288
|
+
let check = "";
|
|
289
|
+
for (let i = count; i < childOptions.counter; i++) {
|
|
290
|
+
i !== count && (check += " || ");
|
|
291
|
+
check += `typeof exprs[${i}] === "function"`;
|
|
292
|
+
}
|
|
293
|
+
options.exprs.push(check + ` ? r.effect(_fn${count}) : _fn${count}()`);
|
|
294
|
+
}
|
|
287
295
|
options.counter = childOptions.counter;
|
|
288
296
|
options.wrap = false;
|
|
289
297
|
}
|
|
@@ -322,6 +330,7 @@ function createHTML(r, {
|
|
|
322
330
|
}
|
|
323
331
|
options.counter = childOptions.counter;
|
|
324
332
|
options.templateId = childOptions.templateId;
|
|
333
|
+
options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
|
|
325
334
|
}
|
|
326
335
|
function processComponentProps(propGroups) {
|
|
327
336
|
let result = [];
|
|
@@ -414,16 +423,19 @@ function createHTML(r, {
|
|
|
414
423
|
options.exprs.push(`return [${parts.join(", \n")}]`);
|
|
415
424
|
} else if (node.type === "tag") {
|
|
416
425
|
const tag = `_$el${uuid++}`;
|
|
417
|
-
|
|
426
|
+
const topDecl = !options.decl.length;
|
|
427
|
+
const templateId = options.templateId;
|
|
428
|
+
options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
418
429
|
const keys = Object.keys(node.attrs);
|
|
419
430
|
const isSVG = r.SVGElements.has(node.name);
|
|
420
431
|
const isCE = node.name.includes("-");
|
|
432
|
+
options.hasCustomElement = isCE;
|
|
421
433
|
for (let i = 0; i < keys.length; i++) {
|
|
422
434
|
const name = keys[i],
|
|
423
435
|
value = node.attrs[name];
|
|
424
|
-
if (value
|
|
436
|
+
if (value.includes("###")) {
|
|
425
437
|
delete node.attrs[name];
|
|
426
|
-
parseAttribute(tag, name, isSVG, isCE, options);
|
|
438
|
+
parseAttribute(tag, name, value, isSVG, isCE, options);
|
|
427
439
|
} else if (name === "###") {
|
|
428
440
|
delete node.attrs[name];
|
|
429
441
|
options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
|
|
@@ -432,17 +444,22 @@ function createHTML(r, {
|
|
|
432
444
|
options.path = tag;
|
|
433
445
|
options.first = false;
|
|
434
446
|
processChildren(node, options);
|
|
447
|
+
if (topDecl) {
|
|
448
|
+
options.decl[0] = options.hasCustomElement ? `const ${tag} = document.importNode(tmpls[${templateId}].content.firstChild, true)` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
|
|
449
|
+
}
|
|
435
450
|
} else if (node.type === "text") {
|
|
436
451
|
const tag = `_$el${uuid++}`;
|
|
437
452
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
438
453
|
options.path = tag;
|
|
439
454
|
options.first = false;
|
|
440
|
-
} else if (node.type === "comment"
|
|
455
|
+
} else if (node.type === "comment") {
|
|
441
456
|
const tag = `_$el${uuid++}`;
|
|
442
457
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
443
|
-
if (
|
|
444
|
-
|
|
445
|
-
|
|
458
|
+
if (node.content === "#") {
|
|
459
|
+
if (options.multi) {
|
|
460
|
+
options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
|
|
461
|
+
} else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
|
|
462
|
+
}
|
|
446
463
|
options.path = tag;
|
|
447
464
|
options.first = false;
|
|
448
465
|
}
|
package/html/dist/html.js
CHANGED
|
@@ -177,15 +177,15 @@ const attrName = "[ " + spaces + "]+" + almostEverything;
|
|
|
177
177
|
const tagName = "<([A-Za-z$#]+[A-Za-z0-9:_-]*)((?:";
|
|
178
178
|
const attrPartials = "(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|\\([^)]*?\\)|<[^>]*?>|" + almostEverything + "))?)";
|
|
179
179
|
const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spaces + "]*/?>)", "g");
|
|
180
|
-
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(['\"(]
|
|
180
|
+
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
|
|
181
181
|
const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
|
|
182
182
|
const marker = "<!--#-->";
|
|
183
183
|
const reservedNameSpaces = new Set(["class", "on", "oncapture", "style", "use", "prop", "attr"]);
|
|
184
184
|
function attrReplacer($0, $1, $2, $3) {
|
|
185
185
|
return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
|
|
186
186
|
}
|
|
187
|
-
function replaceAttributes($0, $1, $2
|
|
188
|
-
return $1 + ($2
|
|
187
|
+
function replaceAttributes($0, $1, $2) {
|
|
188
|
+
return $1 + ($2[0] === '"' || $2[0] === "'" ? $2.replace(/<!--#-->/g, "###") : '"###"');
|
|
189
189
|
}
|
|
190
190
|
function fullClosing($0, $1, $2) {
|
|
191
191
|
return VOID_ELEMENTS.test($1) ? $0 : "<" + $1 + $2 + "></" + $1 + ">";
|
|
@@ -234,9 +234,8 @@ function createHTML(r, {
|
|
|
234
234
|
cache.set(statics, templates);
|
|
235
235
|
return templates;
|
|
236
236
|
}
|
|
237
|
-
function parseKeyValue(tag, name, isSVG, isCE, options) {
|
|
238
|
-
let
|
|
239
|
-
expr = `!doNotWrap ? exprs[${count}]() : exprs[${count}]`,
|
|
237
|
+
function parseKeyValue(tag, name, value, isSVG, isCE, options) {
|
|
238
|
+
let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
|
|
240
239
|
parts,
|
|
241
240
|
namespace;
|
|
242
241
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
@@ -261,7 +260,7 @@ function createHTML(r, {
|
|
|
261
260
|
if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${r.Aliases[name] || name}",${expr})`);
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
|
-
function parseAttribute(tag, name, isSVG, isCE, options) {
|
|
263
|
+
function parseAttribute(tag, name, value, isSVG, isCE, options) {
|
|
265
264
|
if (name.slice(0, 2) === "on") {
|
|
266
265
|
if (!name.includes(":")) {
|
|
267
266
|
const lc = name.slice(2).toLowerCase();
|
|
@@ -279,9 +278,18 @@ function createHTML(r, {
|
|
|
279
278
|
exprs: []
|
|
280
279
|
}),
|
|
281
280
|
count = options.counter;
|
|
282
|
-
parseKeyValue(tag, name, isSVG, isCE, childOptions);
|
|
283
|
-
options.decl.push(`_fn${count} = doNotWrap => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
284
|
-
|
|
281
|
+
parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
|
|
282
|
+
options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
283
|
+
if (value === "###") {
|
|
284
|
+
options.exprs.push(`typeof exprs[${count}] === "function" ? r.effect(_fn${count}) : _fn${count}(true)`);
|
|
285
|
+
} else {
|
|
286
|
+
let check = "";
|
|
287
|
+
for (let i = count; i < childOptions.counter; i++) {
|
|
288
|
+
i !== count && (check += " || ");
|
|
289
|
+
check += `typeof exprs[${i}] === "function"`;
|
|
290
|
+
}
|
|
291
|
+
options.exprs.push(check + ` ? r.effect(_fn${count}) : _fn${count}()`);
|
|
292
|
+
}
|
|
285
293
|
options.counter = childOptions.counter;
|
|
286
294
|
options.wrap = false;
|
|
287
295
|
}
|
|
@@ -320,6 +328,7 @@ function createHTML(r, {
|
|
|
320
328
|
}
|
|
321
329
|
options.counter = childOptions.counter;
|
|
322
330
|
options.templateId = childOptions.templateId;
|
|
331
|
+
options.hasCustomElement = options.hasCustomElement || childOptions.hasCustomElement;
|
|
323
332
|
}
|
|
324
333
|
function processComponentProps(propGroups) {
|
|
325
334
|
let result = [];
|
|
@@ -412,16 +421,19 @@ function createHTML(r, {
|
|
|
412
421
|
options.exprs.push(`return [${parts.join(", \n")}]`);
|
|
413
422
|
} else if (node.type === "tag") {
|
|
414
423
|
const tag = `_$el${uuid++}`;
|
|
415
|
-
|
|
424
|
+
const topDecl = !options.decl.length;
|
|
425
|
+
const templateId = options.templateId;
|
|
426
|
+
options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
416
427
|
const keys = Object.keys(node.attrs);
|
|
417
428
|
const isSVG = r.SVGElements.has(node.name);
|
|
418
429
|
const isCE = node.name.includes("-");
|
|
430
|
+
options.hasCustomElement = isCE;
|
|
419
431
|
for (let i = 0; i < keys.length; i++) {
|
|
420
432
|
const name = keys[i],
|
|
421
433
|
value = node.attrs[name];
|
|
422
|
-
if (value
|
|
434
|
+
if (value.includes("###")) {
|
|
423
435
|
delete node.attrs[name];
|
|
424
|
-
parseAttribute(tag, name, isSVG, isCE, options);
|
|
436
|
+
parseAttribute(tag, name, value, isSVG, isCE, options);
|
|
425
437
|
} else if (name === "###") {
|
|
426
438
|
delete node.attrs[name];
|
|
427
439
|
options.exprs.push(`r.spread(${tag},exprs[${options.counter++}],${isSVG},${!!node.children.length})`);
|
|
@@ -430,17 +442,22 @@ function createHTML(r, {
|
|
|
430
442
|
options.path = tag;
|
|
431
443
|
options.first = false;
|
|
432
444
|
processChildren(node, options);
|
|
445
|
+
if (topDecl) {
|
|
446
|
+
options.decl[0] = options.hasCustomElement ? `const ${tag} = document.importNode(tmpls[${templateId}].content.firstChild, true)` : `const ${tag} = tmpls[${templateId}].content.firstChild.cloneNode(true)`;
|
|
447
|
+
}
|
|
433
448
|
} else if (node.type === "text") {
|
|
434
449
|
const tag = `_$el${uuid++}`;
|
|
435
450
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
436
451
|
options.path = tag;
|
|
437
452
|
options.first = false;
|
|
438
|
-
} else if (node.type === "comment"
|
|
453
|
+
} else if (node.type === "comment") {
|
|
439
454
|
const tag = `_$el${uuid++}`;
|
|
440
455
|
options.decl.push(`${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
456
|
+
if (node.content === "#") {
|
|
457
|
+
if (options.multi) {
|
|
458
|
+
options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}], ${tag})`);
|
|
459
|
+
} else options.exprs.push(`r.insert(${options.parent}, exprs[${options.counter++}])`);
|
|
460
|
+
}
|
|
444
461
|
options.path = tag;
|
|
445
462
|
options.first = false;
|
|
446
463
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.2",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -151,5 +151,5 @@
|
|
|
151
151
|
"compiler",
|
|
152
152
|
"performance"
|
|
153
153
|
],
|
|
154
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "f17df5c7042425aa8d363be261bd9a9e5345c188"
|
|
155
155
|
}
|
|
@@ -66,21 +66,15 @@ export declare type ComponentProps<T extends keyof JSX.IntrinsicElements | Compo
|
|
|
66
66
|
*/
|
|
67
67
|
export declare type Ref<T> = T | ((val: T) => void);
|
|
68
68
|
export declare function createComponent<T>(Comp: Component<T>, props: T): JSX.Element;
|
|
69
|
-
declare type
|
|
70
|
-
[K in keyof T]: T[K];
|
|
71
|
-
} : T;
|
|
72
|
-
declare type UnboxLazy<T> = T extends () => infer U ? U : T;
|
|
73
|
-
declare type RequiredKeys<T> = keyof {
|
|
74
|
-
[K in keyof T as T extends {
|
|
75
|
-
[_ in K]: unknown;
|
|
76
|
-
} ? K : never]: 0;
|
|
77
|
-
};
|
|
78
|
-
declare type Override<T, U> = {
|
|
79
|
-
[K in keyof Omit<T, RequiredKeys<U>>]: T[K] | Exclude<U[K & keyof U], undefined>;
|
|
69
|
+
declare type Override<T, U> = T extends any ? U extends any ? {
|
|
70
|
+
[K in keyof T]: K extends keyof U ? undefined extends U[K] ? Exclude<U[K], undefined> | T[K] : U[K] : T[K];
|
|
80
71
|
} & {
|
|
81
|
-
[K in keyof
|
|
82
|
-
};
|
|
83
|
-
export declare type MergeProps<T extends unknown[], Curr = {}> = T extends [
|
|
72
|
+
[K in keyof U]: K extends keyof T ? undefined extends U[K] ? Exclude<U[K], undefined> | T[K] : U[K] : U[K];
|
|
73
|
+
} : T & U : T & U;
|
|
74
|
+
export declare type MergeProps<T extends unknown[], Curr = {}> = T extends [
|
|
75
|
+
infer Next | (() => infer Next),
|
|
76
|
+
...infer Rest
|
|
77
|
+
] ? MergeProps<Rest, Override<Curr, Next>> : Curr;
|
|
84
78
|
export declare function mergeProps<T extends [unknown, ...unknown[]]>(...sources: T): MergeProps<T>;
|
|
85
79
|
export declare type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
|
|
86
80
|
...{
|