Skip to content

Commit

Permalink
Throw error when unfocus fails after clearing element
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Mar 7, 2018
1 parent 37bd7db commit 4be8cdc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion javascript/atoms/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ bot.action.clear = function(element) {
element.value = '';
bot.events.fire(element, bot.events.EventType.CHANGE);
bot.events.fire(element, bot.events.EventType.BLUR);
bot.action.LegacyDevice_.focusOnElement(bot.getDocument().body);
var body = bot.getDocument().body;
if (body) {
bot.action.LegacyDevice_.focusOnElement(body);
} else {
throw new bot.Error(bot.ErrorCode.UNKNOWN_ERROR,
'Cannot unfocus element after clearing.');
}
} else if (bot.dom.isElement(element, goog.dom.TagName.INPUT) &&
(element.getAttribute('type') && element.getAttribute('type').toLowerCase() == "number")) {
// number input fields that have invalid inputs
Expand Down

0 comments on commit 4be8cdc

Please sign in to comment.