question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Junk input elements get created and never destroyed - bad garbage collection

See original GitHub issue

I apologize if this has been reported or addressed, but I couldn’t find a similar issue. I ran into an issue I initially thought was my fault in my React app not doing proper garbage collection, but then I reproduced it on your doc site materializecss.com.

I order to understand this, I think a pic is best, but basically hitting the Enter key on an input field produces an additional, hidden input (display: none) element, 3 at a time, each time you hit Enter and never gets destroyed.

<input type="text" data-dashlane_trigger_mutation="true" style="display: none;"> 

Screen-Shot-2019-05-28-at-9-26-43-PM

Expected Behavior

I would expect that these elements are destroyed on the next press of Enter if they are in fact needed at all.

Current Behavior

Pressing Enter produces 3 of these elements each time, seemingly indefinitely. Changing them from display: hidden to display: block produces a single input bottom line (the colored border). Screen-Shot-2019-05-28-at-9-32-52-PM

If this is intended behavior, I would suggest using a method that is not so wasteful; these could easily become a memory leak in an SPA.

Possible Solution

Maybe tie an event that checks for the existence of the elements and then uses remove() to destroy them. Something like:

function junk() {
  const garbage = document.querySelectorAll('[data-dashlane_trigger_mutation="true"]');
  if (garbage !== null) garbage.forEach((junk) => junk.remove())
}

Steps to Reproduce (for bugs)

  1. Go here: https://materializecss.com/text-inputs.html.
  2. Open the Chrome dev tools using Cmd + Option + I, right-click and Inspect or F12.
  3. Select Elements and scroll to the bottom (in dev tools, not on the page).
  4. Place your cursor in the “First Name” field in the first example.
  5. Press Enter and watch the junk fields get created at the bottom.

Context

The primary issue is the potential for other bugs, unintended behavior and resource usage. I will work around this by implementing something similar to my suggestion in my own app.

Your Environment

  • Version used: 1.0.0
  • Browser Name and version: Chrome Version 74.0.3729.169 (Official Build) (64-bit) (macOS)
  • Operating System and version (desktop or mobile): macOS 10.14.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
pyrhocommented, Jun 4, 2019

Hey guys, I’m representing Dashlane, that’s our bad sorry for the inconvenience we’ll make sure a fix is shipped with our next extension (soonish).

Thank you for the thorough user support ticket !

1reaction
DanielRufcommented, May 30, 2019

Regarding the bug with the extension, can you report it to the support of Dashlane?

Please let us keep updated regarding this if this is just a problem with their approach or if it is a general issue which affects more implementations and use cases so we can take a closer look and provide a solution for all use cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Garbage collection of unneeded event listeners in javascript
I am building a single page webapp. This means over a period of time I get new DOM elements, remove unneeded ones. For...
Read more >
Optimizing garbage collection in a high load .NET service
Most of the garbage collections are “stop-the-world” ones: they suspend all threads in the app. Actually, so-called background GC's pause all ...
Read more >
The 10 Most Common JavaScript Issues Developers Face
JavaScript's memory management (and, in particular, garbage collection) is largely based on the notion of object reachability.
Read more >
If nature doesn't need trash, neither do we - Grist
If nature doesn't need trash, neither do we. Natural systems evolve to be closed-loop and waste-free. Human ones should take a cue from ......
Read more >
Organized Trash Collection Report on Community Input and ...
In its most simple terms, organized trash collection is a system for collecting trash in which one or multiple trash haulers are authorized...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found