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

Regex test throws an error in IE 11 #17

Open
MarcoDeT opened this issue Jan 28, 2019 · 1 comment
Open

Regex test throws an error in IE 11 #17

MarcoDeT opened this issue Jan 28, 2019 · 1 comment
Assignees
Labels

Comments

@MarcoDeT
Copy link

MarcoDeT commented Jan 28, 2019

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.

@CharlGottschalk
Copy link
Owner

Thanks for letting me know @MarcoDeT .

I will get on fixing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants