Skip to content

bind: preserve Binder behavior through numeric float64 conversion #254

Description

@linkdata

Problem

bind.MakeSetterFloat64 must adapt Setter[T] to Setter[float64] when T is an integer type, float32, or uintptr. The current conversion adapter embeds only Setter[T], so jaws.Element.ApplyGetter cannot see the additional interfaces guaranteed by Binder[T], including click, context-menu, and initial-attribute handling.

For example, the initial attribute is silently omitted:

rw.Number(bind.New(&mu, &n).InitialHTMLAttr(fn))

The in-tree Binder also intentionally implements bind.HTMLGetter; adapting it currently hides Format/GetHTML behavior if the adapted value is later reused as HTML content.

Constraints

  • An existing Setter[float64] should remain an exact pass-through. Wrapping it changes its identity and dynamic interface set, including HTMLGetter, and cannot be generally transparent in Go.
  • A plain converted Setter[T] must not acquire event-handler interfaces it does not implement. Handler-interface presence affects registration and frozen-element behavior even when a proxy returns jaws.ErrEventUnhandled.
  • Non-finite and range validation remains necessary before converting a float64 write to integer or float32 storage.
  • ui.Number, ui.Range, and ui.InputFloat already enforce finite values at the UI boundary. This issue should not impose finite-only semantics on an arbitrary Setter[float64].
  • Read-only and static adapters must retain their documented bind.ErrValueNotSettable behavior.

Expected behavior

Preserve documented Binder behavior through the unavoidable numeric conversion without claiming that an arbitrary wrapper can preserve every optional interface. One possible implementation is a Binder-specific conversion adapter that embeds Binder[T] and overrides only JawsGet and JawsSet, with a variant preserving HTMLGetter when the source exposes it.

Plain Setter[T] values can continue using the value/tag conversion adapter and must remain non-handlers unless they already expose handler behavior through an explicitly supported path.

Tests

  • Exact Setter[float64] values pass through unchanged and retain formatting, tags, handlers, and attributes.
  • Converted Binder values retain their bound-pointer tag, initial attributes, click/context-menu behavior, and in-tree HTMLGetter formatting.
  • Converted plain setters do not become event handlers and remain safe on the documented post-Element.Freeze non-handler path.
  • Integer and float32 adapters continue rejecting non-finite and out-of-range writes.
  • Wide-integer canonical round-trip and reconciliation behavior remains unchanged.

Context

Follow-up to #245. That PR attempted to make a general wrapper transparent and to sanitize exact float64 setters; the approach changes optional-interface semantics and breaks supported Binder composition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions