Phenomenon
When removing formatting from text that has nested formatting (e.g., <b><i>text</i></b>), empty or partial formatting elements may be left in the DOM. The structure becomes broken.
Reproduction example
- Apply bold and italic to text:
<b><i>formatted text</i></b> - Remove bold formatting
- Observe the DOM structure
Observed behavior
- Empty
<b></b>elements may remain - Or partial nesting may remain:
<b><i>text</i></b>becomes<i>text</i>but<b>wrapper may remain - DOM structure becomes broken
- Empty elements accumulate
Expected behavior
- Formatting should be removed cleanly
- No empty elements should remain
- Structure should be normalized
- DOM should be clean
Browser Comparison
- Chrome/Edge: May leave empty elements (this case)
- Firefox: More likely to leave empty structures
- Safari: Most likely to leave broken structures
Notes and possible direction for workarounds
- Normalize formatting structure after removal
- Remove empty formatting elements
- Merge or unwrap nested structures
- Clean up DOM regularly