Phenomenon
When using Chrome on Android with Samsung Keyboard Text Prediction ON, typing Korean at the boundary of a link (<a>) element causes the following structural issues:
- Forced Text Node Splitting: What should be a single continuous text node is physically split into two.
- Caret/Input Escape and Duplication (Leakage): The input value jumps out of the link, and the last character of the link is often duplicated into the new node (e.g., typing ‘Ma’ after ‘com’ results in ‘com’ + ‘mMa’).
- Loss of Composition Reference: The IME loses context between the link text and the new input, leading to the duplication and broken composition described above.
Reproduction Steps
- On a Samsung Galaxy device, open Chrome and enable ‘Predictive text’ in Samsung Keyboard settings.
- Create a link (
<a>Link</a>) within acontenteditableregion. - Place the caret at the very end of the link text.
- Type a Korean character (e.g., ‘안녕’).
Observed Behavior (Based on Zero Trace Log)
- Step 72 (beforeinput): The target ranges correctly point inside the
Atag during theinsertCompositionTextevent. - Step 73 (input): The moment the input is reflected in the DOM, the character (
ㅇ) is inserted into thePtag, outside theAtag. - As a result, the DOM structure becomes
<p><a>Link</a>ㅇ</p>, unintentionally breaking the link formatting.
Expected Behavior
- The typed character should remain within the text node at the end of the
<a>tag. - The text node should not split; new content should be merged into the existing node.
Circular Sync Normalization Points
- Normalization Cycle: Immediately after the
inputevent, if a node split is detected, the algorithm reconciles the state back to the Model’s truth (ID-based structure) by “rotating” the stray text back into the link. - Shadow Composition Tracking: Even if the browser splits the DOM, the Model treats it as a single node, ensuring a merged output in the next rendering cycle.