[contenteditable] Elements made block via CSS use <br> for newlines rather than <divs>
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
People
(Reporter: twisniewski, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: webcompat:site-wait, Whiteboard: [h2review-noted])
Attachments
(2 files)
Elements that are intrisically block elements will use <div> for contenteditable newlines, whereas elements which are assigned to be block elements with CSS will use <br> instead. Chrome instead wraps both cases with <div>.
This is causing an interop issue with YouTube comments. YouTube is expecting Chrome's behavior, and so once users submit their comments, they are treated as a single line, ignoring the line breaks the user saw while typing in the comment. (This was raised at https://webcompat.com/issues/24113).
Updated•5 years ago
|
Comment 1•5 years ago
•
|
||
This is really difficult to fix by outside because Chrome creates DOM tree like this:
--<span contenteditable>
+-<div>
| +- first line
+-<div>
+- second line
If web apps do:
let tmp = editor.innerHTML;
tmp.replace(...);
editor.innerHTML = tmp;
Then, DOM tree would be broken like:
+-<span contenteditable><span>
+-<div>
| +- first line
+-<div>
+- second line
because <span> element is forcibly closed before the first <div> because of impossible to contain.
If we need to change this behavior, we should ask Google about how do they think (i.e., whether should be fixed by them).
Comment 2•5 years ago
|
||
(YouTube should change the editing host from <span> to <div>, anyway.)
Comment 3•5 years ago
|
||
I'm going to reach out to YouTube here and see if they can switch to <div>.
Comment 4•5 years ago
|
||
Sent an email to our partner list.
Comment 5•5 years ago
|
||
See bug 1547409. Moving webcompat whiteboard tags to project flags.
Comment 6•5 years ago
|
||
See bug 1547409. Moving webcompat whiteboard tags to keywords.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 7•4 years ago
|
||
It seems like YouTube worked around this somehow (but I still see spans instead of divs). See screenshot.
Updated•4 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Description
•