On Wed, Oct 29, 2008 at 6:35 AM, Martin S. <[EMAIL PROTECTED]>wrote:
> > It's better than adding IDs, at least for my aesthetics.
> In this example it will work even for multiple tags blocks in the same
> HTML page because an event is used which gets the 'this' pointer,
> but imagine that you want to set ONE specific div, which wont cause
> any event to occur?
> One specific, not ALL of the same class! Hey, there you need an ID,
> that's the reason they exist.
>
> To give you more details:
> I'm using jQuery, but only to connect multiple onload and onunload
> functions.
> I'm needing getElementById because I need the handle in order to call
> a lot of JavaScript methods on it.
> I could maybe get this handle also with jQuery, but it would need an
> also an ID - and would probably call getElementById by itself.
> All browsers which can handle the rest of the JavaScript also can
> getElementById, so there is no need to use an compatibility wrapper
> around it.
>
>From a purely technical standpoint, I remain unconvinced. The differences
between your macro instances are their arguments and their position within
the page. All of this data should be easily available without IDs. But I'm
probably still missing something.
In any case, I think your solution of incrementing from 1 for each request
suffers a race condition. From a recent post on the trac-dev list by Remy
Blank:
> But Components are *not* singletons. There is exactly one instance of
> each Component *per ComponentManager*, so in the case of Trac, *per
> environment*.
So we don't have singletons, but for a single environment, it is effectively
so. The (hypothetical) race condition happens when two or more requests are
received at the same time. After the first request starts processing, the
second request could reset the counter to 1. Even without the reset, there
still might be a race condition, although less likely.
I'd have to review the code more carefully to know if that race condition is
a real risk...and I'm guessing you aren't really worried about people
loading the page simultaneously. After all, what's the random chance that
two people will load the page at the same time? ...Although you were just
saying you worried about random numbers not being unique.
Ted
--
+ -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---