arimgibson / Deadname-Remover

An easy to use Firefox and Chrome plugin to automatically remove and replace deadnames
MIT License
120 stars 30 forks source link

Fix bug with elements that have both text nodes and child elements #467

Closed scratchyone closed 2 years ago

scratchyone commented 2 years ago

Previously, the extension would set the parent innerHTML to update a child text node. If the parent had other child elements as well as the text node, the child elements would be inadvertently deleted. I've noticed this causing issues on a few websites.

This PR fixes that by instead modifying the text nodes nodeValue. If highlighting is enabled, the new behavior is instead to create a new empty element, replace the old element with it, and then set the outerHTML of the new element to newText, which has the outcome of replacing the text node in place with a new mark element.

This PR also fixes an unrelated issue that was causing thousands of mark tags to be generated because replaceText would wrap every item in oldWords in another set of mark tags every time it was called.

scratchyone commented 2 years ago

hi, just pinging @WillHayCode for visibility since this bug causes problems on a fair amount of websites

scratchyone commented 2 years ago

From what I can tell from the issue descriptions, this PR should also close https://groups.google.com/u/3/g/deadname-remover/c/UxI06q2pyD0, #339, and https://groups.google.com/u/3/g/deadname-remover/c/llOhITI0hAY.

arimgibson commented 2 years ago

Hi @scratchyone ! I recently took over maintenance of this extension and wanted to follow up and let you know I'm planning on reviewing this PR within the next couple days. I appreciate your contribution and will be in touch here!

arimgibson commented 2 years ago

This looks great @scratchyone , thanks for the PR! Adding this into a 2.0.0 branch; hoping to push a good number of commits as part of that release, which includes refactoring code. For the time being, I'm planning on not commiting to master and putting effort into that 2.0.0 release.

If you've got capacity and interest in being a co-maintainer, definitely let me know! Especially during this transition phase, I'm trying to find a good way to balance the workload of this repo with my schedule 😜