Skip to content

Type Editor


Type Editor / @type-editor/dom-change-util / browser-hacks/is-ie11-non-breaking-space-bug

browser-hacks/is-ie11-non-breaking-space-bug

Functions

FunctionDescription

isIE11NonBreakingSpaceBug

Checks if this is the IE11 non-breaking space bug.

IE11 has a quirk where typing a space before another space causes it to insert a non-breaking space (U+00A0) ahead of the cursor instead of a regular space at the cursor position. This can cause the change detection to be off by one character.

The bug is detected by checking:

  • Browser is IE11 or earlier
  • Change is exactly one character (endB - start === 1)
  • Change is a replacement (endA === start)
  • Change is not at the very start of the parsed range
  • The character before and after the change position is space + nbsp

When detected, the change positions are adjusted backwards by one to account for the nbsp being inserted in the wrong place.