Skip to content

1.0rc1 - Config validation failure when reusing views configs #3353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kfeinUI opened this issue Feb 24, 2017 · 2 comments
Closed

1.0rc1 - Config validation failure when reusing views configs #3353

kfeinUI opened this issue Feb 24, 2017 · 2 comments
Milestone

Comments

@kfeinUI
Copy link

kfeinUI commented Feb 24, 2017

Ran into an interesting gotcha regarding the 1.0rc1 state configuration validation as I've been working on migrating from 0.x.

So I've got 2 states each having multiple views defined. For those views, they have the same config so I stored the object into a variable and plugged it into both. It's a simple config with a component and bindings. What I found is that a validation error would be raised on the second usage due to the presence of resolveAs on a component configuration. I tracked the issue down to ng1ViewsBuilder.js which modifies the input by applying a default value for resolveAs following the validation, thus making further usages invalid.

Obviously not a showstopper since the workaround is to simply apply a copy, but it was unexpected and may be worth looking at.

Otherwise the migration has been mostly smooth sailing! 1.0 addresses many of pain points of 0.x.

@christopherthielen
Copy link
Contributor

Otherwise the migration has been mostly smooth sailing! 1.0 addresses many of pain points of 0.x.

Lovely, that's great to hear!

I think in general it's a good idea not to share object references in state definitions. We use object equality checks in various places in the code, so sharing references can be dangerous.

I thought through a few options such as making resolveAs a valid option for component views, but I think it's better to reject resolveAs on a component view during validation because it's most likely a developer mistake. I appreciate the bug report, but I think we will close as WONTFIX.

@christopherthielen christopherthielen added this to the 1.0.0-rc.2 milestone Feb 26, 2017
@christopherthielen
Copy link
Contributor

I changed my mind. This is pretty easy to fix by making a shallow copy of the view declaration before processing it, and it seems pretty low risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants