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

Array indexOf Polyfill error in oldie module #8346

Closed
zhy1stgg opened this Issue May 17, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@zhy1stgg

zhy1stgg commented May 17, 2018

Array indexOf Polyfill in your modules/oldie.src.js

if (!Array.prototype.indexOf) {
    H.indexOfPolyfill = function(arr) {
        var len,
            i = 0;

        if (arr) {
            len = arr.length;

            for (; i < len; i++) {
                if (arr[i] === this) {
                    return i;
                }
            }
        }

        return -1;
    };
}

fixed with:

if (!Array.prototype.indexOf) {
    H.indexOfPolyfill = function(item) {
        var len,
            i = 0;

        if (item) {
            len = this.length;

            for (; i < len; i++) {
                if (this[i] === item) {
                    return i;
                }
            }
        }

        return -1;
    };
}
@sebastianbochan

This comment has been minimized.

Show comment
Hide comment
@sebastianbochan

sebastianbochan May 17, 2018

Contributor

Hi @zhy1stgg
Thank you for the suggestion.

@TorsteinHonsi does it make sense for you too?

Contributor

sebastianbochan commented May 17, 2018

Hi @zhy1stgg
Thank you for the suggestion.

@TorsteinHonsi does it make sense for you too?

@KacperMadej

This comment has been minimized.

Show comment
Hide comment
@KacperMadej

KacperMadej May 17, 2018

Contributor

Internal note:

Additionally, H.indexOfPolyfill

if (!Array.prototype.indexOf) {
H.indexOfPolyfill = function (arr) {
var len,
i = 0;
if (arr) {
len = arr.length;
for (; i < len; i++) {
if (arr[i] === this) {
return i;
}
}
}
return -1;
};
}

doesn't support fromIndex.

H.inArray = function (item, arr, fromIndex) {
return (
H.indexOfPolyfill ||
Array.prototype.indexOf
).call(arr, item, fromIndex);
};

Contributor

KacperMadej commented May 17, 2018

Internal note:

Additionally, H.indexOfPolyfill

if (!Array.prototype.indexOf) {
H.indexOfPolyfill = function (arr) {
var len,
i = 0;
if (arr) {
len = arr.length;
for (; i < len; i++) {
if (arr[i] === this) {
return i;
}
}
}
return -1;
};
}

doesn't support fromIndex.

H.inArray = function (item, arr, fromIndex) {
return (
H.indexOfPolyfill ||
Array.prototype.indexOf
).call(arr, item, fromIndex);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment