Skip to content

Fix Style::operator== ignoring boxSizing - #2029

Open
kwy404 wants to merge 1 commit into
react:mainfrom
kwy404:fix-style-equality-box-sizing
Open

kwy404 wants to merge 1 commit into
react:mainfrom
kwy404:fix-style-equality-box-sizing

Conversation

@kwy404

@kwy404 kwy404 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Summary

yoga::Style::operator== compares every style field except boxSizing_ (the field was added in #1701 but never added to the comparison). Two styles that only differ in box sizing therefore compare equal.

Effects:

  • YGNodeCopyStyle(dst, src) only copies when dst->style() != src->style(). If src only differs in box sizing, nothing is copied and dst keeps its old box sizing without being marked dirty.
  • Code that compares styles to decide whether a node needs layout misses the change. For example React Native's YogaLayoutableShadowNode::updateYogaProps only dirties the node when styleResult != yogaNode_.style(), so a prop update that only changes boxSizing is not detected there.

The fix compares boxSizing_ together with the other enum fields.

Changelog: [General][Fixed] - Fix YGNodeCopyStyle and style equality ignoring boxSizing

Test Plan

Added copy_style_box_sizing to tests/YGStyleTest.cpp. It copies a style that only sets YGBoxSizingContentBox onto a default node.

Before the fix:

[ RUN      ] YogaTest.copy_style_box_sizing
tests/YGStyleTest.cpp(60): error: Expected equality of these values:
  YGBoxSizingContentBox
    Which is: 1
  YGNodeStyleGetBoxSizing(node0)
    Which is: 0
[  FAILED  ] YogaTest.copy_style_box_sizing (0 ms)

After the fix it passes, and the full C++ suite (MSVC 2022 + Ninja) passes: 855 tests. clang-format 21.1.2 (the version pinned in scripts/clang-format) reports no changes.

`Style::operator==` compares every style field except `boxSizing_`, so two
styles that only differ in box sizing compare equal. `YGNodeCopyStyle` then
skips the copy and leaves the destination node with the old box sizing, and
callers that compare styles to decide whether a node needs relayout miss the
change.

Compare `boxSizing_` together with the other enum fields.
@meta-cla meta-cla Bot added the CLA Signed label Sep 26, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant