fix(lib/jsrunner): use the key parameter in MustGet instead of hardcoded "elkResult"

Signed-off-by: chai2010 <chaishushan@gmail.com>
This commit is contained in:
chai2010 2025-05-02 06:12:29 +08:00
parent 7150096840
commit 5eda1e36d7

View file

@ -34,11 +34,11 @@ func (j *jsRunner) Engine() Engine {
} }
func (j *jsRunner) MustGet(key string) (JSValue, error) { func (j *jsRunner) MustGet(key string) (JSValue, error) {
result := j.global.Get("elkResult") result := j.global.Get(key)
if result.IsUndefined() { if result.IsUndefined() {
return nil, fmt.Errorf("key %q not found in global scope", key) return nil, fmt.Errorf("key %q not found in global scope", key)
} }
defer j.global.Set("elkResult", js.Undefined()) defer j.global.Set(key, js.Undefined())
return &jsValue{val: result}, nil return &jsValue{val: result}, nil
} }