Prev: FAQ Topic - How can I access the client-side filesystem? (2010-05-11)
Next: apparently wrong function.
From: Scott Sauyet on 17 May 2010 15:21 Stefan Weiss wrote: > On 17/05/10 15:12, Scott Sauyet wrote: >> fetch("obj.foo.bar.baz"); > > How can that work unless obj is global? Hmmm, I'm wondering if I'm simply misremembering code from 2003-04 or if we had a way to deal with that. In those days we used the global scope a lot, but I can't believe we didn't run into such an issue. Now I *really* wish I had access to that code! -- Scott
From: Matt Kruse on 17 May 2010 16:07 On May 17, 2:21 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote: > Stefan Weiss wrote: > > On 17/05/10 15:12, Scott Sauyet wrote: > >> fetch("obj.foo.bar.baz"); > > How can that work unless obj is global? > Hmmm, I'm wondering if I'm simply misremembering code from 2003-04 or > if we had a way to deal with that. In those days we used the global > scope a lot, but I can't believe we didn't run into such an issue. > Now I *really* wish I had access to that code! Oh yeah, that's what I meant to ask you and forgot. That's why I pass in the root object, because otherwise you would need to resolve the first identifier globally, and that never happens in my code ;) In my syntax, if there is no root object passed in, then the first identifier is assumed to be an id, and getElementById() is called first to get the root object. Since this is the most common scenario for me, it's another layer of convenience. Matt Kruse
From: Scott Sauyet on 17 May 2010 16:15 Matt Kruse wrote: > On May 17, 2:21 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote: > > > Stefan Weiss wrote: > > > On 17/05/10 15:12, Scott Sauyet wrote: > > >> fetch("obj.foo.bar.baz"); > > > How can that work unless obj is global? > > Hmmm, I'm wondering if I'm simply misremembering code from 2003-04 or > > if we had a way to deal with that. In those days we used the global > > scope a lot, but I can't believe we didn't run into such an issue. > > Now I *really* wish I had access to that code! > > Oh yeah, that's what I meant to ask you and forgot. That's why I pass > in the root object, because otherwise you would need to resolve the > first identifier globally, and that never happens in my code ;) > > In my syntax, if there is no root object passed in, then the first > identifier is assumed to be an id, and getElementById() is called > first to get the root object. Since this is the most common scenario > for me, it's another layer of convenience. I wasn't using it for DOM nodes usually, so I know I wasn't doing that. I'm wondering if it was just that we were running so much in those days in the global context. That might be the main reason that we eventually abandoned it, having to hoist locals to a global context to use it. But that doesn't really sound familiar. I can't think of any tricks now to deal with that problem. I have this problem with my memory, I forget exactly what it is! :-( -- Scott
From: nick on 17 May 2010 23:29 David Mark wrote: > nick wrote: >> Garrett Smith wrote: >>> Stefan Weiss wrote: >>>> try { var color = body.firstChild.style.backgroundColor; } catch(e) {} >> This seems like the most obvious way to do it. > The trouble is that it is ham-fisted. You will have no idea why the > exception is thrown, so the pattern has very limited potential in > anything but the simplest of contexts. Not any more so that a function that parses a string and returns either 'true' or 'false.' This should solve the problem the OP presented just about as effectively, minus the built-in dom stuff from Matt's "stab at it" post (I'd rather have separate dom selector and 'can access' functions, personally). It could be easily modified to return the property value if it is found as in Matt's example, but I'm not sure I like this either... what if the value is 0, false, null, or undefined? If you forget to use ===, the behavior could invite mistakes. Maybe returning something like this would be safer? { "value" : /* return value goes here */ }
From: David Mark on 18 May 2010 05:42
Matt Kruse wrote: > On May 17, 9:51 am, David Mark <dmark.cins...(a)gmail.com> wrote: >> [snip a heap of blithering] >> I suppose you still use jQuery as well. :) >> http://www.urbandictionary.com/define.php?term=pseudo-intellectual > > It's good to see that you are still here trolling with ad-hominem > attacks and spewing your same old tired mantra, David. But seriously, > isn't it time to grow up, move on, and discuss ideas instead of > attacking people? > Some spin that. Who is responsible for moving projects like jQuery, Dojo, etc. forward (whether they like it or not?) Who comes up with and publishes the best ideas (not to mention library) for cross-browser scripting? http://www.cinsoft.net/host.html http://www.cinsoft.net/mylib.html Then who periodically pops in here to whine and insult me because much of what I do invalidates years of futility on their part? And other than periodically pointing out that you are a time-wasting twit, I rarely insult anyone in here. Out of nearly 5,000 posts, virtually all of them are about ideas. Look at how many times I have gone out of my way to solve problems for people here, despite the fact that often they are ungrateful (and even hostile). Go back and read them from the start if your amnesia is flaring up again. Nobody's buying your revisionism (except perhaps you). |