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.

`addIconToElement` disposable should revert DOM modifications

See original GitHub issue

I’m looking at potentially bringing file-icons support back to Nuclide (https://github.com/facebook/nuclide/issues/951 – sorry for the long delay).

Since Nuclide uses React, DOM nodes for file names get re-used very frequently, eg. in quick-open and in the file-tree. I’ve built a React wrapper that applies addIconToElement to the underlying DOM nodes whenever the path changes. However, the disposable returned from addIconToElement does not reset the classnames applied by addIconToElement to the DOM node. I think it would be cleaner if the disposable not only removed references to the attached node from file-icons, but actually reverted all DOM side-effects caused by addIconToElement.

console.log(element.className);
// 'initial-classname'

const disposable = addIconToElement(element, 'foo.js');
console.log(element.className);
// 'initial-classname js-icon medium-yellow'

disposable.dispose();
console.log(element.className);
// CURRENT: 'initial-classname js-icon medium-yellow'
// IDEAL: 'initial-classname'

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
jgebhardtcommented, Apr 22, 2017

@Alhadis just a heads-up, next weeks’ Nuclide release will include the file-icons compatibility fixes (and it looks really nice; thanks for all your work on this!)

We usually release Tuesday afternoon-ish (PST), ±24h.

1reaction
Alhadiscommented, Apr 25, 2017

Awesome! So is v2.1.4. Thanks for that! 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

file-tree not support file-icons..... · Issue #951 - GitHub
really hope both your guys can make some standard to fix it. ... addIconToElement disposable should revert DOM modifications ...
Read more >
Undo dom changes in JS - javascript - Stack Overflow
I am writing a custom HTML editor. User can edit an entire HTML content and the changes will be updated in DOM. We...
Read more >
Summary: DOM modification techniques - Khan Academy
We covered various ways that you can modify aspects of an existing element: · You can set an attribute on an element by...
Read more >
Detect, Undo And Redo DOM Changes With Mutation Observers
I've been wondering why DOM Mutation Observers, which can monitor changes to one or more DOM elements and return a report of what...
Read more >
How JavaScript works: tracking changes in the DOM using ...
In essence, it covers every single change that can possibly occur in the DOM and it's way more optimized as it fires the...
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