release: WRNexusJS 0.2.27

This commit is contained in:
2026-07-14 14:40:13 +05:30
parent fef4218a07
commit d3094010af
64 changed files with 763 additions and 244 deletions
+32 -9
View File
@@ -386,13 +386,15 @@ export function parseHtmlView(src: string, pos: number): { nodes: ViewNode[]; en
let i = pos;
const isNameStart = (c: string): boolean => /[A-Za-z_]/.test(c);
const isNamePart = (c: string): boolean => /[A-Za-z0-9_:.[\]%-]/.test(c);
const isTagNamePart = (c: string): boolean => /[A-Za-z0-9_$:.-]/.test(c);
const isAttributeNamePart = (c: string, next: string | undefined): boolean => {
if (c === "/") {
return next !== ">";
}
return isNamePart(c);
return /[A-Za-z0-9_$:.[\]%-]/.test(c);
};
const isWs = (c: string): boolean => c === " " || c === "\t" || c === "\n" || c === "\r";
@@ -429,18 +431,39 @@ export function parseHtmlView(src: string, pos: number): { nodes: ViewNode[]; en
return value;
};
const readName = (): string => {
if (i >= src.length || !isNameStart(src[i]!)) return fail("Expected a tag or attribute name");
const readTagName = (): string => {
if (i >= src.length || !isNameStart(src[i]!)) {
return fail("Expected a tag name");
}
const start = i++;
while (i < src.length && isAttributeNamePart(src[i], src[i + 1])) {
while (i < src.length && isTagNamePart(src[i]!)) {
i++;
}
return src.slice(start, i);
};
const readAttributeName = (): string => {
const first = src[i];
if (i >= src.length || (!isNameStart(first!) && first !== ":" && first !== "$")) {
return fail("Expected an attribute name");
}
const start = i++;
while (i < src.length && isAttributeNamePart(src[i]!, src[i + 1])) {
i++;
}
return src.slice(start, i);
};
const parseTag = (): ViewNode => {
i++; // consume '<'
const tag = readName();
const tag = readTagName();
const attrs: Attr[] = [];
for (;;) {
@@ -457,7 +480,7 @@ export function parseHtmlView(src: string, pos: number): { nodes: ViewNode[]; en
}
if (c === "@") {
i++;
const name = readName();
const name = readAttributeName();
skipWs();
if (src[i] !== "=") return fail(`Expected '=' after @${name}`);
i++;
@@ -465,7 +488,7 @@ export function parseHtmlView(src: string, pos: number): { nodes: ViewNode[]; en
attrs.push({ name, value: readQuoted(), event: true });
continue;
}
const name = readName();
const name = readAttributeName();
skipWs();
if (src[i] === "=") {
i++;
@@ -485,7 +508,7 @@ export function parseHtmlView(src: string, pos: number): { nodes: ViewNode[]; en
if (src[i] !== "<" || src[i + 1] !== "/") return fail(`Expected </${tag}>`);
i += 2;
skipWs();
const close = readName();
const close = readTagName();
if (close !== tag) return fail(`Mismatched </${close}>, expected </${tag}>`);
skipWs();
if (src[i] !== ">") return fail(`Expected '>' to close </${tag}>`);