-
Notifications
You must be signed in to change notification settings - Fork 467
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
Multiple code blocks on a page: sometimes a block is filled with content of another block #207
Comments
I thought this might actually be a bug. It had been reported a couple times on the mousetrap documentation page: ccampbell/mousetrap#347 Doing them in a sequence like you suggested probably would fix it, but I think there is something else going on. The only way this can be happening is if the id comes back with the same identifier for multiple code blocks which means Line 162 in 3374f13
The problem is I don't know a way to consistently reproduce this or how it is even possible that multiple blocks are coming back with the same identifier |
If the computer is fast enough, Date.now() can produce same values; I have logged some calls with console.log("id: " + String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now()); console.log("id: " + String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now()); Sometimes I see identical values for Date.now(); the computed random-char has a chance of 1 : 26 to be the same, so there is a real chance for identical IDs; Could the issue be related to your cachedWorker? When I suppress caching (creating a new worker for every call), I can't reproduce the error. |
Interesting. Yeah I think the counter is probably the simplest approach. I don't think the |
It's definitely just random. On a fast enough computer, it has a 1/26 chance of re-using the same id assuming all the blocks are looped over in the same millisecond |
Yes, it's the random, I logged the created ID now; when the error occurs, the ID is actually the same. |
Can confirm same issue with Firefox 50.0.2/Windows 10 pro 64bit |
You may consider to patch that issue with something like: |
There seems to be an issue with multiple code blocks on a page, sometimes the content of a block is replaced by the content of another block. I could even reproduce the problem on the demo-site (see picture below) with Firefox 49.0.1/Windows 10 pro 64bit, after pressing F5-key repeatedly:
I think, the problem can be avoided by sequentializing the render process (my pre-tags have class "snippet"):
The text was updated successfully, but these errors were encountered: