@solidjs/html 2.0.0-experimental.1 → 2.0.0-experimental.11
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/LICENSE +1 -1
- package/dist/html.cjs +9 -9
- package/dist/html.js +9 -9
- package/package.json +3 -3
- package/types/index.d.ts +0 -3
- package/types/lit.d.ts +0 -57
package/LICENSE
CHANGED
package/dist/html.cjs
CHANGED
|
@@ -64,7 +64,7 @@ function parseTag(tag) {
|
|
|
64
64
|
}
|
|
65
65
|
function pushTextNode(list, html, start) {
|
|
66
66
|
const end = html.indexOf('<', start);
|
|
67
|
-
const content = html.slice(start, end === -1 ?
|
|
67
|
+
const content = html.slice(start, end === -1 ? undefined : end);
|
|
68
68
|
if (!/^\s*$/.test(content)) {
|
|
69
69
|
list.push({
|
|
70
70
|
type: 'text',
|
|
@@ -83,7 +83,7 @@ function pushCommentNode(list, tag) {
|
|
|
83
83
|
}
|
|
84
84
|
function parse(html) {
|
|
85
85
|
const result = [];
|
|
86
|
-
let current =
|
|
86
|
+
let current = undefined;
|
|
87
87
|
let level = -1;
|
|
88
88
|
const arr = [];
|
|
89
89
|
const byTag = {};
|
|
@@ -92,7 +92,7 @@ function parse(html) {
|
|
|
92
92
|
const isComment = tag.slice(0, 4) === '<!--';
|
|
93
93
|
const start = index + tag.length;
|
|
94
94
|
const nextChar = html.charAt(start);
|
|
95
|
-
let parent =
|
|
95
|
+
let parent = undefined;
|
|
96
96
|
if (isOpen && !isComment) {
|
|
97
97
|
level++;
|
|
98
98
|
current = parseTag(tag);
|
|
@@ -168,7 +168,7 @@ const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spac
|
|
|
168
168
|
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
|
|
169
169
|
const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
|
|
170
170
|
const marker = "<!--#-->";
|
|
171
|
-
const reservedNameSpaces = new Set(["class", "on", "style", "use", "prop"
|
|
171
|
+
const reservedNameSpaces = new Set(["class", "on", "style", "use", "prop"]);
|
|
172
172
|
function attrReplacer($0, $1, $2, $3) {
|
|
173
173
|
return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
|
|
174
174
|
}
|
|
@@ -253,8 +253,8 @@ function createHTML(r, {
|
|
|
253
253
|
options.exprs.push(`r.style(${tag},${expr},_$p)`);
|
|
254
254
|
} else if (name === "class") {
|
|
255
255
|
options.exprs.push(`r.className(${tag},${expr},${isSVG},_$p)`);
|
|
256
|
-
} else if (
|
|
257
|
-
options.exprs.push(`${tag}.${
|
|
256
|
+
} else if (isChildProp || !isSVG && isProp || namespace === "prop") {
|
|
257
|
+
options.exprs.push(`${tag}.${name} = ${expr}`);
|
|
258
258
|
} else {
|
|
259
259
|
const ns = isSVG && name.indexOf(":") > -1 && r.SVGNamespace[name.split(":")[0]];
|
|
260
260
|
if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${name}",${expr})`);
|
|
@@ -364,9 +364,9 @@ function createHTML(r, {
|
|
|
364
364
|
propGroups.push(`exprs[${options.counter++}]`);
|
|
365
365
|
propGroups.push(props = []);
|
|
366
366
|
} else if (value === "###") {
|
|
367
|
-
props.push(
|
|
368
|
-
} else props.push(
|
|
369
|
-
} else if (type ===
|
|
367
|
+
props.push(`"${name}": exprs[${options.counter++}]`);
|
|
368
|
+
} else props.push(`"${name}": "${value}"`);
|
|
369
|
+
} else if (type === 'directive') {
|
|
370
370
|
const tag = `_$el${uuid++}`;
|
|
371
371
|
const topDecl = !options.decl.length;
|
|
372
372
|
options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
package/dist/html.js
CHANGED
|
@@ -62,7 +62,7 @@ function parseTag(tag) {
|
|
|
62
62
|
}
|
|
63
63
|
function pushTextNode(list, html, start) {
|
|
64
64
|
const end = html.indexOf('<', start);
|
|
65
|
-
const content = html.slice(start, end === -1 ?
|
|
65
|
+
const content = html.slice(start, end === -1 ? undefined : end);
|
|
66
66
|
if (!/^\s*$/.test(content)) {
|
|
67
67
|
list.push({
|
|
68
68
|
type: 'text',
|
|
@@ -81,7 +81,7 @@ function pushCommentNode(list, tag) {
|
|
|
81
81
|
}
|
|
82
82
|
function parse(html) {
|
|
83
83
|
const result = [];
|
|
84
|
-
let current =
|
|
84
|
+
let current = undefined;
|
|
85
85
|
let level = -1;
|
|
86
86
|
const arr = [];
|
|
87
87
|
const byTag = {};
|
|
@@ -90,7 +90,7 @@ function parse(html) {
|
|
|
90
90
|
const isComment = tag.slice(0, 4) === '<!--';
|
|
91
91
|
const start = index + tag.length;
|
|
92
92
|
const nextChar = html.charAt(start);
|
|
93
|
-
let parent =
|
|
93
|
+
let parent = undefined;
|
|
94
94
|
if (isOpen && !isComment) {
|
|
95
95
|
level++;
|
|
96
96
|
current = parseTag(tag);
|
|
@@ -166,7 +166,7 @@ const attrSeeker = new RegExp(tagName + attrName + attrPartials + "+)([ " + spac
|
|
|
166
166
|
const findAttributes = new RegExp("(" + attrName + "\\s*=\\s*)(<!--#-->|['\"(]([\\w\\s]*<!--#-->[\\w\\s]*)*['\")])", "gi");
|
|
167
167
|
const selfClosing = new RegExp(tagName + attrName + attrPartials + "*)([ " + spaces + "]*/>)", "g");
|
|
168
168
|
const marker = "<!--#-->";
|
|
169
|
-
const reservedNameSpaces = new Set(["class", "on", "style", "use", "prop"
|
|
169
|
+
const reservedNameSpaces = new Set(["class", "on", "style", "use", "prop"]);
|
|
170
170
|
function attrReplacer($0, $1, $2, $3) {
|
|
171
171
|
return "<" + $1 + $2.replace(findAttributes, replaceAttributes) + $3;
|
|
172
172
|
}
|
|
@@ -251,8 +251,8 @@ function createHTML(r, {
|
|
|
251
251
|
options.exprs.push(`r.style(${tag},${expr},_$p)`);
|
|
252
252
|
} else if (name === "class") {
|
|
253
253
|
options.exprs.push(`r.className(${tag},${expr},${isSVG},_$p)`);
|
|
254
|
-
} else if (
|
|
255
|
-
options.exprs.push(`${tag}.${
|
|
254
|
+
} else if (isChildProp || !isSVG && isProp || namespace === "prop") {
|
|
255
|
+
options.exprs.push(`${tag}.${name} = ${expr}`);
|
|
256
256
|
} else {
|
|
257
257
|
const ns = isSVG && name.indexOf(":") > -1 && r.SVGNamespace[name.split(":")[0]];
|
|
258
258
|
if (ns) options.exprs.push(`r.setAttributeNS(${tag},"${ns}","${name}",${expr})`);else options.exprs.push(`r.setAttribute(${tag},"${name}",${expr})`);
|
|
@@ -362,9 +362,9 @@ function createHTML(r, {
|
|
|
362
362
|
propGroups.push(`exprs[${options.counter++}]`);
|
|
363
363
|
propGroups.push(props = []);
|
|
364
364
|
} else if (value === "###") {
|
|
365
|
-
props.push(
|
|
366
|
-
} else props.push(
|
|
367
|
-
} else if (type ===
|
|
365
|
+
props.push(`"${name}": exprs[${options.counter++}]`);
|
|
366
|
+
} else props.push(`"${name}": "${value}"`);
|
|
367
|
+
} else if (type === 'directive') {
|
|
368
368
|
const tag = `_$el${uuid++}`;
|
|
369
369
|
const topDecl = !options.decl.length;
|
|
370
370
|
options.decl.push(topDecl ? "" : `${tag} = ${options.path}.${options.first ? "firstChild" : "nextSibling"}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/html",
|
|
3
3
|
"description": "Build-less Tagged-Template-Literal Templating for Solid",
|
|
4
|
-
"version": "2.0.0-experimental.
|
|
4
|
+
"version": "2.0.0-experimental.11",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"./dist/*": "./dist/*"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@solidjs/web": "^2.0.0-experimental.
|
|
34
|
+
"@solidjs/web": "^2.0.0-experimental.11"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@solidjs/web": "2.0.0-experimental.
|
|
37
|
+
"@solidjs/web": "2.0.0-experimental.11"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "npm-run-all -nl build:*",
|
package/types/index.d.ts
DELETED
package/types/lit.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
|
-
type ClassList =
|
|
3
|
-
| Record<string, boolean>
|
|
4
|
-
| Array<string | number | boolean | null | undefined | Record<string, boolean>>;
|
|
5
|
-
interface Runtime {
|
|
6
|
-
effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void, init?: T): void;
|
|
7
|
-
untrack<T>(fn: () => T): T;
|
|
8
|
-
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
9
|
-
spread<T>(node: Element, accessor: (() => T) | T, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
10
|
-
createComponent(Comp: (props: any) => any, props: any): any;
|
|
11
|
-
addEventListener(
|
|
12
|
-
node: Element,
|
|
13
|
-
name: string,
|
|
14
|
-
handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
|
|
15
|
-
delegate: boolean
|
|
16
|
-
): void;
|
|
17
|
-
delegateEvents(eventNames: string[]): void;
|
|
18
|
-
className(
|
|
19
|
-
node: Element,
|
|
20
|
-
value: string | ClassList,
|
|
21
|
-
isSVG?: boolean,
|
|
22
|
-
prev?: string | ClassList
|
|
23
|
-
): void;
|
|
24
|
-
style(
|
|
25
|
-
node: Element,
|
|
26
|
-
value: {
|
|
27
|
-
[k: string]: string;
|
|
28
|
-
},
|
|
29
|
-
prev?: {
|
|
30
|
-
[k: string]: string;
|
|
31
|
-
}
|
|
32
|
-
): void;
|
|
33
|
-
mergeProps(...sources: unknown[]): unknown;
|
|
34
|
-
dynamicProperty(props: any, key: string): any;
|
|
35
|
-
setAttribute(node: Element, name: string, value: any): void;
|
|
36
|
-
setAttributeNS(node: Element, namespace: string, name: string, value: any): void;
|
|
37
|
-
getPropAlias(prop: string, tagName: string): string | undefined;
|
|
38
|
-
Properties: Set<string>;
|
|
39
|
-
ChildProperties: Set<string>;
|
|
40
|
-
DelegatedEvents: Set<string>;
|
|
41
|
-
SVGElements: Set<string>;
|
|
42
|
-
SVGNamespace: Record<string, string>;
|
|
43
|
-
}
|
|
44
|
-
export type HTMLTag = {
|
|
45
|
-
(statics: TemplateStringsArray, ...args: unknown[]): Node | Node[];
|
|
46
|
-
};
|
|
47
|
-
export declare function createHTML(
|
|
48
|
-
r: Runtime,
|
|
49
|
-
{
|
|
50
|
-
delegateEvents,
|
|
51
|
-
functionBuilder
|
|
52
|
-
}?: {
|
|
53
|
-
delegateEvents?: boolean;
|
|
54
|
-
functionBuilder?: (...args: string[]) => Function;
|
|
55
|
-
}
|
|
56
|
-
): HTMLTag;
|
|
57
|
-
export {};
|