Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome adds <br> to contenteditable span with a :after if its content is deleted; bug?

Is the following functionality a bug in Chrome, or is it correct behavior that I don't understand?

In Chrome (version 25), if I have a content editable span which has a node added after it through a :after css class, as in this jsfiddle

http://jsfiddle.net/yQBvn/

if I delete all of the content of the span, after I've deleted the last character, Chrome adds a <br> to the content editable span. This doesn't feel right.

I've verified that Chrome does not do this if the :after css content isn't added, and I've verified that Firefox doesn't do this in any case.

like image 725
jwrush Avatar asked Oct 05 '22 15:10

jwrush


1 Answers

Wanna see something CRAZY?!

http://jsfiddle.net/joeframbach/VXMEN/

<body>
<div id="EDIT-AREA">
    <span class='CHARACTER-NAME' contenteditable='true'>Bob</span><span>&nbsp;</span>
</div>
</body>

Adding a span with a space after it fixes the problem. Don't ask me why or how.

like image 158
Joe Frambach Avatar answered Oct 10 '22 05:10

Joe Frambach