Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes to Merge
This update improves the robustness, compatibility, and correctness of polyfills for ES5 methods in JavaScript. Key fixes include stricter type checks, improved error handling, proper property lookups, and adherence to ECMAScript specifications.
🔧 Key Fixes & Enhancements
1️⃣ Fixed Object.create Implementation:
Ensured it only accepts non-null objects.
Throws a TypeError for invalid inputs.
2️⃣ Fixed Object.keys Property Lookup:
Replaced r.hasOwnProperty.call(o, k) with Object.prototype.hasOwnProperty.call(o, k).
Ensures it correctly filters only own properties.
3️⃣ Fixed Array.prototype.indexOf Handling of fromIndex:
Handles negative indices properly by clamping within valid bounds.
Ensures consistent behavior in older browsers.
4️⃣ Improved Type Checks for Array.prototype.forEach, map, filter:
Added explicit TypeError checks to prevent execution on null or undefined arrays.
Ensured function arguments are validated before execution.
5️⃣ Refactored Function.prototype.bind for Better Compatibility:
Fixed prototype inheritance issues in older browsers (IE8).
Ensured the bound function correctly retains this context when called with new.
6️⃣ Fixed window.location.assign:
Added a TypeError check to ensure the URL is a string.
Uses window.location.href = url; to prevent assignment issues.
🚀 Expected Benefits
Better Compatibility with older browsers like IE8+.
Stronger Error Handling preventing unexpected crashes.
More Standards-Compliant Behavior aligned with ECMAScript 5.1.
Improved Performance with optimized loops and property checks.