Skip to content
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

Uncaught TypeError: Cannot read property '_serverData' of undefined #93

Closed
astoilkov opened this issue Oct 3, 2015 · 6 comments · Fixed by #143
Closed

Uncaught TypeError: Cannot read property '_serverData' of undefined #93

astoilkov opened this issue Oct 3, 2015 · 6 comments · Fixed by #143
Labels

Comments

@astoilkov
Copy link
Owner

http://plnkr.co/edit/4UgROWV8wHbqozP7IdRy?p=preview

@astoilkov astoilkov added the bug label Oct 3, 2015
@Kanaye
Copy link
Collaborator

Kanaye commented May 20, 2016

This bug exsists because the blocks.clone method tries to create new View without the right context/arguments.
Possible ways to fix this:

    1. Implement a cloneable or _clonable propertie that would (if exsists and false) prevent from cloning an instance.
      Or
    1. Let blocks.clone search for a clone method on objects and if exsists use that return value. In the App.View we could just return a reference because a view is a singleton.

Both atemps have the disadvantage that we would need to implement a wrapper function for lodash/underscore once we remove jsvalue.

What do you think ?

Btw. the clone method and other (namely currently debug.*) are in the lib directory because they are originaly jsvalue/jscore functions. How should we handle modifications to them ?

@astoilkov
Copy link
Owner Author

Can you explain a little more? When and with what blocks.clone method is called so it tries to clone the App.View is there a way to just not call clone on the App.View object?

If the above is not possible I like the second idea more because not only fixes the problem but provides new functionality. Regarding the modifications there are two ways:
There is a private repository which have jsvalue inside.

  • I can do it
  • Or if it is interesting for you I can give you access to the private repository

@Kanaye
Copy link
Collaborator

Kanaye commented May 22, 2016

In the example linked above, we have nested model that get's called with an exsisting instance of an other model (in the example it's the User model that get's called with an Car instance called newCar).
The newCar instance will be cloned by the User constructor.
The newCar has an property _application (btw. that might be the better position to place a clone method or _clonable flag mentioned above) that Application has the ._views array.
When the views in that array get cloned the constructor does not get passed the right arguments and fails when calling View#_load() as that tries to access the property _serverData of the not passed Application instance.

When thinking about that we could also implement a check in the Model constructor if a passed argument is a Model instance and than handle it some other way.

Regarding access to the repository, I would love to get access.
It's normally easier to figure something out if you can see and modify all parts of it.
But in the end it's your dicission and I will respect it, as with every change I submit to the framework.

@astoilkov
Copy link
Owner Author

Perfect. I understand the problem now. I will give you access to the repository. I will do it tomorrow.

Happy to see you are interested. :)

@astoilkov
Copy link
Owner Author

I invited you. You could try and run the project. If you have any difficulties running it let me know there.

Kanaye pushed a commit to Kanaye/jscore that referenced this issue May 24, 2016
@Kanaye
Copy link
Collaborator

Kanaye commented May 24, 2016

Awesome! Thank you!
I will look into jsvalue deeper once I start to fix the bug related to it and when I have time again.
I created a PR for the clone change in the jscore repository.
I will push a PR containing the updated 'lib/blocks/core.js' and some other changes with clone implmentations, including the both mentioned above, probably tomorrow.
I found a bug with the clone implementation in Model.clone I want to fix before I push anything.

Kanaye pushed a commit to Kanaye/jsblocks that referenced this issue May 25, 2016
'Fixed' clone implementation for Model (now returns a Model with all
protoypes properties not only all App.Properties).

Model constructor now clones 'prototype' and 'dataItem' otherwise
obervables in nested models won't be cloned.

Fixes astoilkov#93
@Kanaye Kanaye mentioned this issue May 25, 2016
astoilkov added a commit that referenced this issue May 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants