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

Commit

Permalink
Fix spelling in comment and move funs to be pkg private
Browse files Browse the repository at this point in the history
  • Loading branch information
robingustafsson committed Nov 5, 2021
1 parent c722f5b commit fefec9a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions common/frame_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion common/page_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
58 changes: 29 additions & 29 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -59,20 +59,20 @@ 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)
if err != nil {
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
}

Expand All @@ -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,
Expand All @@ -114,20 +114,20 @@ 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)
if err != nil {
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
}

Expand All @@ -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,
Expand All @@ -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
}
Expand All @@ -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
}

Expand All @@ -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,
Expand All @@ -220,20 +220,20 @@ 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)
if err != nil {
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
}

Expand All @@ -252,36 +252,36 @@ 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,
}

// 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)
if err != nil {
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
}

Expand Down

0 comments on commit fefec9a

Please sign in to comment.