Preserve newlines in textarea placeholders

This commit is contained in:
JustOff 2019-02-19 21:15:35 +02:00 committed by Roy Tam
commit 7ae2bd83b7

View file

@ -2255,7 +2255,11 @@ nsTextEditorState::UpdatePlaceholderText(bool aNotify)
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
content->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholderValue);
nsContentUtils::RemoveNewlines(placeholderValue);
if (mTextCtrlElement->IsTextArea()) { // <textarea>s preserve newlines...
nsContentUtils::PlatformToDOMLineBreaks(placeholderValue);
} else { // ...<input>s don't
nsContentUtils::RemoveNewlines(placeholderValue);
}
NS_ASSERTION(mPlaceholderDiv->GetFirstChild(), "placeholder div has no child");
mPlaceholderDiv->GetFirstChild()->SetText(placeholderValue, aNotify);
}