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.
195195func (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
0 commit comments