Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input.type = 'number' throws exception in IE9 #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lib/documentListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ function addDocumentListeners(doc) {
documentInput({target: document.activeElement}); // selectionchange evts don't have the e.target we need
}
}, true);
}

// For some reason valueAsNumber returns NaN for number inputs in IE
// until a new IE version that handles this is released, parse input.value as a fallback
var input = document.createElement('input');
input.type = 'number';
input.value = '7';
if (input.valueAsNumber !== input.valueAsNumber) {
var oldInputValue = inputValue;
inputValue = function(input) {
if (input.type === 'number') {
return inputIsNumberValue(input) ? parseFloat(input.value) : input.value;
} else {
return oldInputValue.apply(this, arguments);
}
};
} else { //cannot set input.type to 'number' in IE9
// For some reason valueAsNumber returns NaN for number inputs in IE
// until a new IE version that handles this is released, parse input.value as a fallback
var input = document.createElement('input');
input.type = 'number';
input.value = '7';
if (input.valueAsNumber !== input.valueAsNumber) {
var oldInputValue = inputValue;
inputValue = function(input) {
if (input.type === 'number') {
return inputIsNumberValue(input) ? parseFloat(input.value) : input.value;
} else {
return oldInputValue.apply(this, arguments);
}
};
}
}
}

Expand Down