Skip to content

Commit 4be8cdc

Browse files
committed
Throw error when unfocus fails after clearing element
1 parent 37bd7db commit 4be8cdc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

javascript/atoms/action.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ bot.action.clear = function(element) {
9292
element.value = '';
9393
bot.events.fire(element, bot.events.EventType.CHANGE);
9494
bot.events.fire(element, bot.events.EventType.BLUR);
95-
bot.action.LegacyDevice_.focusOnElement(bot.getDocument().body);
95+
var body = bot.getDocument().body;
96+
if (body) {
97+
bot.action.LegacyDevice_.focusOnElement(body);
98+
} else {
99+
throw new bot.Error(bot.ErrorCode.UNKNOWN_ERROR,
100+
'Cannot unfocus element after clearing.');
101+
}
96102
} else if (bot.dom.isElement(element, goog.dom.TagName.INPUT) &&
97103
(element.getAttribute('type') && element.getAttribute('type').toLowerCase() == "number")) {
98104
// number input fields that have invalid inputs

0 commit comments

Comments
 (0)