developit / developit/undom

Problem with spies

Open
#35 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
690
Forks
25
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the implementation of parent.removeChild and trace the other DOM methods that invoke it internally. Identify the internally reused operations that should bypass public methods, then verify that explicit removeChild calls remain observable while internal removals no longer inflate the count.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.