Share as Library runs function that's not called -- magic!

I believe App Lab is glitching due to the Share as Library feature. Here is what is happening, you can experience it here.

  1. I created a (very silly) function and tested it with 2 console.logs. Both ran successfully.
  2. I shared the function as a library using the Share as Library feature.
  3. I ran the function again, without changing it, and it ran 4 times.
  4. I commented out my console.logs, the function still ran 2 times even though my code was not calling it.
  5. I deleted my console.logs, the function still runs 2 times even though it is not being called.

Further investigation shows that Share as Library included the function calls with the function code, even though they were above the function definition and comments, separated by a blank line.

So the problem seems to be that Share as Library is grabbing more than simply the function and documentation.

I resolved the issue but worry that the Share as Library behavior may still occur.

I’m glad you were able to resolve your issue. If you think there is a bug in Share as Library, please send an email to support@code.org and be share to include a link to the code.