-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Potential usage of reserved keywords in Parser.getterFn #9131
Comments
I don't think there is a problem with accessing a property using the dot notation even if that property's name is a reserved keyword (but I might be missing something). @zenorbi, do you have an example expression that causes an error or unexpected behaviour due to this ? |
In IE8 it does throw an exception. I know that IE8 doesn't participate on automated testing, but this is only a 4 character modification. |
We don't support angular in 1.3.x. Does it happen in 1.2.x? |
It doesn't happen there as the key is wrapped in square brackets. |
@zenorbi: Could you post the breaking example. I am just curious and I wasn't able to reproduce it. |
I've been able to narrow it down to this: A div like this gets inserted by angular-ui and causes the parser to try and parse the "in" part. |
@zenorbi if you have a reproduction for Angular 1.2.x that is broken in IE8, we can take a look at it. |
@btford Angular 1.2.x doesn't have this bug, as that uses square brackets. This is the line from angular 1.2.25: |
that sounds like a pretty simple fix then, did we change that for perf On Wed, Sep 17, 2014 at 1:59 PM, Zenorbi notifications@github.com wrote:
|
I know that most of the stuff doesn't actually work in IE8 like Object.getPrototypeOf or Object.create but I was able to shim that in along with a bunch of other stuff. Currently this is the only thing which needs modification on the angular.js file. I can just keep replacing this line in each angular version, I'm just hoping that because this is such a small adjustment, it can live in the real source. |
if we had a good reason to change it, then it probably can't. But lets find out. If you want you could submit a fix for it, it should be a pretty trivial PR |
@lgalfaso Ok then, it was worth a shot anyway. Thank you. |
I don't believe the performance reasons are really correct in this case, because it breaks a lot of valid expressions, and makes the whole |
For IE9 we should actually check the value of |
|
Chrome and FF are smart enough to notice that the key is is a string literal, so this change doesn't make a difference there. Safari gets a boost. I haven't tested IE, but it can't cause harm there. :) http://jsperf.com/fn-dereferencing
Igor says we use a different path when |
I also think we should use the [] syntax if |
reading at the code, I am not sure how just |
the object literal parser doesn't look like it should run into that, this is true |
I've found that this also crashes Android 2.x browsers as the parser does throw SyntaxError. |
@zenorbi would it be possible to have a minimal example where this is a problem? |
Of course, you just need to run an ng-app with this element inside: |
Ok, I am able to reproduce this. I think that the proposed patch is not the right one, will post a patch in a few |
Create the ident functions lazily as these are not used for filters not object literal properties Closes angular#9131
Create the ident functions lazily as these are not used for filters not object literal properties Closes angular#9131
Create the ident functions lazily as these are not used for filters not object literal properties Closes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes `{.: ...}` parsing as `{'.': ...}` Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes `{.: ...}` parsing as `{'.': ...}` Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes `{.: ...}` parsing as `{'.': ...} instead of throwing` Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes `{.: ...}` parsing as `{'.': ...}` instead of throwing Fixes angular#9131
Fixes `a.b` and `a .b` generating different getterFns Fixes `{'': ...}` turning into `{"''": ...}` Fixes `{.: ...}` parsing as `{'.': ...}` instead of throwing Fixes angular#9131
At the line 928:
: '((l&&l.hasOwnProperty("' + key + '"))?l:s)') + '.' + key + ';\n';
should be replaced to
: '((l&&l.hasOwnProperty("' + key + '"))?l:s)') + '["' + key + '"];\n';
as the
key
can potential be a reserved keyword like float, class, for. I know about 1 instance where thekey
is "in" which is part of thefor (k in o)
syntax.The text was updated successfully, but these errors were encountered: