From fefec9a580994a18ab73908bc643980f686210a3 Mon Sep 17 00:00:00 2001 From: Robin Gustafsson Date: Fri, 5 Nov 2021 16:23:40 +0100 Subject: [PATCH] Fix spelling in comment and move funs to be pkg private --- common/frame_options.go | 8 +++--- common/page_options.go | 2 +- common/types.go | 58 ++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/common/frame_options.go b/common/frame_options.go index 74713f411..d1fafc3e4 100644 --- a/common/frame_options.go +++ b/common/frame_options.go @@ -298,7 +298,7 @@ func (o *FrameGotoOptions) Parse(ctx context.Context, opts goja.Value) error { o.Timeout = time.Duration(opts.Get(k).ToInteger()) * time.Millisecond case "waitUntil": lifeCycle := opts.Get(k).String() - if l, ok := LifecycleEventToID[lifeCycle]; ok { + if l, ok := lifecycleEventToID[lifeCycle]; ok { o.WaitUntil = l } else { return fmt.Errorf("%q is not a valid lifecycle", lifeCycle) @@ -505,7 +505,7 @@ func (o *FrameSetContentOptions) Parse(ctx context.Context, opts goja.Value) err o.Timeout = time.Duration(opts.Get(k).ToInteger()) * time.Millisecond case "waitUntil": lifeCycle := opts.Get(k).String() - if l, ok := LifecycleEventToID[lifeCycle]; ok { + if l, ok := lifecycleEventToID[lifeCycle]; ok { o.WaitUntil = l } else { return fmt.Errorf("%q is not a valid lifecycle", lifeCycle) @@ -670,7 +670,7 @@ func (o *FrameWaitForNavigationOptions) Parse(ctx context.Context, opts goja.Val o.Timeout = time.Duration(opts.Get(k).ToInteger()) * time.Millisecond case "waitUntil": lifeCycle := opts.Get(k).String() - if l, ok := LifecycleEventToID[lifeCycle]; ok { + if l, ok := lifecycleEventToID[lifeCycle]; ok { o.WaitUntil = l } else { return fmt.Errorf("%q is not a valid lifecycle", lifeCycle) @@ -698,7 +698,7 @@ func (o *FrameWaitForSelectorOptions) Parse(ctx context.Context, opts goja.Value switch k { case "state": state := opts.Get(k).String() - if s, ok := DOMElementStateToID[state]; ok { + if s, ok := domElementStateToID[state]; ok { o.State = s } else { return fmt.Errorf("%q is not a valid DOM state", state) diff --git a/common/page_options.go b/common/page_options.go index 8b9ba7122..73b3a58e0 100644 --- a/common/page_options.go +++ b/common/page_options.go @@ -91,7 +91,7 @@ func (o *PageReloadOptions) Parse(ctx context.Context, opts goja.Value) error { switch k { case "waitUntil": lifeCycle := opts.Get(k).String() - if l, ok := LifecycleEventToID[lifeCycle]; ok { + if l, ok := lifecycleEventToID[lifeCycle]; ok { o.WaitUntil = l } else { return fmt.Errorf("%q is not a valid lifecycle", lifeCycle) diff --git a/common/types.go b/common/types.go index e3d14c74e..d3625ce5e 100644 --- a/common/types.go +++ b/common/types.go @@ -41,16 +41,16 @@ const ( ) func (c ColorScheme) String() string { - return ColorSchemeToString[c] + return colorSchemeToString[c] } -var ColorSchemeToString = map[ColorScheme]string{ +var colorSchemeToString = map[ColorScheme]string{ ColorSchemeLight: "light", ColorSchemeDark: "dark", ColorSchemeNoPreference: "no-preference", } -var ColorSchemeToID = map[string]ColorScheme{ +var colorSchemeToID = map[string]ColorScheme{ "light": ColorSchemeLight, "dark": ColorSchemeDark, "no-preference": ColorSchemeNoPreference, @@ -59,12 +59,12 @@ var ColorSchemeToID = map[string]ColorScheme{ // MarshalJSON marshals the enum as a quoted JSON string func (c ColorScheme) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString(`"`) - buffer.WriteString(ColorSchemeToString[c]) + buffer.WriteString(colorSchemeToString[c]) buffer.WriteString(`"`) return buffer.Bytes(), nil } -// UnmarshalJSON unmashals a quoted JSON string to the enum value +// UnmarshalJSON unmarshals a quoted JSON string to the enum value func (c *ColorScheme) UnmarshalJSON(b []byte) error { var j string err := json.Unmarshal(b, &j) @@ -72,7 +72,7 @@ func (c *ColorScheme) UnmarshalJSON(b []byte) error { return err } // Note that if the string cannot be found then it will be set to the zero value. - *c = ColorSchemeToID[j] + *c = colorSchemeToID[j] return nil } @@ -94,17 +94,17 @@ const ( ) func (s DOMElementState) String() string { - return DOMElementStateToString[s] + return domElementStateToString[s] } -var DOMElementStateToString = map[DOMElementState]string{ +var domElementStateToString = map[DOMElementState]string{ DOMElementStateAttached: "attached", DOMElementStateDetached: "detached", DOMElementStateVisible: "visible", DOMElementStateHidden: "hidden", } -var DOMElementStateToID = map[string]DOMElementState{ +var domElementStateToID = map[string]DOMElementState{ "attached": DOMElementStateAttached, "detached": DOMElementStateDetached, "visible": DOMElementStateVisible, @@ -114,12 +114,12 @@ var DOMElementStateToID = map[string]DOMElementState{ // MarshalJSON marshals the enum as a quoted JSON string func (s DOMElementState) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString(`"`) - buffer.WriteString(DOMElementStateToString[s]) + buffer.WriteString(domElementStateToString[s]) buffer.WriteString(`"`) return buffer.Bytes(), nil } -// UnmarshalJSON unmashals a quoted JSON string to the enum value +// UnmarshalJSON unmarshals a quoted JSON string to the enum value func (s *DOMElementState) UnmarshalJSON(b []byte) error { var j string err := json.Unmarshal(b, &j) @@ -127,7 +127,7 @@ func (s *DOMElementState) UnmarshalJSON(b []byte) error { return err } // Note that if the string cannot be found then it will be set to the zero value. - *s = DOMElementStateToID[j] + *s = domElementStateToID[j] return nil } @@ -151,16 +151,16 @@ const ( ) func (l LifecycleEvent) String() string { - return LifecycleEventToString[l] + return lifecycleEventToString[l] } -var LifecycleEventToString = map[LifecycleEvent]string{ +var lifecycleEventToString = map[LifecycleEvent]string{ LifecycleEventLoad: "load", LifecycleEventDOMContentLoad: "domcontentloaded", LifecycleEventNetworkIdle: "networkidle", } -var LifecycleEventToID = map[string]LifecycleEvent{ +var lifecycleEventToID = map[string]LifecycleEvent{ "load": LifecycleEventLoad, "domcontentloaded": LifecycleEventDOMContentLoad, "networkidle": LifecycleEventNetworkIdle, @@ -169,7 +169,7 @@ var LifecycleEventToID = map[string]LifecycleEvent{ // MarshalJSON marshals the enum as a quoted JSON string func (l LifecycleEvent) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString(`"`) - buffer.WriteString(LifecycleEventToString[l]) + buffer.WriteString(lifecycleEventToString[l]) buffer.WriteString(`"`) return buffer.Bytes(), nil } @@ -182,7 +182,7 @@ func (l *LifecycleEvent) UnmarshalJSON(b []byte) error { return err } // Note that if the string cannot be found then it will be set to the zero value. - *l = LifecycleEventToID[j] + *l = lifecycleEventToID[j] return nil } @@ -202,16 +202,16 @@ const ( ) func (p PollingType) String() string { - return PollingTypeToString[p] + return pollingTypeToString[p] } -var PollingTypeToString = map[PollingType]string{ +var pollingTypeToString = map[PollingType]string{ PollingRaf: "raf", PollingMutation: "mutation", PollingInterval: "interval", } -var PollingTypeToID = map[string]PollingType{ +var pollingTypeToID = map[string]PollingType{ "raf": PollingRaf, "mutation": PollingMutation, "interval": PollingInterval, @@ -220,12 +220,12 @@ var PollingTypeToID = map[string]PollingType{ // MarshalJSON marshals the enum as a quoted JSON string func (p PollingType) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString(`"`) - buffer.WriteString(PollingTypeToString[p]) + buffer.WriteString(pollingTypeToString[p]) buffer.WriteString(`"`) return buffer.Bytes(), nil } -// UnmarshalJSON unmashals a quoted JSON string to the enum value +// UnmarshalJSON unmarshals a quoted JSON string to the enum value func (p *PollingType) UnmarshalJSON(b []byte) error { var j string err := json.Unmarshal(b, &j) @@ -233,7 +233,7 @@ func (p *PollingType) UnmarshalJSON(b []byte) error { return err } // Note that if the string cannot be found then it will be set to the zero value. - *p = PollingTypeToID[j] + *p = pollingTypeToID[j] return nil } @@ -252,15 +252,15 @@ const ( ) func (r ReducedMotion) String() string { - return ReducedMotionToString[r] + return reducedMotionToString[r] } -var ReducedMotionToString = map[ReducedMotion]string{ +var reducedMotionToString = map[ReducedMotion]string{ ReducedMotionReduce: "reduce", ReducedMotionNoPreference: "no-preference", } -var ReducedMotionToID = map[string]ReducedMotion{ +var reducedMotionToID = map[string]ReducedMotion{ "reduce": ReducedMotionReduce, "no-preference": ReducedMotionNoPreference, } @@ -268,12 +268,12 @@ var ReducedMotionToID = map[string]ReducedMotion{ // MarshalJSON marshals the enum as a quoted JSON string func (r ReducedMotion) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString(`"`) - buffer.WriteString(ReducedMotionToString[r]) + buffer.WriteString(reducedMotionToString[r]) buffer.WriteString(`"`) return buffer.Bytes(), nil } -// UnmarshalJSON unmashals a quoted JSON string to the enum value +// UnmarshalJSON unmarshals a quoted JSON string to the enum value func (r *ReducedMotion) UnmarshalJSON(b []byte) error { var j string err := json.Unmarshal(b, &j) @@ -281,7 +281,7 @@ func (r *ReducedMotion) UnmarshalJSON(b []byte) error { return err } // Note that if the string cannot be found then it will be set to the zero value. - *r = ReducedMotionToID[j] + *r = reducedMotionToID[j] return nil }