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

Unified Diff: Source/core/html/HTMLSelectElement.cpp

Issue 213773003: select.add() should support optgroup adding and before index (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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: Source/core/html/HTMLSelectElement.cpp
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index eaed769fd7c3b461c72fbcee405535bbd3b1f196..e05c7b801d98ad5e4418231d62e48c989be29774 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -203,13 +203,19 @@ void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before, Exception
// Make sure the element is ref'd and deref'd so we don't leak it.
RefPtr<HTMLElement> protectNewChild(element);
- if (!element || !(isHTMLOptionElement(element) || isHTMLHRElement(element)))
+ if (!element || !(isHTMLOptionElement(element) || isHTMLOptGroupElement(element) || isHTMLHRElement(element)))
return;
insertBefore(element, before, exceptionState);
setNeedsValidityCheck();
}
+void HTMLSelectElement::addBeforeOptionAtIndex(HTMLElement* element, unsigned beforeIndex, ExceptionState& exceptionState)
+{
+ HTMLElement* beforeElement = toHTMLElement(options()->item(beforeIndex));
+ add(element, beforeElement, exceptionState);
+}
+
void HTMLSelectElement::remove(int optionIndex)
{
int listIndex = optionToListIndex(optionIndex);

Powered by Google App Engine
This is Rietveld 408576698