forked from mirrors/gecko-dev
I misunderstood the traditional behavior before bug1789967, that is, `HTMLEditor` collapsed `Selection` to end of the deepest last child container element **or text node** of the `<body>`, rather than to end of **only** the deepest last child container element. This misunderstanding caused the backout of the first landing, but I didn't realize this mistake. Therefore, this patch makes the crashtests which are touched in bug1789967and the collapsed point is at a text node (or failed to consider the collapsed point) collapse `Selection` to end of the deepest last text node of their `<body>` elements. Differential Revision: https://phabricator.services.mozilla.com/D158177
21 lines
738 B
HTML
21 lines
738 B
HTML
<script>
|
|
function onLoad() {
|
|
const dd = document.querySelector("dd[contenteditable]");
|
|
// For emulating the traditional behavior, collapse Selection to end of the
|
|
// text node at end of the <dd contenteditable> which is the deepest last
|
|
// child of the <body> (end of the text node after the <template>).
|
|
getSelection().collapse(dd.lastChild, dd.lastChild.length);
|
|
getSelection().setPosition(
|
|
document.querySelector("template")
|
|
);
|
|
dd.addEventListener("DOMNodeInserted", () => {
|
|
document.execCommand("selectAll");
|
|
document.execCommand("insertText", false, "");
|
|
});
|
|
document.execCommand("insertImage", false, "#");
|
|
}
|
|
</script>
|
|
<body onload="onLoad()">
|
|
<dd contenteditable>
|
|
<template></template>
|
|
</dd></body>
|