Skip to content

Commit bebf0c8

Browse files
committed
Merge branch 'main' of github.com:/reasonml/reason-react into melange-5-support
* 'main' of github.com:/reasonml/reason-react: feat(react-dom): add experimental module (#849) add color to domProps (#871) Remove most React.Uncurried from tests (but keep 1) (#890) fix melange dep Revert support for "custom children" in uppercase components (#891) ci: update nix action (#888)
2 parents 101161c + c7679f6 commit bebf0c8

File tree

8 files changed

+351
-36
lines changed

8 files changed

+351
-36
lines changed

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- uses: cachix/install-nix-action@v27
17+
- uses: cachix/install-nix-action@v31
1818
with:
1919
extra_nix_config: |
2020
extra-substituters = https://anmonteiro.nix-cache.workers.dev

CHANGES.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Unreleased
22

3-
* BREAKING, ppx: Allow passing an array of custom children to a component
4-
without having to wrap in array literal ([@jchavarri in #748](https://github.com/reasonml/reason-react/pull/823))
5-
63
# 0.15.0
74

85
* Add `isValidElement` (@r17x in

ppx/reason_react_ppx.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,7 @@ let jsxExprAndChildren ~component_type ~loc ~ctxt mapper ~keyProps children =
487487
children *)
488488
( Builder.pexp_ident ~loc { loc; txt = Ldot (ident, "jsxs") },
489489
None,
490-
Some
491-
(match component_type with
492-
| Uppercase -> children
493-
| Lowercase -> Binding.React.array ~loc children) )
490+
Some (Binding.React.array ~loc children))
494491
| None, (label, key) :: _ ->
495492
( Builder.pexp_ident ~loc { loc; txt = Ldot (ident, "jsxKeyed") },
496493
Some (label, key),

ppx/test/upper.t/run.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
let upper_children_single = foo =>
55
React.jsx(Upper.make, Upper.makeProps(~children=foo, ()));
66
let upper_children_multiple = (foo, bar) =>
7-
React.jsxs(Upper.make, Upper.makeProps(~children=[|foo, bar|], ()));
7+
React.jsxs(
8+
Upper.make,
9+
Upper.makeProps(~children=React.array([|foo, bar|]), ()),
10+
);
811
let upper_children =
912
React.jsx(
1013
Page.make,

src/ReactDOM.re

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,91 @@ external unmountComponentAtNode: Dom.element => unit =
477477
[@mel.module "react-dom"]
478478
external flushSync: (unit => unit) => unit = "flushSync";
479479

480+
module Experimental = {
481+
type preloadOptions;
482+
483+
[@mel.obj]
484+
external preloadOptions:
485+
(
486+
~_as: [
487+
| `audio
488+
| `document
489+
| `embed
490+
| `fetch
491+
| `font
492+
| `image
493+
| [@mel.as "object"] `object_
494+
| `script
495+
| `style
496+
| `track
497+
| `video
498+
| `worker
499+
],
500+
~fetchPriority: [ | `auto | `high | `low]=?,
501+
~referrerPolicy: [
502+
| [@mel.as "no-referrer"] `noReferrer
503+
| [@mel.as "no-referrer-when-downgrade"]
504+
`noReferrerWhenDowngrade
505+
| [@mel.as "origin"] `origin
506+
| [@mel.as "origin-when-cross-origin"]
507+
`originWhenCrossOrigin
508+
| [@mel.as "unsafe-url"] `unsafeUrl
509+
]
510+
=?,
511+
~imageSrcSet: string=?,
512+
~imageSizes: string=?,
513+
~crossOrigin: string=?,
514+
~integrity: string=?,
515+
~nonce: string=?,
516+
unit
517+
) =>
518+
preloadOptions;
519+
520+
[@deriving jsProperties]
521+
type preinitOptions = {
522+
[@mel.as "as"]
523+
_as: [ | `script | `style],
524+
[@mel.optional]
525+
fetchPriority: option([ | `auto | `high | `low]),
526+
[@mel.optional]
527+
precedence: option([ | `reset | `low | `medium | `high]),
528+
[@mel.optional]
529+
crossOrigin: option(string),
530+
[@mel.optional]
531+
integrity: option(string),
532+
[@mel.optional]
533+
nonce: option(string),
534+
};
535+
536+
[@deriving jsProperties]
537+
type preOptions = {
538+
[@mel.as "as"]
539+
_as: [ | `script],
540+
[@mel.optional]
541+
crossOrigin: option(string),
542+
[@mel.optional]
543+
integrity: option(string),
544+
[@mel.optional]
545+
nonce: option(string),
546+
};
547+
548+
[@mel.module "react-dom"] external preconnect: string => unit = "preconnect";
549+
[@mel.module "react-dom"]
550+
external prefetchDNS: string => unit = "prefetchDNS";
551+
[@mel.module "react-dom"]
552+
external preinit: (string, ~options: preinitOptions=?, unit) => unit =
553+
"preinit";
554+
[@mel.module "react-dom"]
555+
external preinitModule: (string, ~options: preOptions=?, unit) => unit =
556+
"preinitModule";
557+
[@mel.module "react-dom"]
558+
external preload: (string, ~options: preloadOptions=?, unit) => unit =
559+
"preload";
560+
[@mel.module "react-dom"]
561+
external preloadModule: (string, ~options: preOptions=?, unit) => unit =
562+
"preloadModule";
563+
};
564+
480565
external domElementToObj: Dom.element => Js.t({..}) = "%identity";
481566

482567
type style = Style.t;
@@ -1066,6 +1151,8 @@ type domProps = {
10661151
[@mel.optional]
10671152
clipRule: option(string),
10681153
[@mel.optional]
1154+
color: option(string),
1155+
[@mel.optional]
10691156
colorInterpolation: option(string),
10701157
[@mel.optional]
10711158
colorInterpolationFilters: option(string),

src/ReactDOM.rei

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,169 @@ external unmountComponentAtNode: Dom.element => unit =
478478
[@mel.module "react-dom"]
479479
external flushSync: (unit => unit) => unit = "flushSync";
480480

481+
module Experimental: {
482+
/* This module is used to bind to APIs for future versions of ReactDOM. There is no guarantee of backwards compatibility or stability. */
483+
/*
484+
preload options.
485+
https://react.dev/reference/react-dom/preload#parameters
486+
*/
487+
type preloadOptions;
488+
489+
[@mel.obj]
490+
external preloadOptions:
491+
/* Its possible values are audio, document, embed, fetch, font, image, object, script, style, track, video, worker. */
492+
(
493+
~_as: [
494+
| `audio
495+
| `document
496+
| `embed
497+
| `fetch
498+
| `font
499+
| `image
500+
| [@mel.as "object"] `object_
501+
| `script
502+
| `style
503+
| `track
504+
| `video
505+
| `worker
506+
],
507+
/*
508+
Suggests a relative priority for fetching the resource.
509+
The possible values are auto (the default), high, and low.
510+
*/
511+
~fetchPriority: [ | `auto | `high | `low]=?,
512+
/*
513+
The Referrer header to send when fetching.
514+
Its possible values are no-referrer-when-downgrade (the default), no-referrer, origin, origin-when-cross-origin, and unsafe-url.
515+
*/
516+
~referrerPolicy: [
517+
| [@mel.as "no-referrer"] `noReferrer
518+
| [@mel.as "no-referrer-when-downgrade"]
519+
`noReferrerWhenDowngrade
520+
| [@mel.as "origin"] `origin
521+
| [@mel.as "origin-when-cross-origin"]
522+
`originWhenCrossOrigin
523+
| [@mel.as "unsafe-url"] `unsafeUrl
524+
]
525+
=?,
526+
/*
527+
For use only with as: "image". Specifies the source set of the image.
528+
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
529+
*/
530+
~imageSrcSet: string=?,
531+
/*
532+
For use only with as: "image". Specifies the source sizes of the image.
533+
https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
534+
*/
535+
~imageSizes: string=?,
536+
/*
537+
a required string. It must be "anonymous", "use-credentials", and "".
538+
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
539+
*/
540+
~crossOrigin: string=?,
541+
/*
542+
A cryptographic hash of the module, to verify its authenticity.
543+
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
544+
*/
545+
~integrity: string=?,
546+
/*
547+
A cryptographic nonce to allow the module when using a strict Content Security Policy.
548+
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
549+
*/
550+
~nonce: string=?,
551+
unit
552+
) =>
553+
preloadOptions;
554+
555+
/*
556+
preinit options.
557+
https://react.dev/reference/react-dom/preinit#parameters
558+
*/
559+
[@deriving jsProperties]
560+
type preinitOptions = {
561+
/* possible values: "script" or "style" */
562+
[@mel.as "as"]
563+
_as: [ | `script | `style],
564+
/*
565+
Suggests a relative priority for fetching the resource.
566+
The possible values are auto (the default), high, and low.
567+
*/
568+
[@mel.optional]
569+
fetchPriority: option([ | `auto | `high | `low]),
570+
/*
571+
Required with Stylesheets (`style). Says where to insert the stylesheet relative to others.
572+
Stylesheets with higher precedence can override those with lower precedence.
573+
The possible values are reset, low, medium, high.
574+
*/
575+
[@mel.optional]
576+
precedence: option([ | `reset | `low | `medium | `high]),
577+
/*
578+
a required string. It must be "anonymous", "use-credentials", and "".
579+
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
580+
*/
581+
[@mel.optional]
582+
crossOrigin: option(string),
583+
/*
584+
A cryptographic hash of the module, to verify its authenticity.
585+
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
586+
*/
587+
[@mel.optional]
588+
integrity: option(string),
589+
/*
590+
A cryptographic nonce to allow the module when using a strict Content Security Policy.
591+
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
592+
*/
593+
[@mel.optional]
594+
nonce: option(string),
595+
};
596+
597+
/*
598+
preinitModule and preloadModule options.
599+
https://react.dev/reference/react-dom/preinitModule#parameters
600+
https://react.dev/reference/react-dom/preloadModule#parameters
601+
*/
602+
[@deriving jsProperties]
603+
type preOptions = {
604+
/* It must be 'script'. */
605+
[@mel.as "as"]
606+
_as: [ | `script],
607+
/*
608+
a required string. It must be "anonymous", "use-credentials", and "".
609+
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
610+
*/
611+
[@mel.optional]
612+
crossOrigin: option(string),
613+
/*
614+
A cryptographic hash of the module, to verify its authenticity.
615+
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
616+
*/
617+
[@mel.optional]
618+
integrity: option(string),
619+
/*
620+
A cryptographic nonce to allow the module when using a strict Content Security Policy.
621+
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
622+
*/
623+
[@mel.optional]
624+
nonce: option(string),
625+
};
626+
627+
[@mel.module "react-dom"] external preconnect: string => unit = "preconnect";
628+
[@mel.module "react-dom"]
629+
external prefetchDNS: string => unit = "prefetchDNS";
630+
[@mel.module "react-dom"]
631+
external preinit: (string, ~options: preinitOptions=?, unit) => unit =
632+
"preinit";
633+
[@mel.module "react-dom"]
634+
external preinitModule: (string, ~options: preOptions=?, unit) => unit =
635+
"preinitModule";
636+
[@mel.module "react-dom"]
637+
external preload: (string, ~options: preloadOptions=?, unit) => unit =
638+
"preload";
639+
[@mel.module "react-dom"]
640+
external preloadModule: (string, ~options: preOptions=?, unit) => unit =
641+
"preloadModule";
642+
};
643+
481644
external domElementToObj: Dom.element => Js.t({..}) = "%identity";
482645

483646
type style = Style.t;
@@ -1067,6 +1230,8 @@ type domProps = {
10671230
[@mel.optional]
10681231
clipRule: option(string),
10691232
[@mel.optional]
1233+
color: option(string),
1234+
[@mel.optional]
10701235
colorInterpolation: option(string),
10711236
[@mel.optional]
10721237
colorInterpolationFilters: option(string),

0 commit comments

Comments
 (0)