facebook/idx

IE and FireFox - different error patterns

joselcc opened this issue · 2 comments

IE and Edge

I've been using idx for a couple of days and found that it returns only null on property access error for IE and Edge.

This is caused because the isNullPropertyAccessError and isUndefinedPropertyAccessError methods used by idx are getting the same pattern from the getInvalidPropertyAccessErrorPattern function as shown bellow:

// FireFox
getInvalidPropertyAccessErrorPattern(null);
// Pattern: /.+ is null/
getInvalidPropertyAccessErrorPattern(undefined);
// Pattern: /.+ is undefined/

// Chrome
getInvalidPropertyAccessErrorPattern(null);
// Pattern: /Cannot read property '.+' of null/
getInvalidPropertyAccessErrorPattern(undefined);
// Pattern: /Cannot read property '.+' of undefined/

// EDGE and IE11
getInvalidPropertyAccessErrorPattern(null);
// Pattern: /Unable to get property '.+' of undefined or null reference/
getInvalidPropertyAccessErrorPattern(undefined);
// Pattern: /Unable to get property '.+' of undefined or null reference/

Firefox

I am also getting sometimes a TypeError message only in FireFox version 52.
I guess this is related to the fact that in most of the browser you get the same error message but different ones for FF in the following cases:

Chrome
// Access to a property of an object set as undefined
var a = undefined;
a.someProperty
**TypeError: Cannot read property 'someProperty' of undefined**
// Access to a property of undefined (global object)
undefined.someProperty
**TypeError: Cannot read property 'someProperty' of undefined**

FireFox
// Access to a property of an object set as undefined
var a = undefined;
a.someProperty
**TypeError: a is undefined**
// Access to a property of undefined (global object)
undefined.someProperty
**TypeError: undefined has no properties**

IE and EDGE
// Access to a property of an object set as undefined
var a = undefined;
a.someProperty
**Unable to get property 'someProperty' of undefined or null reference**
// Access to a property of undefined (global object)
undefined.someProperty
**Unable to get property 'someProperty' of undefined or null reference**

@joselcc Thanks for investigating and providing all the actual patterns that materialize on the different browsers. This is way more thorough than anything I originally did because I never intended for the actual idx runtime function to be used in production.

Given that there may not be a way around this in Edge / IE and that babel-plugin-idx exists, I'm not sure there is much to be done here. What do you think?

FireFox
// Access to a property of an object set as undefined
var a = undefined;
a.someProperty
TypeError: a is undefined
// Access to a property of undefined (global object)
undefined.someProperty
TypeError: undefined has no properties

IE and EDGE
// Access to a property of an object set as undefined
var a = undefined;
a.someProperty
Unable to get property 'someProperty' of undefined or null reference
// Access to a property of undefined (global object)
undefined.someProperty
Unable to get property 'someProperty' of undefined or null reference

can I get solution to these errors