@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2016-2023 Ryan Carniato
3
+ Copyright (c) 2016-2025 Ryan Carniato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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 ? void 0 : end);
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 = void 0;
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 = void 0;
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", "attr"]);
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 (namespace !== "attr" && (isChildProp || !isSVG && (r.getPropAlias(name, node.name.toUpperCase()) || isProp) || namespace === "prop")) {
257
- options.exprs.push(`${tag}.${r.getPropAlias(name, node.name.toUpperCase()) || name} = ${expr}`);
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(`${name}: exprs[${options.counter++}]`);
368
- } else props.push(`${name}: "${value}"`);
369
- } else if (type === "directive") {
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 ? void 0 : end);
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 = void 0;
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 = void 0;
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", "attr"]);
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 (namespace !== "attr" && (isChildProp || !isSVG && (r.getPropAlias(name, node.name.toUpperCase()) || isProp) || namespace === "prop")) {
255
- options.exprs.push(`${tag}.${r.getPropAlias(name, node.name.toUpperCase()) || name} = ${expr}`);
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(`${name}: exprs[${options.counter++}]`);
366
- } else props.push(`${name}: "${value}"`);
367
- } else if (type === "directive") {
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.1",
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.1"
34
+ "@solidjs/web": "^2.0.0-experimental.11"
35
35
  },
36
36
  "devDependencies": {
37
- "@solidjs/web": "2.0.0-experimental.1"
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
@@ -1,3 +0,0 @@
1
- import type { HTMLTag } from "./lit.js";
2
- declare const html: HTMLTag;
3
- export default html;
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 {};