Firefox logs `MouseEvent.mozPressure` / `mozInputSource` deprecation warnings when Redact handles a click
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- playwright, react, typescript, vite
Hướng nghiên cứu
Bắt đầu với packages/redact/src/dom/synthetic-event.ts, đặc biệt là vòng lặp sao chép của createSyntheticEvent, rồi so sánh các interface sự kiện của nó với React DOM 19.3.1. Tái hiện vấn đề bằng bản Firefox được cung cấp và probe.mjs, sau đó thêm hoặc cập nhật phạm vi kiểm thử liên quan đến sự kiện tổng hợp. Hoàn thành khi một sự kiện nhấp chuột đã được hydrate bởi Redact hoạt động mà không đọc các getter không còn được hỗ trợ mozPressure hoặc mozInputSource của Firefox và không tạo cảnh báo trong console.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
In Firefox, the first click handled by a Redact onClick logs two deprecation warnings:
MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead.
MouseEvent.mozInputSource is deprecated. Use PointerEvent.pointerType instead.
The same page hydrated with React DOM 19.3.1 logs nothing.
The cause is that createSyntheticEvent copies every enumerable property of the native event, which calls Firefox's deprecated getters:
// packages/redact/src/dom/synthetic-event.ts, lines 15-20
// (identical in the 0.3.1 tarball and on main at 61ad375c)
for (const key in native) {
if (!(key in event)) {
const value = (native as any)[key]
event[key] = isFunction(value) ? value.bind(native) : value
}
}
In 0.3.1's dist/dom/synthetic-event.js, the same loop is at lines 24-29.
This also fails console checks that treat any warning as a failure. We hit it in a React Router framework-mode app whose Firefox browser tests reject unexpected console warnings.
Environment
@tanstack/redact0.3.1 (npm) andmainat61ad375c, built locallyreact/react-dom19.3.1,vite8.4.1, Node 26.13.1- Firefox 159.0 (Playwright 1.65.2), Windows 11 x64 (10.0.26300)
- Setup: server rendering with native
react-dom/server, hydration with Redact viaredact({ environments: ['client'] })
Reproduction
package.json:
{
"type": "module",
"dependencies": {
"@tanstack/redact": "0.3.1",
"react": "19.3.1",
"react-dom": "19.3.1",
"vite": "8.4.1"
}
}
vite.config.js:
import { redact } from '@tanstack/redact/vite'
// RUNTIME=redact: Redact in the browser. RUNTIME=react: the native React control.
const runtime = process.env.RUNTIME ?? 'redact'
export default ({ isSsrBuild }) => ({
plugins: !isSsrBuild && runtime === 'redact' ? [redact({ environments: ['client'] })] : [],
build: isSsrBuild
? { outDir: 'dist-ssr' }
: { outDir: `dist-${runtime}`, rollupOptions: { input: 'client.jsx', output: { entryFileNames: 'client.js' } } },
})
app.jsx:
import { useState } from 'react'
export function App() {
const [count, setCount] = useState(0)
return (
<button type="button" onClick={() => setCount(count + 1)}>
Clicked {count}
</button>
)
}
client.jsx:
import { hydrateRoot } from 'react-dom/client'
import { App } from './app.jsx'
hydrateRoot(document.getElementById('root'), <App />, {
identifierStrategy: 'react',
onRecoverableError: (error) => console.error('onRecoverableError:', error.message),
})
server.mjs (native react-dom/server):
// Usage: node server.mjs <client dir> <port>
import { readFile } from 'node:fs/promises'
import { createServer } from 'node:http'
import { createElement } from 'react'
import { renderToString } from 'react-dom/server'
import { App } from './dist-ssr/app.js'
const [clientDir, port = '4173'] = process.argv.slice(2)
createServer(async (request, response) => {
if (request.url === '/client.js') {
response.writeHead(200, { 'content-type': 'text/javascript' })
return response.end(await readFile(`${clientDir}/client.js`))
}
const html = renderToString(createElement(App))
response.writeHead(200, { 'content-type': 'text/html' })
response.end(`<!doctype html><html><body><div id="root">${html}</div><script type="module" src="/client.js"></script></body></html>`)
}).listen(Number(port), '127.0.0.1')
probe.mjs (needs playwright with Firefox installed):
import { firefox } from 'playwright'
const browser = await firefox.launch()
const page = await browser.newPage()
const messages = []
page.on('console', (message) => messages.push(`${message.type()}: ${message.text()}`))
await page.goto('http://127.0.0.1:4173/')
await page.waitForTimeout(1000)
await page.click('button')
await page.waitForTimeout(1000)
console.log({ button: await page.textContent('button'), console: messages })
await browser.close()
Steps
npm install
RUNTIME=redact npx vite build && RUNTIME=react npx vite build && npx vite build --ssr app.jsx
node server.mjs dist-redact 4173 # then, in another shell: node probe.mjs
node server.mjs dist-react 4173 # control, then: node probe.mjs
Expected
One click, no console output. This is what React DOM 19.3.1 does:
{ button: 'Clicked 1', console: [] }
Actual (Redact 0.3.1, and main at 61ad375c)
The click works, but Firefox logs two warnings that point at Redact's bundle:
{
button: 'Clicked 1',
console: [
'warning: [JavaScript Warning: "MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead." {file: "http://127.0.0.1:4173/client.js" line: 1}]',
'warning: [JavaScript Warning: "MouseEvent.mozInputSource is deprecated. Use PointerEvent.pointerType instead." {file: "http://127.0.0.1:4173/client.js" line: 1}]'
]
}
A client-only createRoot version of the same button logged the same two warnings under Redact and none under React DOM.
Suggested fix
Copy only the properties React's synthetic events expose, per event type, instead of every enumerable property of the native event:
- React's documented interface. The React event object exposes
bubbles,cancelable,currentTarget,defaultPrevented,eventPhase,isTrusted,target,timeStamp,nativeEvent, pluspreventDefault,stopPropagation,isDefaultPrevented,isPropagationStopped,persistandisPersistent. Mouse events addaltKey,button,buttons,ctrlKey,clientX,clientY,getModifierState,metaKey,movementX,movementY,pageX,pageY,relatedTarget,screenX,screenY,shiftKey, and the inherited UIEventdetailandview(react.dev, React event object and MouseEvent handler). - React's implementation. React DOM 19.3.1 builds synthetic events from per-type interfaces and copies only the interface's keys:
for (const propName in Interface)inpackages/react-dom-bindings/src/events/SyntheticEvent.js(MouseEventInterfaceat line 192).
Anything outside that set stays reachable through e.nativeEvent.
Related
- #98 and PR #113 change the same loop for a different reason: happy-dom's non-enumerable
Eventfields. #113's diff walks the prototype chain withObject.getOwnPropertyNames. I have not tested it, but because these getters are onMouseEvent, that approach looks likely to keep reading them. An interface-based copy would serve both issues. - Searched open and closed issues and PRs on 5/12/2026 for
mozPressure,mozInputSource,deprecated,Firefox warning,synthetic event,SyntheticEventandnativeEvent properties. Nothing covers these warnings.
- Ngôn ngữ chính
- TypeScript
- Star
- 640
- Fork
- 32
- Merge trung bình
- 1 giờ 15 phút
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/redact
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TanStack/redact#142 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
TanStack/redact#196 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/redact
Issue tương tự
-
bug data-types
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: middleware enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
agent/quality testing
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
Maintainer thường phản hồi trong vòng 1 ngày
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
juspay/agent-distro#203 ·
Maintainer thường phản hồi trong vòng 1 ngày