Skip to content

Use precise native style updates in @taffyjs/yoga #16

Description

@hyfdev

Context

@taffyjs/node currently applies setStyle(node, input) as a complete Style replacement. To preserve Yoga's per-property setter semantics, @taffyjs/yoga keeps the complete logical Yoga declaration state, translates it into a complete Taffy Style, and replaces the native Style after each supported setter.

This is semantically correct, but it converts and writes unaffected native fields. @taffyjs/node is gaining an API for precise style-field updates.

Follow-up

Once that API is available:

  • use it for the ordinary @taffyjs/yoga setter path, updating only the Taffy fields affected by the changed Yoga declaration;
  • handle setters that expand to multiple Taffy fields, such as logical edges and the flex shorthand, as one precise derived update;
  • retain the complete logical Yoga declaration state as the source of truth because translated Taffy Style is lossy and cannot reconstruct every Yoga declaration;
  • retain complete Style replacement where it is semantically appropriate, such as initialization, reset, copy, or a broad Config/direction retranslation;
  • preserve current public behavior, getter semantics, dirty behavior, failure atomicity, and Yoga-oracle compatibility.

Acceptance criteria

  • Sequential property setters do not reset unrelated declarations and continue to match Yoga 3.2.1 behavior.
  • Declared-style getters still read the current Yoga declaration state; computed layout remains derived by Taffy.
  • Unsupported or invalid setters still fail without partially updating either state representation.
  • The normal property-setter path no longer rebuilds and replaces a complete native Style when a precise update is sufficient.

This is an internal synchronization optimization, not a public API change to @taffyjs/yoga.

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