aurelia / i18n

A plugin that provides i18n support.
MIT License
93 stars 70 forks source link

Bindable called 'text' cause error #218

Closed zoltanbedi closed 7 years ago

zoltanbedi commented 7 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: I have a custom element which has a bindable called text. I want to use the T attribute to localize this text like this: t="[text]Profile-Security" but aurelia fails to start with this error: ERROR [app-router] HierarchyRequestError: Failed to execute 'appendChild' on 'Node': This node type does not support this method. I saw in the I18N.prototype.updateValue function that text is a special string. Can you please change the implementation that if the value contains text then not to use the text case in the switch? Or is this confusing?

Expected/desired behavior:

zewa666 commented 7 years ago

Hmm that's a good question. Actually I think the plugin should give you a warning or at least handle the case somehow. I'll take a look at it next week, but we will definitely do something about it. Thanks for reporting

zewa666 commented 7 years ago

I thought about how we should go about this. Your proposed solution to change the predefined keys to be omitted if a bindable with the same name exists, sounds a bit contraproductive as it would disable the opportunity to do exactly what they're supposed to do. In most cases I do feel that a simple renaming/aliasing of your bindable should solve your issue. So what we could do instead is log a warning that a bindable has been detected using one of the reserved names. That would at least give you a hint on how to work around the issue. What do you think about this approach @B3zo0 ?

Here's a small example of how it would look like: 2017-05-29_08h08_27

The bug you have there sounds a little bit different though. Could you create a small example and upload it somewhere, so that I can take a look at it?

zoltanbedi commented 7 years ago

Hi @zewa666! I did rename my property so it won't cause error. I like that warning, I think it would make sense to print it if a property which is one of the reserved word can be found in the element. To be honest it was my fault because I didn't read the doc carefully it says that it is a reserved name. I'll create a gist later.

zewa666 commented 7 years ago

Yep thats the way to do it, only show the warning if the key is one of the reserved words. I'll create a PR in a min for that

zewa666 commented 7 years ago

@B3zo0 the recently released version should fix this issue.