XFA JavaScript Event Scope
Unit: HPDFXFAEventScript, integrated through HPDFXFARuntime
Named aliases and local declarations
The event host resolves eligible named form nodes into the outer event scope; an event can continue to use input.rawValue when input is an accessible named field
The user event body has its own JavaScript function scope, so const, let and class declarations can shadow a field alias without conflicting with host-generated variable declarations
const input = xfa.resolveNode("main.input");
input.rawValue = "saved";
Local var and function declarations also use ordinary JavaScript scope rules; explicit local bindings shadow an outer alias, and a lexical binding remains unavailable before its initialization
Host-reserved names and invalid identifiers remain excluded from automatic field aliases; xfa.resolveNode provides explicit lookup for those names
Execution context and strict mode
The event body's this remains the executing form node, and an explicit return value continues to flow to calculate or validate completion processing
An initial use strict directive now remains the directive of the user body; assigning an undeclared variable throws rather than creating a global binding
"use strict";
const local = "value";
xfa.resolveNode("main.input").rawValue = local;
Transactions and lifetime
A syntax error, temporal-dead-zone ReferenceError or strict-mode ReferenceError aborts the event and restores its native form/datasets snapshot, including writes performed before a runtime error
Successful native writes survive saved XDP reload; local event variables belong to that invocation, while variables script objects retain their established persistent lexical state and closure behavior
The nested scope does not add host transport calls or change script, memory, operation and replay budgets
Related APIs
HPDFXFAExecuteJavaScriptEvent, Interactive XFA Runtime and Native Absent Property Creation