Index: Source/core/dom/DOMTokenList.cpp |
diff --git a/Source/core/dom/DOMTokenList.cpp b/Source/core/dom/DOMTokenList.cpp |
index b434de742135c97e057c103ca3a1c70f0ba875c1..3f2482cf4a3b8ae742b8cd5f9d67ce95482de83e 100644 |
--- a/Source/core/dom/DOMTokenList.cpp |
+++ b/Source/core/dom/DOMTokenList.cpp |
@@ -121,30 +121,23 @@ void DOMTokenList::remove(const Vector<String>& tokens, ExceptionState& exceptio |
setValue(removeTokens(value(), tokens)); |
} |
-bool DOMTokenList::toggle(const AtomicString& token, ExceptionState& exceptionState) |
+bool DOMTokenList::toggle(const AtomicString& token, Optional<bool> force, ExceptionState& exceptionState) |
{ |
if (!validateToken(token, exceptionState)) |
return false; |
if (containsInternal(token)) { |
- removeInternal(token); |
- return false; |
- } |
- addInternal(token); |
- return true; |
-} |
- |
-bool DOMTokenList::toggle(const AtomicString& token, bool force, ExceptionState& exceptionState) |
-{ |
- if (!validateToken(token, exceptionState)) |
- return false; |
- |
- if (force) |
+ if (force.isMissing() || !force.get()) { |
+ removeInternal(token); |
+ return false; |
+ } |
+ return true; |
+ } else { |
+ if (!force.isMissing() && !force.get()) |
+ return false; |
addInternal(token); |
- else |
- removeInternal(token); |
- |
- return force; |
+ return true; |
+ } |
} |
void DOMTokenList::addInternal(const AtomicString& token) |