You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bit of an edge case, but we were passing an object to traverse that could possibly be undefined, then using has to check if the object contained or not a path. Then if it returns false we would do something else.
It worked fine in 0.6.8, but since we updated has always returned true in those cases, which obviously seems wrong.
I tracked it to here where node && was added in the for loop, causing it to always return true when the node is undefined.
/** @type {(ps: PropertyKey[]) => boolean} */
Traverse.prototype.has = function (ps) {
var node = this.value;
for (var i = 0; node && i < ps.length; i++) {
var key = ps[i];
if (!hasOwnProperty.call(node, key) || (!this.options.includeSymbols && typeof key === 'symbol')) {
return false;
}
node = node[key];
}
return true;
};
require('.')(undefined).has([]) seems to return true for me in every traverse version, including v0.6.8 - however, require('.')(undefined).has(['my', 'path']) indeed returns false until v0.6.9.
A bit of an edge case, but we were passing an object to traverse that could possibly be
undefined
, then usinghas
to check if the object contained or not a path. Then if it returnsfalse
we would do something else.It worked fine in
0.6.8
, but since we updatedhas
always returnedtrue
in those cases, which obviously seems wrong.I tracked it to here where
node &&
was added in thefor
loop, causing it to always returntrue
when the node isundefined
.Here an example
I'm gonna fix it on our side since there's no point in even calling
traverse
in those cases, but felt I should report it anyway.The text was updated successfully, but these errors were encountered: