Index: Source/core/html/HTMLOptionElement.cpp |
diff --git a/Source/core/html/HTMLOptionElement.cpp b/Source/core/html/HTMLOptionElement.cpp |
index 1bdde70b90d434be260de3938d7652317c9ab16a..8750085da165560bc0837b0bb5c24bec32a3b5f8 100644 |
--- a/Source/core/html/HTMLOptionElement.cpp |
+++ b/Source/core/html/HTMLOptionElement.cpp |
@@ -132,11 +132,9 @@ void HTMLOptionElement::setText(const String &text, ExceptionState& exceptionSta |
bool selectIsMenuList = select && select->usesMenuList(); |
int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; |
- // Handle the common special case where there's exactly 1 child node, and it's a text node. |
- Node* child = firstChild(); |
- if (child && child->isTextNode() && !child->nextSibling()) |
- toText(child)->setData(text); |
- else { |
+ if (hasOneTextChild()) { |
+ toText(firstChild())->setData(text); |
+ } else { |
removeChildren(); |
appendChild(Text::create(document(), text), exceptionState); |
} |