fix(page-data): isolate invalid workspace bindings

This commit is contained in:
john
2026-07-20 11:39:17 +08:00
parent 105a72c1f1
commit b6f2b40942
3 changed files with 34 additions and 16 deletions
+7 -3
View File
@@ -47,13 +47,17 @@ export function detectPageDataDatasetUsageFromHtml(html) {
// this API must therefore only require the safe, default capability.
remember(match[1], { softDelete: true });
}
for (const match of text.matchAll(/\.insertRow\(\s*([A-Za-z_$][\w$]*)/g)) {
// `${...}` inside an HTML template literal is a row-id interpolation, not a
// JavaScript identifier passed as the dataset argument. Without this guard,
// snippets such as `onclick="deleteRow(${row.id})"` are detected as a `$`
// dataset and can make the whole workspace binding pass fail.
for (const match of text.matchAll(/\.insertRow\(\s*(?!\$\{)([A-Za-z_$][\w$]*)/g)) {
remember(constants.get(match[1]) ?? match[1], { insert: true });
}
for (const match of text.matchAll(/\.listRows\(\s*([A-Za-z_$][\w$]*)/g)) {
for (const match of text.matchAll(/\.listRows\(\s*(?!\$\{)([A-Za-z_$][\w$]*)/g)) {
remember(constants.get(match[1]) ?? match[1], { read: true });
}
for (const match of text.matchAll(/\.deleteRow\(\s*([A-Za-z_$][\w$]*)/g)) {
for (const match of text.matchAll(/\.deleteRow\(\s*(?!\$\{)([A-Za-z_$][\w$]*)/g)) {
remember(constants.get(match[1]) ?? match[1], { softDelete: true });
}