Skip to content

Add slot attribute to JsxDom props #7402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hellos3b
Copy link
Contributor

@hellos3b hellos3b commented Apr 22, 2025

This adds the slot attribute to the JsxDom props which is commonly used in web component libraries that use the shadow dom.

MDN Reference

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/slot

Sample

<div slot="content">
  <MyReactComponent/>
</div>

Workaround

Have been using this as a workaround for a while before I realized I can contribute myself

module Slot = {
  @react.component
  let make = (~children: React.element, ~slot: string) =>
    React.cloneElement(children, Obj.magic({"slot": slot}))
}

<Slot slot="content">
  <div>
    <MyReactComponent/>
  </div>
</Slot>

@nojaf
Copy link
Collaborator

nojaf commented Apr 23, 2025

Hello, thanks for this contribution!

Could you run:

make lib
make build
make test-analysis

to update the failing test!

@hellos3b
Copy link
Contributor Author

@nojaf Dang yeah thought I could get away with git editor. Will get things set up and do it more properly

@nojaf
Copy link
Collaborator

nojaf commented Apr 23, 2025

No worries! Just a quick tip for next time: please use a different branch for your PR if possible. I fixed this locally, but I wasn't able to push to your branch since it is the default one.

@hellos3b
Copy link
Contributor Author

hellos3b commented Apr 23, 2025

@nojaf I may need to resubmit off a new branch, went through CONTRIBUTION.md but having trouble with the make commands -- any chance you recognize this error

> python --version
Python 3.11.0
> opam --version
2.3.0
> make lib
./scripts/buildRuntime.sh
TypeError: Cannot read properties of undefined (reading 'toString')
    at acquireBuild (file:///www.github.com/rescript-compiler/cli/common/bsb.js:57:53)
    at delegate (file:///www.github.com/rescript-compiler/cli/common/bsb.js:76:12)
    at Module.clean (file:///www.github.com/rescript-compiler/cli/common/bsb.js:112:3)
    at file:///www.github.com/rescript-compiler/cli/rescript.js:111:11
    at ModuleJob.run (node:internal/modules/esm/module_job:274:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5)
Error: spawn /www.github.com/rescript-compiler/darwinarm64/rescript.exe ENOENT
make: *** [lib] Error 2
// @
fs.writeFileSync(lockFileName, ownerProcess.pid.toString(), {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants