Skip to content
This repository

Fixed VK Like widget initialisation for IE8 #49

Merged
merged 1 commit into from over 1 year ago

2 participants

Slava Kotiya David Bushell
Slava Kotiya

I run into a bug with VK Like widget in IE8. It may initialise Like widget twise If there are more than one Like button on the page because IE8 sometimes somehow can create several DOM elements at the exact same time, thus there are many elements on the page with the same ID. Random number seems to solve the problem.

David Bushell
Collaborator

Thanks :)

It doesn't makes a real difference, but perhaps avoiding string manipulation may be a nanosecond faster! Instead of:

Math.random().toString().replace('.', '-');

Do this:

Math.floor(Math.random()*1000)

Who knows? Who cares!

David Bushell dbushell merged commit b6fcee0 into from December 04, 2012
David Bushell dbushell closed this December 04, 2012
Slava Kotiya

Actually Math.floor(Math.random()*1000) looks much clearer :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 03, 2012
Slava Kotiya Fixed VK Like widget initialisation for IE8 fc3c771
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  extensions/socialite.vkontakte.js
2  extensions/socialite.vkontakte.js
@@ -69,7 +69,7 @@
69 69
                     settings = Socialite.settings.vkontakte;
70 70
                 el.className = 'vk-like';
71 71
                 // Vkontakte needs explicit element id
72  
-                el.id = 'vkontakte-like-' + (new Date()).getTime();
  72
+                el.id = 'vkontakte-like-' + (new Date()).getTime() + Math.random().toString().replace('.', '-');
73 73
                 Socialite.copyDataAttributes(instance.el, el);
74 74
                 like = extendConfWithAttributes(instance.el, ['type'], settings.like);
75 75
                 instance.el.appendChild(el);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.