fix(electron): retain computed literal preference keys

Use the parsed semantic property key instead of treating all bracketed keys as dynamic. Preserve empty and numeric literal keys; unresolved computed expressions remain unknown.

Validation: exact named preference and dynamic coverage regressions pass. Fixes #2521.

Based on #3105.

Co-authored-by: ShuaixinHuang <1836656514@qq.com>
This commit is contained in:
morlutoandShuaixinHuang committed 2026-10-14 13:58:13 +08:00
1 parent 7e1c560dd6
commit bdf865252c
2 files changed
+58 -3

No files matched your search

@@ -25,7 +25,7 @@ import {
staticPath,
staticPathResolutionContext,
} from "./javascriptStaticAnalysisHelpers.js";
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
import { semanticStaticPropertyKey } from "./javascriptAstValues.js";
import type { JavaScriptFindingContext } from "./javascriptStaticAnalysisState.js";
/** Inspect BrowserWindow, contextBridge, and utility-process syntax. */
@@ -126,8 +126,8 @@ const collectWebPreferences = (
});
continue;
}
const name = semanticStaticPropertyName(property.key, property.computed);
if (name === "" || property.computed) {
const name = semanticStaticPropertyKey(property.key, property.computed);
if (name === null) {
unknown += 1;
preferences.push({
name: `[dynamic@${String(property.start ?? -1)}]`,