Skip to content
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

setAttribute error when using with Typekit in Safari #75

Closed
benknight opened this issue Feb 16, 2016 · 0 comments
Closed

setAttribute error when using with Typekit in Safari #75

benknight opened this issue Feb 16, 2016 · 0 comments

Comments

@benknight
Copy link

I found an extreme edge case bug but nevertheless it's something I believe could effect many users of this project.

It turns out Typekit's code snippet overrides Element.prototype.setAttribute as follows:

t.setAttribute = function(e, r, i, l) {
        r.match(s) && (i = new XMLHttpRequest,
        i.open("GET", r, !0),
        i.onreadystatechange = function() {
            4 === i.readyState && (l = i.responseText,
            l !== o && (n[a] = l))
        }
        ,
        i.send(null ),
        t.setAttribute = u,
        o) || u.apply(this, arguments)
    }

And in the Tab.js component we have this:

node.setAttribute('tabindex', 0);

Which is causing the following error, only in Safari:

TypeError: r.match is not a function. (In 'r.match(s)', 'r.match' is undefined)

This is happening because the "r" argument of Typekit's custom setAttribute is expected to be a string, however it's receiving an integer 0, which has no match function.

So the fix is just change the line above to:

node.setAttribute('tabindex', '0');
@danez danez closed this as completed in f70a422 Jun 13, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant