Skip to content

Commit 133750a

Browse files
committed
allow static values as ifElse return values
1 parent 315d47f commit 133750a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

runner/src/builtins/if-else.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { type DocImpl, getDoc } from "../doc.ts";
2+
import { isCellLink } from "../cell.ts";
23
import { type Action } from "../scheduler.ts";
34
import { type ReactivityLog } from "../scheduler.ts";
4-
import { getCellLinkOrThrow } from "../query-result-proxy.ts";
5+
import { getCellLinkOrValue } from "../query-result-proxy.ts";
6+
57
export function ifElse(
68
inputsCell: DocImpl<[any, any, any]>,
79
sendResult: (result: any) => void,
@@ -15,9 +17,12 @@ export function ifElse(
1517
return (log: ReactivityLog) => {
1618
const condition = inputsCell.getAsQueryResult([0], log);
1719

18-
const ref = getCellLinkOrThrow(
20+
const current = getCellLinkOrValue(
1921
inputsCell.getAsQueryResult([condition ? 1 : 2], log),
2022
);
21-
result.send(ref.cell.getAtPath(ref.path), log);
23+
const value = isCellLink(current)
24+
? current.cell.getAtPath(current.path)
25+
: current;
26+
result.send(value, log);
2227
};
2328
}

0 commit comments

Comments
 (0)