Repository navigation
Merge styles= into optional className and style correctly - #402
Merged
Merged
Conversation
The expansion only handled an optional incoming value. An existing ?className or ?style was concatenated as a plain string or style and handed back to the optional argument, so <div ?className styles=x /> failed to type-check. One merge now covers the four optional/required combinations; when either side is always present the attribute drops its ?. Binders are __incoming and __existing so a user value named x is not captured.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
davesnx
marked this pull request as ready for review
September 23, 2026 17:56
BenchmarksNo baseline from
|
This branch was successfully deployed
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.
Styles_attribute.expand_attributesmergesstyles=into an element's existingclassName/style, but it only handled the case where the incoming value is optional. When the element already carried?classNameor?style, the merge concatenated thestring optionas a string and passed a plain value to the optional argument:which does not type-check.
?style styles=xdid the same throughReactDOM.Style.combine. The branch that did work also used a barexbinder, so<div className=x styles=?y />expanded toSome x -> x ^ " " ^ xand captured the user's value.merge_classNameandmerge_styleare now onemergeover the four optional/required combinations:incoming ^ " " ^ existing(orStyle.combine existing incoming).?and matches the existing option.Generated binders are
__incoming/__existing, following the reserved-name convention the Writer uses.styled-ppx consumes this library for its own
styles=handling (packages/ppx/src/dunelistsserver-reason-react.styles-attribute), so it picks the fix up with the next server-reason-react release; nothing to change there. #401 builds on the same helper forpartand should be rebased onto this.Tests
At 8513c32, OCaml 5.4.0, quickjs 0.5.1, melange 7.0.1, ocamlformat 0.28.1:
dune build @packages/styles-attribute/runtest: 10 tests; four new ones cover the optional-existing, optional-incoming, and both-optional shapes forclassNameandstyle.dune build @packages/server-reason-react-ppx/runtest: 69 tests;styles.tgains<div ?className styles=x />,<div ?style styles=x />and<div ?className styles=?x />in native and Melange mode, snapshot promoted and reviewed.dune build @runtest: all suites pass exceptpackages/router/test/browser, which needsnpm installin the checkout.ocamlformat --checkon the touched.mlfiles: clean.Risk: two-way door. Reverting restores the old merge for the required+required and required+optional shapes, which were the only ones that compiled. Output for those shapes changes only in binder names and an added
let.