Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

TypeError: badgeSvg is undefined #66

Open
graingert opened this issue Sep 5, 2018 · 1 comment
Open

TypeError: badgeSvg is undefined #66

graingert opened this issue Sep 5, 2018 · 1 comment

Comments

@graingert
Copy link

looks like you want something like this:

const sleep = t => new Promise(resolve => setTimeout(resolve, t));

(async () => {
  await $.ready;
  await sleep(500); // not sure why this is 
  const badgeSvg = document.getElementById("badge").contentDocument;

  if (isOrganiser || isContributor) {
    badgeSvg.getElementById("background").className.baseVal = "red";
  } else if (isContributor) {
    badgeSvg.getElementById("background").className.baseVal = "blue";
  }
}();

moved from PyconUK/2018.pyconuk.org#5

@graingert
Copy link
Author

it looks like:

$(window).bind("load", function() {
  setTimeout(badgeLoad, 500);
});

is just totally superfluous, it means if you click on any of the buttons in under 500ms after the window load event then it fails.

it looks like you just need: badgeLoad() on its own

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