<div contenteditable id="container">
this <a contenteditable="false">link</a> after
</div>
<p>1. Make the selection like "this link after|".</p>
<p>2. Click button to move the caret by line.</p>
<button>Move</button>
<script>
document.querySelector('button').addEventListener('click', (event) => {
document.getElementById('container').focus();
const selection = window.getSelection();
selection.modify('move', 'backward', 'paragraphboundary');
});
</script>
The behavior of browsers:
Safari, Edge, and Chrome: The caret position is this link| after.
Firefox: Not support the granularity of paragraphboundary.
If we make a to be editable, the behavior of browsers:
Safari, Edge, and Chrome: The caret position is |this link after.
Firefox: Not support the granularity of paragraphboundary.
The behavior of selection.modify() when the granularity parameter is paragraphboundary should be be consistent, whether a is editable or not.
The specification doesn't define the behavior of
seleciton.modify()
when the granularity parameter isparagraphboundary
.Consider this test case
The behavior of browsers:
this link| after
.paragraphboundary
.If we make
a
to be editable, the behavior of browsers:|this link after
.paragraphboundary
.The behavior of
selection.modify()
when the granularity parameter isparagraphboundary
should be be consistent, whethera
is editable or not.