developit / developit/undom

Problem with spies

Abierto
#35 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
690
Forks
25
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I'm trying to spy on `removeChild` in a test - I have a `parent` node being modified like this:

```
let removals = 0;

let removeChild = parent.removeChild.bind(parent);

parent.removeChild = (child) => {
removals += 1;
return removeChild(child);
};
```

To my surprise, it was counting way too many calls to `removeChild`.

It turns out, several of these methods are being called internally, for brevity.

The real DOM does not call it's own public methods, afaik? If it needs to remove children for other reasons than calls to `removeChild`, it does not internally call the method, it just removed them.

How would you feel about moving the internally reused methods to private methods?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.