From: Matt Kruse on
On May 11, 12:19 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
> So this won't allow, for instance,
>     $props("myObj.prop1.prop2[current.value]")
> Is that right?  It needs to have only a single root at the first
> token.  That will cover a lot of possibilities, but the more general
> case is interesting too.

True. But since you're passing in a string, couldn't you just do:

$prop("myObj.prop1.prop2."+current.value)
?

Matt
From: Thomas 'PointedEars' Lahn on
Matt Kruse wrote:

> On May 11, 12:19 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
>> So this won't allow, for instance,
>> $props("myObj.prop1.prop2[current.value]")
>> Is that right? It needs to have only a single root at the first
>> token. That will cover a lot of possibilities, but the more general
>> case is interesting too.
>
> True. But since you're passing in a string, couldn't you just do:
>
> $prop("myObj.prop1.prop2."+current.value)
> ?

Generally, no. Think about it. See also the caveats that I have mentioned.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Scott Sauyet on
Matt Kruse wrote:
> On May 11, 12:19 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
>
>> So this won't allow, for instance,
>>     $props("myObj.prop1.prop2[current.value]")
>> Is that right?  It needs to have only a single root at the first
>> token.  That will cover a lot of possibilities, but the more general
>> case is interesting too.
>
> True. But since you're passing in a string, couldn't you just do:
>
> $prop("myObj.prop1.prop2."+current.value)
> ?

Sure, unless current is undefined, which I think is the original
problem we're trying to solve. :-)

And of course we could want

$props("myObj.prop1.prop2[current.deeply.nested.value]")

as well.

--
Scott
From: Thomas 'PointedEars' Lahn on
Scott Sauyet wrote:

> Matt Kruse wrote:
>> On May 11, 12:19 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
>>> So this won't allow, for instance,
>>> $props("myObj.prop1.prop2[current.value]")
>>> Is that right? It needs to have only a single root at the first
>>> token. That will cover a lot of possibilities, but the more general
>>> case is interesting too.
>>
>> True. But since you're passing in a string, couldn't you just do:
>>
>> $prop("myObj.prop1.prop2."+current.value)
>> ?
>
> Sure, unless current is undefined, [...]

Wrong. Think about what would happen with

current.value = 42;

or

current.value = "foo.bar";

or

current.value = "foo['bar']";


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004)
From: Thomas 'PointedEars' Lahn on
Matt Kruse wrote:

> if ( p.match(/(.+?)(\[\d+\].*)/) ) {
> p = RegExp.$1;
> props.unshift(RegExp.$2);

Other flaws of this approach that I have already mentioned aside, the `$n'
properties of `RegExp' are deprecated as of JavaScript 1.5 at least. Use
the return values of String.prototype.match() and RegExp.prototype.exec(),
respectively, instead.

<https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Deprecated_Features#RegExp_Properties>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee