`addIconToElement` disposable should revert DOM modifications
See original GitHub issueI’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:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
Awesome! So is v2.1.4. Thanks for that! 🙏