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

onload, length of stateAbbreviations is null #1

Open
galiat opened this issue Feb 21, 2014 · 1 comment
Open

onload, length of stateAbbreviations is null #1

galiat opened this issue Feb 21, 2014 · 1 comment

Comments

@galiat
Copy link

galiat commented Feb 21, 2014

On page load, I get the error:

Uncaught TypeError: Cannot read property 'length' of null on line 165

After the page fully loads, the value is set.

@august-schlubach
Copy link

This seems like a harmless issue where recolorNation is being called before window.onload populates the stateAbbreviations array. I got around this by catching the error.

function recolorNation(hashtag) {
    // A function to go through every state and color it correctly for a given hashtag
    try {
        for ( var k = 0; k < stateAbbreviations.length; k++ ) {
            var stateAbbreviation = stateAbbreviations[k];
            var state = nation.getElementById(stateAbbreviation);
            colorState(state, getIntervalAt(SOTUvideo.currentTime), hashtag);
        }
    }
    catch(err) {
        // throws this the first time it loads.
    }
}

:octocat:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants