bug with String.contains polyfill
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- angularjs
- Domain
- frontend
Research direction
The issue is in the String.contains polyfill. Look for where String.prototype.contains is defined in the codebase, likely in a polyfill file. The fix is to use Object.defineProperty with enumerable: false to prevent the property from appearing in for...in loops. Test the fix by running the provided code snippet before and after the change to ensure the function is not enumerated and no exception is thrown.
Written by the indexing model from the issue text.
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();}
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 319
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from a8m/angular-filter
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
a8m/angular-filter#267 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a8m/angular-filter#254 · 2 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a8m/angular-filter#250 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a8m/angular-filter#208 · 1 comment · 1 reaction ·
-
groupBy multiple key Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
a8m/angular-filter#177 · 1 comment ·
All issues in a8m/angular-filter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·