Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Validate contextPath state on store #344

Merged
merged 1 commit into from
Apr 1, 2014
Merged

Conversation

kpdecker
Copy link
Contributor

The server marshal should validate that the context path value is correct on save to ensure that lookup will occur safely when restoring on the client side.

@kpdecker kpdecker added this to the 3.0 milestone Mar 28, 2014
@@ -36,14 +37,14 @@ var ServerMarshal = Thorax.ServerMarshal = {
if (_.isArray(attributes) && !_.isString(attributeIds) && !attributes.toJSON) {
if (attributes.length) {
cache[name] = _.map(attributes, function(value, key) {
return lookupValue(value, attributeIds[key], contextPath);
return lookupValue(value, attributeIds[key], contextPath, data.view, data.root);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just pass data as a third argument instead of its three attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the data structure that is passed to handlebars helpers, which is the primary use case for this, so the nesting felt like the proper thing to do in this particular case.

Ensure that ServerMarshal.store generated lookup paths refer to the same object that is passed in. This prevents us from running into issues on the client where there is no hope of a safe recovery.
@kpdecker
Copy link
Contributor Author

kpdecker commented Apr 1, 2014

@candid went ahead and made the data object optional.

kpdecker added a commit that referenced this pull request Apr 1, 2014
@kpdecker kpdecker merged commit d9446ad into master Apr 1, 2014
@kpdecker kpdecker deleted the marshal-store-lookup branch April 1, 2014 19:46
@kpdecker
Copy link
Contributor Author

kpdecker commented Apr 1, 2014

Released in v3.0.0-alpha.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

2 participants