starfederation / datastar

A real-time hypermedia framework.
https://data-star.dev/
MIT License
722 stars 41 forks source link

Remove merge options covered by idiomorph #157

Closed potatotech closed 3 weeks ago

potatotech commented 1 month ago

Use cases for inner, outer, and upsert_attributes can all be handled by morph and signals.

bencroker commented 1 month ago

Can you please explain?

delaneyj commented 1 month ago

@potatotech upsert_attributes isn't covered by idiomorph

potatotech commented 1 month ago

Restored upsert_attributes

delaneyj commented 1 month ago

Needs to be removed from datastar.go and any examples as well but getting close!

bencroker commented 1 month ago

I think I’ve changed all instances in all examples now.

bencroker commented 1 month ago

main has been merged, fyi.

delaneyj commented 1 month ago

LGTM will put off until v20 release

bencroker commented 1 month ago

Use cases for inner, outer, and upsert_attributes can all be handled by morph and signals.

@potatotech can you please help me understand how inner can be handled when the default morph style used is outerHTML, which is not currently configurable in Datastar?

bencroker commented 1 month ago

If it turns out that the only redundant merge strategy is outer, then I’d opt for leaving it in, as it still offers the benefit of allowing you to target an element by selector without requiring matching IDs.

bencroker commented 4 weeks ago

I’ve come to the strong conclusion that there is no upside whatsoever in removing merge options. Even outer can be useful considering that the back-end should have full control over deciding what DOM elements to swap. Without it, an ID must already exist in the front-end. I vote not to merge.

potatotech commented 4 weeks ago

The backend is the frontend with hypermedia. If there's a missing id, add it in the template. When swapping fragments, datastar needs to target a specific element, and the only unique selector is id. Morph is sufficient because all other selectors are less specific*.

* There are things like #id[attribute] or #id.class, but id is already unique, so these are not necessary. You definitely should not be using them to store state either.

delaneyj commented 3 weeks ago

I'm going to leave it @potatotech, while I :100: agree you should always use the idiomorph I can see value in the effiency of inner/outerhtml for sheer speed in certain situatins. Thank you for your effort!