Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

forceGetParentVarAtFqn returns non-object/non-array #144

Closed
whatsallthisthn opened this Issue · 4 comments

3 participants

@whatsallthisthn

on the client side now.js file you have a function util.createVarAtFqn, and it relies on util.forceGetParentVarAtFqn

the problem is when you try to set double-nested objects, like, lets say i had

now.blah0.blah1 = false;

and i want to change it to

now.blah0.blah1 = {blah2:blah3};

util.createVarAtFqn will sometimes try to set values of like blah3 before it changes blah1 from false into an object, and that will cause the currVal returned by util.forceGetParentVarAtFqn to be undefined, which fucks everything up

so i just added the lines

if ((typeof(currVar[prop]) !== "object")&&(typeof(currVar[prop]) !== "array")) {
currVar[prop] = {};
}

right before

currVar = currVar[prop];

and i think this fixes the problem, but i don't know if there are any unintended consequences, or whether the function was originally setup the way that it was for a reason

@steveWang

In fact you only need the first check, since arrays are actually objects. The better way to do it is as follows:

if (currVar[prop] && typeof currVar[prop] === "object") { 
  ...
}

since null is also considered to be an object but has a falsy value.

@ericz

Ahh indeed there is a bug here. I'll see what the repercussions of the fix might be

@ericz ericz closed this
@ericz ericz referenced this issue from a commit
@ericz ericz issue #144 de1ce43
@ericz

Fixed

@ericz ericz referenced this issue from a commit
@ericz ericz issue #144 bc849bd
@ericz ericz referenced this issue from a commit
@ericz ericz issue #144 for good bfd5157
@ericz

I couldn't actually reproduce the issue (couldnt get children to write before parent object was written) but I put the fix in for good measure as I determined there would be no issues created by it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.