Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Fix issues found during code review
Browse files Browse the repository at this point in the history
  • Loading branch information
bandorko committed Dec 1, 2023
1 parent a60419b commit 6c40fe8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions common/element_handle_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func (o *ElementHandleCheckOptions) Parse(ctx context.Context, opts goja.Value)
func NewElementHandleSetInputFilesOptions(defaultTimeout time.Duration) *ElementHandleSetInputFilesOption {
return &ElementHandleSetInputFilesOption{
ElementHandleBaseOptions: *NewElementHandleBaseOptions(defaultTimeout),
Payload: []File{},
}
}

Expand All @@ -205,17 +204,20 @@ func (o *ElementHandleSetInputFilesOption) Parse(ctx context.Context, opts goja.
if err := o.ElementHandleBaseOptions.Parse(ctx, opts); err != nil {
return err
}
if opts != nil && !goja.IsUndefined(opts) && !goja.IsNull(opts) {
opts := opts.ToObject(rt)
for _, k := range opts.Keys() {
if k == "payload" {
var p []File
if err := rt.ExportTo(opts.Get(k), &p); err != nil {
return fmt.Errorf("unable to parse SetInputFileOptions; reason: %w", err)
}
o.Payload = p
}
if !gojaValueExists(opts) {
return nil
}
gopts := opts.ToObject(rt)
for _, k := range gopts.Keys() {
if k != "payload" {
continue
}
var p []File
if err := rt.ExportTo(gopts.Get(k), &p); err != nil {
return fmt.Errorf("unable to parse SetInputFileOptions; reason: %w", err)
}
o.Payload = p

Check failure on line 220 in common/element_handle_options.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
}

return nil
Expand Down

0 comments on commit 6c40fe8

Please sign in to comment.