Skip to content

Problem with spies #35

Description

@mindplay-dk

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions