Support Datastar v1.0.1 data-bind __prop/__event and data-on __document modifiers#42
Open
maragubot wants to merge 2 commits into
Open
Support Datastar v1.0.1 data-bind __prop/__event and data-on __document modifiers#42maragubot wants to merge 2 commits into
data-bind __prop/__event and data-on __document modifiers#42maragubot wants to merge 2 commits into
Conversation
…vent` helpers for Datastar v1.0.0 - `data-bind` gains `__prop` and `__event` modifier support via a new variadic `modifiers` parameter on `Bind()`. - `data-on` gains `__document` modifier support. - Bump vendored `datastar.js` to v1.0.0 and update compatibility note.
- `Prop(name)` now returns the full `__prop.name` modifier; `Event(names...)` returns the full `__event.a.b.c` modifier. Drop the now-redundant `ModifierProp` and `ModifierEvent` constants — one helper call replaces the paired-modifier form and removes a footgun where callers could emit invalid attributes. - Both helpers now panic on empty input, matching `Duration` and `Threshold`. - Fix `Bind` godoc to show the value form the library actually emits, and note that `__prop` and `__event` may be used independently (v1.0.1). - Bump vendored `datastar.js` and compat note to v1.0.1.
__prop, __event, __document)data-bind __prop/__event and data-on __document modifiers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the new attribute modifiers introduced in Datastar v1.0.0 and refined in v1.0.1:
data-bind__propmodifier — bind through a specific property (camelCased at runtime in v1.0.1)data-bind__eventmodifier — define which events sync the element back to the signaldata-on__documentmodifier — attach event listeners to thedocumentelementIn v1.0.1 the
__propand__eventmodifiers may be used independently of each other, so both the single- and combined-modifier forms are valid.API additions
Prop(name string) Modifier— returns the full__prop.namemodifier. Panics on empty name.Event(names ...string) Modifier— returns the full__event.a.b.cmodifier. Panics when no names or any empty name is given.ModifierDocumentconstantBind()now acceptsmodifiers ...Modifier(source-compatible with existing single-argument calls; alldemo/main.gocall sites unchanged)Usage
Other
docs/datastar.jsto v1.0.1AGENTS.mdcompatibility note to v1.0.1Runtime-only v1.0.0/v1.0.1 changes (morphing, fetch behavior,
kebabfix,selectsignal-type fix,retryMaxWaitMsrename, Rocket rewrite) are out of scope for this library.Test plan
make testpasses (95.6% coverage)__prop,__event(single and multiple events), combined__prop+__event, and__documentProp(""),Event(), andEvent("x", "")BindPropRequiredWhenEventProvided/BindEventRequiredpairing constraint