Skip to content

Commit

Permalink
Also set "options" on the "exports" not just in the runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov authored and na-- committed May 21, 2020
1 parent e148773 commit bda6461
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ func (b *Bundle) Instantiate() (bi *BundleInstance, instErr error) {
var jsOptionsObj *goja.Object
if jsOptions == nil || goja.IsNull(jsOptions) || goja.IsUndefined(jsOptions) {
jsOptionsObj = rt.NewObject()
rt.Set("options", jsOptionsObj)
if err := exports.Set("options", jsOptionsObj); err != nil {
return nil, err
}
} else {
jsOptionsObj = jsOptions.ToObject(rt)
}
Expand Down
1 change: 1 addition & 0 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func TestOptionsSettingToScript(t *testing.T) {
t.Run(fmt.Sprintf("Variant#%d", i), func(t *testing.T) {
t.Parallel()
data := variant + `
exports.options = options;
exports.default = function() {
if (!options) {
throw new Error("Expected options to be defined!");
Expand Down

0 comments on commit bda6461

Please sign in to comment.