Skip to content

Commit 5ff9a6c

Browse files
authored
Merge pull request #28 from willstocks-tech/develop
v0.0.8
2 parents 9ebaf5e + ac3a8dc commit 5ff9a6c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
A little script that allows you to only polyfill a feature when absolutely necessary - no wasted requests on browsers that have native support! 😆🤓
1313

14-
This script is ~4.03KB **un**minified (121 lines) _(1019B **un**minified and gzipped)_, ~8.37KB **un**minified with inline comments (121 lines) _(2.12KB **un**minified and gzipped)_, or ~1.75KB **minified** (1 line) _(697B minified and gzipped)_, so it's _fairly_ light. :smile:
14+
This script is ~4.2KB **un**minified (121 lines) _(1.04KB **un**minified and gzipped)_, ~8.37KB **un**minified with inline comments (121 lines) _(2.12KB **un**minified and gzipped)_, or ~1.9KB **minified** (1 line) _(743B minified and gzipped)_, so it's _fairly_ light. :smile:
1515

1616
## Getting Started
1717

dynamicpolyfill.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const polyfillio = "https://polyfill.io/v3/polyfill.min.js?features=";
22

33
function dynamicPolyfill(tocheck, scriptToPolyfill, functionToRunonLoad) {
4-
if(typeof Promise !== "undefined" || "Promise" in this) {
4+
if(typeof Promise !== "undefined" || window.hasOwnProperty("Promise")) {
55
var polyfillReq = [];
66
if(Array.isArray(tocheck)) {
77
tocheck.forEach(
@@ -37,12 +37,12 @@ function promiFill(tocheck, scriptToPolyfill, functionToRunonLoad) {
3737

3838
function checking(check) {
3939
var splitChars = ".";
40-
if((check in window) !== true || (check in this) !== true) {
40+
if(window.hasOwnProperty(check)!== true || (typeof this.check !== 'function') !== true || (check in this) !== true) {
4141
if (check.indexOf(splitChars) >= 1) {
4242
var split = check.split(".");
43-
var firstWord = window[split[0]];
43+
var firstWord = (split[0] === "window" ? split[0] : window[split[0]]);
4444
var lastWord = new Object(split[split.length - 1]);
45-
if (lastWord in firstWord != true && lastWord in firstWord.prototype != true) {
45+
if ((firstWord.prototype.hasOwnProperty(lastWord) !== true) && (firstWord.hasOwnProperty(lastWord) !== true) && (lastWord in firstWord !== true)) {
4646
return check;
4747
}
4848
} else {

dynamicpolyfill.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)