import from UXP: Preserve newlines in textarea placeholders (7ae2bd83)

This commit is contained in:
2022-04-01 10:55:09 +08:00
parent 099d54dd27
commit 81ea840c5a
+5 -1
View File
@@ -2266,7 +2266,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);
}