Skip to content

Commit

Permalink
Merge pull request knockout#2360 from Deathicator/master
Browse files Browse the repository at this point in the history
Add number input workaround for Microsoft Edge.
  • Loading branch information
mbest authored Mar 26, 2018
2 parents 7760526 + e80a15c commit fc8c59e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/binding/defaultBindings/textInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ if (window && window.navigator) {

// Detect various browser versions because some old versions don't fully support the 'input' event
var userAgent = window.navigator.userAgent,
operaVersion, chromeVersion, safariVersion, firefoxVersion, ieVersion;
operaVersion, chromeVersion, safariVersion, firefoxVersion, ieVersion, edgeVersion;

(operaVersion = window.opera && window.opera.version && parseInt(window.opera.version()))
|| (edgeVersion = parseVersion(userAgent.match(/Edge\/([^ ]+)$/)))
|| (chromeVersion = parseVersion(userAgent.match(/Chrome\/([^ ]+)/)))
|| (safariVersion = parseVersion(userAgent.match(/Version\/([^ ]+) Safari/)))
|| (firefoxVersion = parseVersion(userAgent.match(/Firefox\/([^ ]+)/)))
Expand Down Expand Up @@ -173,6 +174,10 @@ ko.bindingHandlers['textInput'] = {
// Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.
onEvent('dragdrop', updateModel); // <3.5
onEvent('drop', updateModel); // 3.5
} else if (edgeVersion && element.type === "number") {
// Microsoft Edge doesn't fire 'input' or 'change' events for number inputs when
// the value is changed via the up / down arrow keys
onEvent('keydown', deferUpdateModel);
}
}

Expand Down

0 comments on commit fc8c59e

Please sign in to comment.