fix(editor): type nested attribute expressions
Quality / quality (windows-latest) (push) Waiting to run
Quality / quality (ubuntu-latest) (push) Failing after 9m52s

This commit is contained in:
2026-08-25 15:16:38 +05:30
parent 3cb6ba1233
commit 7658c5d499
12 changed files with 193 additions and 22 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
import type { Attr, PageAst, ViewNode } from "@wrnexus/syntax";
import { extractInterpolations, type Attr, type PageAst, type ViewNode } from "@wrnexus/syntax";
export class NativeCompileError extends Error {
constructor(message: string) {
@@ -68,11 +68,11 @@ function expression(value: string): string | null {
function textJsx(value: string): string {
const pieces: string[] = [];
let last = 0;
for (const match of value.matchAll(/\{([^{}]+)\}/g)) {
if (match.index! > last) pieces.push(value.slice(last, match.index));
const expr = match[1]!.trim();
for (const segment of extractInterpolations(value)) {
if (segment.start > last) pieces.push(value.slice(last, segment.start));
const expr = segment.expression;
pieces.push(expr.startsWith("t:") ? `{${JSON.stringify(expr.slice(2).trim())}}` : `{${expr}}`);
last = match.index! + match[0].length;
last = segment.end;
}
pieces.push(value.slice(last));
return pieces.join("").replace(/([<>])/g, (char) => (char === "<" ? "&lt;" : "&gt;"));