Open Bug 1519578 Opened 5 years ago Updated 2 years ago

[contenteditable] Elements made block via CSS use <br> for newlines rather than <divs>

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

Webcompat Priority P3
Tracking Status
firefox66 --- affected

People

(Reporter: twisniewski, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:site-wait, Whiteboard: [h2review-noted])

Attachments

(2 files)

Attached file test.html

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).

Flags: webcompat?
Priority: -- → P3

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).

(YouTube should change the editing host from <span> to <div>, anyway.)

I'm going to reach out to YouTube here and see if they can switch to <div>.

Flags: needinfo?(miket)
Whiteboard: [webcompat] → [webcompat-revisit]

Sent an email to our partner list.

Flags: needinfo?(miket)
Whiteboard: [webcompat-revisit] → [webcompat-revisit][sitewait]

See bug 1547409. Moving webcompat whiteboard tags to project flags.

Webcompat Priority: --- → ?

See bug 1547409. Moving webcompat whiteboard tags to keywords.

Webcompat Priority: ? → revisit
Whiteboard: [webcompat-revisit][sitewait]
Flags: webcompat?

It seems like YouTube worked around this somehow (but I still see spans instead of divs). See screenshot.

Whiteboard: [h2review-noted]
Webcompat Priority: revisit → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: