-
Notifications
You must be signed in to change notification settings - Fork 371
Prevent duplicate ID's #295
Prevent duplicate ID's #295
Conversation
A service provides unique ID's using a counter instead of a timestamp.
@@ -53,7 +53,7 @@ describe('uiTinymce', function () { | |||
expect(tinymce.init).toHaveBeenCalled(); | |||
expect(tinymce.init.calls.mostRecent().args[0].tinymce.bar).toBe('baz'); | |||
}); | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this was commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test failed but had nothing to do with my piece of code... Sorry, should have mentioned it ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything else I should do?
It was actually doing this recently, and was changed by 15c64f1. I just want to do some investigation tonight to see if there are any implications for changing that back. I have another possible fix, for what that commit was trying to solve, so I will take another look tonight at everything. |
Ok, checked it with the generatedIds var, this also passes my unit test so you don't need the service. I thought every directive would get its own instance so the counter var would start at zero all the time, but this isn't true (at least if the var is initialized above the return of course). |
I'm running into the same issue (duplicate id's for multiple instances are generated with the same timestamp) ... Hope this PR can be resolved soon! Also, love me some Phish band. Been touring since '94 ;) |
How in the world isn't this fixed yet - and how did someone think it was a good idea to use a timestamp? |
@ClickerMonkey, thanks for the helpful input! |
We had a problem using multiple inline tinymce editors. Because the code used a timestamp for generating unique ID's some were generated in the same millisecond resulting in duplicate ID's.
As a solution I wrote a service (which is a singleton) that provides a unique ID. All directives ask a unique ID from this service guaranteeing its uniqueness.
FYI: I also tried the supplied unit test agains the old code, then it fails which proves the problem.
Cheers, Roel Plieger.