Skip to content

setAttribute error when using with Typekit in Safari #75

Closed
@benknight

Description

@benknight

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');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions