Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1995)

Unified Diff: third_party/WebKit/Source/core/html/HTMLOptionElement.cpp

Issue 2891723002: Do not create child node for Option constructor with no arguments/undefined text (Closed)
Patch Set: Rebased and added IsEmpty check Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLOptionElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLOptionElement.cpp b/third_party/WebKit/Source/core/html/HTMLOptionElement.cpp
index 218ea266c83254a97530a771d2684d4d49b9f96d..e28f864e91500a3708e770445b4de74d6db49d60 100644
--- a/third_party/WebKit/Source/core/html/HTMLOptionElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLOptionElement.cpp
@@ -72,10 +72,11 @@ HTMLOptionElement* HTMLOptionElement::CreateForJSConstructor(
ExceptionState& exception_state) {
HTMLOptionElement* element = new HTMLOptionElement(document);
element->EnsureUserAgentShadowRoot();
- element->AppendChild(Text::Create(document, data.IsNull() ? "" : data),
- exception_state);
- if (exception_state.HadException())
- return nullptr;
+ if (!data.IsEmpty()) {
+ element->AppendChild(Text::Create(document, data), exception_state);
+ if (exception_state.HadException())
+ return nullptr;
+ }
if (!value.IsNull())
element->setValue(value);
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/html/semantics/forms/the-option-element/option-element-constructor-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698