Skip to content

Type Editor


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

Function: isIE11NonBreakingSpaceBug()

ts
function isIE11NonBreakingSpaceBug(change, parse): boolean;

Defined in: browser-hacks/is-ie11-non-breaking-space-bug.ts:30

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.

Parameters

ParameterTypeDescription
changeDocumentChangeThe detected document change
parseParseBetweenResultParsed document information containing the document content for checking the surrounding characters

Returns

boolean

True if this matches the IE11 nbsp bug pattern and adjustment is needed, false otherwise