PolymerElements / app-localize-behavior

Polymer behaviour to help internationalize your application
48 stars 55 forks source link

IE10 JavaScript error fix #30

Closed dlockhart closed 7 years ago

dlockhart commented 8 years ago

Fixes #29 ("Unable to set property 'messages' of undefined or null reference" JS error) by wrapping access to __localizationCache in checks, as it's undefined in IE10. This obviously results in no caching goodness for IE10. An alternate approach would be to use a different mechanism than the prototype for storing a singleton cache of values.

I didn't add a test since this really only happens in IE10. If you want to repro, you could likely wire your existing tests up to Sauce with IE10.

Feel free to use a different approach, or just close this and the associated issue outright if you don't care about IE10. Some of us however do need to deal with it for a bit longer, so in the meantime I'll need to work off a fork.

notwaldorf commented 8 years ago

Hmm, why is this null on IE10? Is it because you can't put things on the prototype?

cadwmaster commented 8 years ago

Also happens in Safari Mobile OS 7.x.

@dlockhart You could also extend the original behaviour with your custom one and overwrite only that function until having a proper solution ;)

dlockhart commented 8 years ago

@notwaldorf I don't think that's it. I created a basic example that has a single shared value between all instances of a class and uses the same this.constructor.prototype approach. I tested in IE10 and the results are the same as other browsers -- no issues accessing the prototype.

Might it be more related to how the definition of this behavior is getting upgraded to an object and instances of that object (one for each time the behavior gets applied to a WC) by Polymer?

notwaldorf commented 7 years ago

Sorry, I have merged https://github.com/PolymerElements/app-localize-behavior/pull/84 which does this as well