Synthetic events drop non-enumerable fields (clipboardData/dataTransfer from Testing Library are undefined)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, react, typescript
Línea de trabajo
Empieza en src/dom/synthetic-event.ts, en createSyntheticEvent, y lee cómo copia los campos del evento nativo. Reproduce los valores que faltan de clipboardData o dataTransfer con el ejemplo de Vitest y Testing Library del issue. La tarea estará terminada cuando los handlers reciban esos valores en las pruebas y el comportamiento actual de los eventos sintéticos siga funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version: @tanstack/redact 0.2.2
createSyntheticEvent (src/dom/synthetic-event.ts) copies the native event's fields with for (const key in native). That only sees enumerable properties. Own properties defined with Object.defineProperty (non-enumerable by default) are dropped, so the handler gets undefined where React hands over the value.
In real browsers this is fine for native events: WebIDL attributes such as ClipboardEvent.clipboardData and DragEvent.dataTransfer are enumerable accessors on the prototype (checked in Chromium). It breaks for:
- Testing Library / jsdom:
fireEvent.paste(el, { clipboardData })andfireEvent.drop(el, { dataTransfer })assign those fields withObject.defineProperty, because jsdom has noClipboardEvent/DragEventdata. Paste and drop tests that pass under React fail under Redact. - Any library or app code that dispatches a plain
Eventand attaches data the same way.
Repro (Vitest + jsdom + Testing Library)
import { render, fireEvent } from "@testing-library/react";
it("handlers see non-enumerable event fields", () => {
let pasted: unknown;
const { getByRole } = render(
<textarea onPaste={(e) => { pasted = e.clipboardData?.getData("text/plain"); }} />,
);
fireEvent.paste(getByRole("textbox"), { clipboardData: { getData: () => "hello" } });
let dropped: unknown;
const { container } = render(<div onDrop={(e) => { dropped = e.dataTransfer?.getData("text"); }} />);
const ev = new Event("drop", { bubbles: true });
Object.defineProperty(ev, "dataTransfer", { value: { getData: () => "dropped" } });
container.firstChild!.dispatchEvent(ev);
expect(pasted).toBe("hello");
expect(dropped).toBe("dropped");
});
pasted |
dropped |
|
|---|---|---|
| React 19 | "hello" |
"dropped" |
| Redact 0.2.2 | undefined |
undefined |
Suggestion
Also copy own non-enumerable properties (Object.getOwnPropertyNames(native)), or read fields lazily from nativeEvent (a getter or Proxy fallback) the way React's per-interface getters read nativeEvent.clipboardData / dataTransfer directly.
Found while running a TanStack Start app's component tests (chat composer paste and image drop) under Redact.
- Lenguaje dominante
- TypeScript
- Estrellas
- 408
- Forks
- 13
- Merge medio
- 1 h 44 min
- PR fusionados (30 d)
- 21
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/redact
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
TanStack/redact#67 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Bug: jsx runtime doesn't apply defaultProps (breaks Recharts 2: "Could not find xAxis by id")Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TanStack/redact#58 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/redact
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
lichess-org/lila#22324 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsAbiertoep:WebGPU platform:web quantization
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/onnxruntime#33752 ·
Los mantenedores suelen responder en 2 días
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimAbiertobug entra-agent-id
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
fix(worker): keep normal prepare waiting states failure-freePosiblemente ocupada @LichKing-2234 la tomó hoy. Abiertoagent:codex priority:P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Los mantenedores suelen responder en 1 día
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingPosiblemente ocupada @Eapp1e la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
makecindy/cindy#7973 · 1 comentario ·
Los mantenedores suelen responder en 1 día