mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
make $parent access without key return undefined
This commit is contained in:
@@ -202,7 +202,7 @@ function getContextStorage(storage) {
|
||||
|
||||
function followParentContext(parent, key) {
|
||||
if (key === "$parent") {
|
||||
return [parent, ""];
|
||||
return [parent, undefined];
|
||||
}
|
||||
else if (key.startsWith("$parent.")) {
|
||||
var len = "$parent.".length;
|
||||
@@ -275,24 +275,16 @@ function createContext(id,seed,parent) {
|
||||
var result = followParentContext(parent, key);
|
||||
if (result) {
|
||||
var [ctx, new_key] = result;
|
||||
if (ctx) {
|
||||
if (new_key === "") {
|
||||
if (callback) {
|
||||
return callback(ctx);
|
||||
}
|
||||
else {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
if (ctx && new_key) {
|
||||
return ctx.get(new_key, storage, callback);
|
||||
}
|
||||
else {
|
||||
if (callback) {
|
||||
return callback(undefined);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
if (callback) {
|
||||
return callback(undefined);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -365,7 +357,7 @@ function createContext(id,seed,parent) {
|
||||
var result = followParentContext(parent, key);
|
||||
if (result) {
|
||||
var [ctx, new_key] = result;
|
||||
if (ctx) {
|
||||
if (ctx && new_key) {
|
||||
return ctx.set(new_key, value, storage, callback);
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user