Closed whatsallthisthn closed 13 years ago
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.
Ahh indeed there is a bug here. I'll see what the repercussions of the fix might be
Fixed
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
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