On 29 May 2012 17:59, Nicholas C. Zakas <[email protected]> wrote:
> var element = document.getElementById("**myDiv");
> element.{
> innerHTML: "Hello world!",
> className: "enabled"
> };
>
> Going by the current definition, this code block would actually have no
> effect because it would be defining new own properties rather than
> assigning values to the existing prototype accessor properties. I cringe at
> the thought of how long it would take most developers to figure out that it
> is the colon that's the problem. IMHO, This code doesn't behave as expected.
It'll throw, right? If so, presumably the developer wouldn't take too long
to figure it out.
What would your fix be? To reverse : and = in the new syntax, so that :
means [[Put]] and = means [[DefineOwnProperty]]? Because Brendan's point
about exploits is a cogent one, and as : means [[DefineOwnProperty]] in
literals today, it seems like sticking with that makes sense. Developers
using the new syntax will hopefully learn the importance of using =.
Especially as I would expect that it would be the default choice for most
people, most of the time, so that's what they'd see as examples... (I could
be wrong there, of course.)
-- T.J.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss