approvejs
approvejs copied to clipboard
Regex test throws an error in IE 11
Hi,
When using the format validation attribute in IE 11 approvejs throws the error that toString is not an object. Below you have the affected function:
/** * Returns an object containing the arguments for a test's expected parameters. */ _getArgs: function(params) { var pars = {}; // Does the test for this rule expect any paramaters? this._eachExpected(params, function(expects, expectsLength) { // Check if the rule object has the required parameter. if (params.constraint.hasOwnProperty(expects)) { // Add the expected parameter value to the pars object. pars[expects] = params.constraint[expects]; } else if (expectsLength <= 1 && (/^[A-Za-z0-9]+$/i.test(params.constraint) || toString.call(params.constraint) === '[object RegExp]')) { // Set the parameter to the rule's value. pars[expects] = params.constraint; } else { throw 'approve.value(): ' + params.rule + ' expects the ' + expects + ' parameter.'; } }); // Does the rule have config if(params.constraint.hasOwnProperty('config')) { // Add the config to the pars object. pars.config = params.constraint.config; } // Return the parameters object return pars; }
The toString call must be corrected to Object.prototype.toString.call(params.constraint) because IE is not that smart to look for toString in Object's prototype.
Thanks for letting me know @MarcoDeT .
I will get on fixing the issue.