-
Notifications
You must be signed in to change notification settings - Fork 121
fix(react/runtime): export correct cloneElement
on main-thread
#1508
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
d44d3a5
04d2172
790fe0d
6868abd
15f8838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@lynx-js/react": patch | ||
--- | ||
|
||
Fix `cloneElement` and `createElement` not working correctly on the main thread. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2024 The Lynx Authors. All rights reserved. | ||
// Licensed under the Apache License Version 2.0 that can be found in the | ||
// LICENSE file in the root directory of this source tree. | ||
export { cloneElement, createElement } from 'react'; | ||
export { cloneElement, createElement } from 'preact/compat'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2025 The Lynx Authors. All rights reserved. | ||
// Licensed under the Apache License Version 2.0 that can be found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
import { cloneElement as preactCloneElement } from 'preact/compat'; | ||
|
||
import { cloneElement as mainThreadCloneElement } from '../lepus/index.js'; | ||
|
||
export const cloneElement: typeof import('preact/compat').cloneElement = /*#__PURE__*/ (() => { | ||
if (__BACKGROUND__) { | ||
return preactCloneElement; | ||
} else { | ||
return mainThreadCloneElement; | ||
} | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2025 The Lynx Authors. All rights reserved. | ||
// Licensed under the Apache License Version 2.0 that can be found in the | ||
// LICENSE file in the root directory of this source tree. | ||
import { createElement as preactCreateElement } from 'preact/compat'; | ||
|
||
import { createElement as mainThreadCreateElement } from '../lepus/index.js'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify lepus.createElement also accepts and forwards variadic children To maintain parity, ensure 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "createElement signature in lepus runtime:"
rg -nP -C2 'export\s+function\s+createElement\s*\(' packages/react/runtime/lepus/index.js || true
echo
echo "Look for rest-children usage and forwarding:"
rg -nP -C2 '\.\.\.children|createElement\([^)]*,[^)]*,\s*\.\.\.children' packages/react/runtime/lepus/index.js || true Length of output: 562 Action: Make lepus.createElement accept and forward variadic children Found: packages/react/runtime/lepus/index.js declares What to change:
Suggested diff:
🤖 Prompt for AI Agents
|
||
|
||
export const createElement: typeof import('preact/compat').createElement = /*#__PURE__*/ (() => { | ||
if (__BACKGROUND__) { | ||
return preactCreateElement; | ||
} else { | ||
return mainThreadCreateElement; | ||
} | ||
})(); |
Uh oh!
There was an error while loading. Please reload this page.