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 carry on using 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 initialisation
Host-reserved names and invalid identifiers stay excluded from automatic field aliases; xfa.resolveNode offers 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 still flows to calculate or validate completion processing
An initial use strict directive now remains the directive of the user body; assigning to an undeclared variable throws instead of 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 any writes performed before a runtime error
Successful native writes survive saved XDP reload; local event variables belong to that invocation, whilst variables script objects retain their established persistent lexical state and closure behaviour
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