summaryrefslogtreecommitdiffstats
path: root/dom/html
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2019-02-19 21:15:35 +0200
committerJustOff <Off.Just.Off@gmail.com>2019-02-19 21:15:35 +0200
commitb1e78d1db168584a9fbef8f30cb76ca826323b4f (patch)
tree66d006e771c6c3d53195f79d1cb6ff26b6035fcf /dom/html
parent3029dee77bd01e867bc3c7e49bfd14c1484581bb (diff)
downloadUXP-b1e78d1db168584a9fbef8f30cb76ca826323b4f.tar
UXP-b1e78d1db168584a9fbef8f30cb76ca826323b4f.tar.gz
UXP-b1e78d1db168584a9fbef8f30cb76ca826323b4f.tar.lz
UXP-b1e78d1db168584a9fbef8f30cb76ca826323b4f.tar.xz
UXP-b1e78d1db168584a9fbef8f30cb76ca826323b4f.zip
Preserve newlines in textarea placeholders
Diffstat (limited to 'dom/html')
-rw-r--r--dom/html/nsTextEditorState.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp
index 0b4cb1920..25be6016c 100644
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -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);
}