Skip to content

Commit b7ff0f7

Browse files
committed
Finish Go renaming
1 parent 44488fe commit b7ff0f7

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

sdk/go/datastar/elements-sugar.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/valyala/bytebufferpool"
99
)
1010

11-
// ValidElementMergeTypes is a list of valid element merge modes.
12-
var ValidElementMergeTypes = []ElementPatchMode{
11+
// ValidElementPatchModes is a list of valid element patch modes.
12+
var ValidElementPatchModes = []ElementPatchMode{
1313
ElementPatchModeOuter,
1414
ElementPatchModeInner,
1515
ElementPatchModeRemove,
@@ -20,8 +20,8 @@ var ValidElementMergeTypes = []ElementPatchMode{
2020
ElementPatchModeReplace,
2121
}
2222

23-
// ElementMergeTypeFromString converts a string to a [ElementPatchMode].
24-
func ElementMergeTypeFromString(s string) (ElementPatchMode, error) {
23+
// ElementPatchModeFromString converts a string to a [ElementPatchMode].
24+
func ElementPatchModeFromString(s string) (ElementPatchMode, error) {
2525
switch s {
2626
case "outer":
2727
return ElementPatchModeOuter, nil
@@ -44,45 +44,45 @@ func ElementMergeTypeFromString(s string) (ElementPatchMode, error) {
4444
}
4545
}
4646

47-
// WithMergeOuter creates a PatchElementOption that merges elements using the outer mode.
48-
func WithMergeOuter() PatchElementOption {
49-
return WithMergeMode(ElementPatchModeOuter)
47+
// WithModeOuter creates a PatchElementOption that merges elements using the outer mode.
48+
func WithModeOuter() PatchElementOption {
49+
return WithMode(ElementPatchModeOuter)
5050
}
5151

52-
// WithMergeInner creates a PatchElementOption that merges elements using the inner mode.
53-
func WithMergeInner() PatchElementOption {
54-
return WithMergeMode(ElementPatchModeInner)
52+
// WithModeInner creates a PatchElementOption that merges elements using the inner mode.
53+
func WithModeInner() PatchElementOption {
54+
return WithMode(ElementPatchModeInner)
5555
}
5656

57-
// WithMergeRemove creates a PatchElementOption that removes elements from the DOM.
58-
func WithMergeRemove() PatchElementOption {
59-
return WithMergeMode(ElementPatchModeRemove)
57+
// WithModeRemove creates a PatchElementOption that removes elements from the DOM.
58+
func WithModeRemove() PatchElementOption {
59+
return WithMode(ElementPatchModeRemove)
6060
}
6161

62-
// WithMergePrepend creates a PatchElementOption that merges elements using the prepend mode.
63-
func WithMergePrepend() PatchElementOption {
64-
return WithMergeMode(ElementPatchModePrepend)
62+
// WithModePrepend creates a PatchElementOption that merges elements using the prepend mode.
63+
func WithModePrepend() PatchElementOption {
64+
return WithMode(ElementPatchModePrepend)
6565
}
6666

67-
// WithMergeAppend creates a PatchElementOption that merges elements using the append mode.
68-
func WithMergeAppend() PatchElementOption {
69-
return WithMergeMode(ElementPatchModeAppend)
67+
// WithModeAppend creates a PatchElementOption that merges elements using the append mode.
68+
func WithModeAppend() PatchElementOption {
69+
return WithMode(ElementPatchModeAppend)
7070
}
7171

72-
// WithMergeBefore creates a PatchElementOption that merges elements using the before mode.
73-
func WithMergeBefore() PatchElementOption {
74-
return WithMergeMode(ElementPatchModeBefore)
72+
// WithModeBefore creates a PatchElementOption that merges elements using the before mode.
73+
func WithModeBefore() PatchElementOption {
74+
return WithMode(ElementPatchModeBefore)
7575
}
7676

77-
// WithMergeAfter creates a PatchElementOption that merges elements using the after mode.
78-
func WithMergeAfter() PatchElementOption {
79-
return WithMergeMode(ElementPatchModeAfter)
77+
// WithModeAfter creates a PatchElementOption that merges elements using the after mode.
78+
func WithModeAfter() PatchElementOption {
79+
return WithMode(ElementPatchModeAfter)
8080
}
8181

82-
// WithMergeReplace creates a PatchElementOption that replaces elements without morphing.
82+
// WithModeReplace creates a PatchElementOption that replaces elements without morphing.
8383
// This mode does not use morphing and will completely replace the element, resetting any related state.
84-
func WithMergeReplace() PatchElementOption {
85-
return WithMergeMode(ElementPatchModeReplace)
84+
func WithModeReplace() PatchElementOption {
85+
return WithMode(ElementPatchModeReplace)
8686
}
8787

8888
// WithSelectorID is a convenience wrapper for [WithSelector] option
@@ -125,7 +125,7 @@ func (sse *ServerSentEventGenerator) PatchElementTempl(c TemplComponent, opts ..
125125
buf := bytebufferpool.Get()
126126
defer bytebufferpool.Put(buf)
127127
if err := c.Render(sse.Context(), buf); err != nil {
128-
return fmt.Errorf("failed to merge element: %w", err)
128+
return fmt.Errorf("failed to patch element: %w", err)
129129
}
130130
if err := sse.PatchElements(buf.String(), opts...); err != nil {
131131
return fmt.Errorf("failed to patch element: %w", err)
@@ -191,10 +191,10 @@ func DeleteSSE(urlFormat string, args ...any) string {
191191
}
192192

193193
// RemoveElement is a convenience method for removing elements from the DOM.
194-
// It uses PatchElements with the remove merge mode and the specified selector.
194+
// It uses PatchElements with the remove mode and the specified selector.
195195
func (sse *ServerSentEventGenerator) RemoveElement(selector string, opts ...PatchElementOption) error {
196196
// Prepend the remove mode option
197-
allOpts := append([]PatchElementOption{WithMergeRemove(), WithSelector(selector)}, opts...)
197+
allOpts := append([]PatchElementOption{WithModeRemove(), WithSelector(selector)}, opts...)
198198
return sse.PatchElements("", allOpts...)
199199
}
200200

sdk/go/datastar/elements.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func WithSelector(selector string) PatchElementOption {
4747
}
4848
}
4949

50-
// WithMergeMode overrides the [DefaultElementPatchMode] for the element.
50+
// WithMode overrides the [DefaultElementPatchMode] for the element.
5151
// Choose a valid [ElementPatchMode].
52-
func WithMergeMode(merge ElementPatchMode) PatchElementOption {
52+
func WithMode(merge ElementPatchMode) PatchElementOption {
5353
return func(o *patchElementOptions) {
5454
o.MergeMode = merge
5555
}

sdk/go/datastar/elements_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import "testing"
44

55
func TestAllValidElementMergeTypes(t *testing.T) {
66
var err error
7-
for _, validType := range ValidElementMergeTypes {
8-
if _, err = ElementMergeTypeFromString(string(validType)); err != nil {
7+
for _, validType := range ValidElementPatchModes {
8+
if _, err = ElementPatchModeFromString(string(validType)); err != nil {
99
t.Errorf("Expected %v to be a valid element merge type, but it was rejected: %v", validType, err)
1010
}
1111
}
1212

13-
if _, err = ElementMergeTypeFromString(""); err == nil {
13+
if _, err = ElementPatchModeFromString(""); err == nil {
1414
t.Errorf("Expected an empty string to be an invalid element merge type, but it was accepted")
1515
}
1616

17-
if _, err = ElementMergeTypeFromString("fakeType"); err == nil {
17+
if _, err = ElementPatchModeFromString("fakeType"); err == nil {
1818
t.Errorf("Expected a fake type to be an invalid element merge type, but it was accepted")
1919
}
2020
}

sdk/go/datastar/execute-script-sugar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (sse *ServerSentEventGenerator) ExecuteScript(scriptContents string, opts .
100100
// Use PatchElements to send the script
101101
patchOpts := []PatchElementOption{
102102
WithSelector("body"),
103-
WithMergeAppend(),
103+
WithModeAppend(),
104104
}
105105
if options.EventID != "" {
106106
patchOpts = append(patchOpts, WithPatchElementsEventID(options.EventID))

0 commit comments

Comments
 (0)