a8m / a8m/angular-filter

bug with String.contains polyfill

Open
#260 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.9k
Forks
319
PR merge metrics
No merged PRs in 30d

Description

Using and loving this library. Found a bug with the String.contains polyfill. Another library was calling a for in loop on a string and the contains function was showing as a property. That library was then calling the function anonymously which led to an exception being thrown. We included a fix in our code before importing your library and I'm sharing it with you if you are interested in applying it to this library:
if(!String.prototype.contains){
Object.defineProperty(String.prototype, 'contains', {
enumerable: false,
value: function() {
return String.prototype.indexOf.apply(this, arguments) !== -1;
}
});
}

You can test out the fix by running the following code before and after this fix:
for(var i in ''){ console.log(i);var fn = ''[i]; fn();}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.