selection.data() throws TypeError when selection is created from a DOM element

Abierto
#324 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
56/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
javascript
Área
frontend

Línea de trabajo

Start by reproducing the failure in d3-selection 3.0.0 with the DOM element example in the issue, then trace how .data() reaches EnterNode and bindIndex in the reported stack. Compare that path with selection from '#app' and identify why the element-created selection lacks the expected document reference. Done means both examples complete without the TypeError and the behavior is covered by a regression test.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

Calling data() on a selection created from a DOM element appears to fail when D3 attempts to create EnterNodes.
The following works:

d3.select('#app').data([1, 2, 3, 4]);

but the equivalent selection created from the DOM element itself throws:

d3.select(document.getElementById('app')).data([1, 2, 3, 4]);

Uncaught TypeError: Cannot read properties of null (reading 'ownerDocument') at new EnterNode (d3-selection.js?v=2f31b0b4:142:30) at bindIndex (d3-selection.js?v=2f31b0b4:177:20)...

Shouldn't both snippets result in indentical execution?

Reproduction

<div id="app"></div>
<script>
  d3.select(document.getElementById('app'))
    .data([1, 2, 3, 4]);
</script>

Environment

d3-selection : 3.0.0
browser : Chrome Version 147.0.7727.55 (Official Build) (64-bit)

Lenguaje dominante
JavaScript
Estrellas
571
Forks
283
Merge medio
7 h
PR fusionados (30 d)
1

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de d3/d3-selection

Todos los issues de d3/d3-selection

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.