mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 00:24:07 -08:00
fix(core): Handle item
, items
and $node
correctly in JS task runner (no-changelog) (#11660)
This commit is contained in:
parent
f1e2df7d07
commit
0a05aa4862
|
@ -62,6 +62,15 @@ describe('BuiltInsParser', () => {
|
|||
|
||||
expect(state).toEqual(new BuiltInsParserState({ needs$input: true }));
|
||||
});
|
||||
|
||||
test.each([['items'], ['item']])(
|
||||
'should mark input as needed when %s is used',
|
||||
(identifier) => {
|
||||
const state = parseAndExpectOk(`return ${identifier};`);
|
||||
|
||||
expect(state).toEqual(new BuiltInsParserState({ needs$input: true }));
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('$(...)', () => {
|
||||
|
@ -135,6 +144,13 @@ describe('BuiltInsParser', () => {
|
|||
);
|
||||
});
|
||||
|
||||
describe('$node', () => {
|
||||
it('should require all nodes when $node is used', () => {
|
||||
const state = parseAndExpectOk('return $node["name"];');
|
||||
expect(state).toEqual(new BuiltInsParserState({ needsAllNodes: true, needs$input: true }));
|
||||
});
|
||||
});
|
||||
|
||||
describe('ECMAScript syntax', () => {
|
||||
describe('ES2020', () => {
|
||||
it('should parse optional chaining', () => {
|
||||
|
|
|
@ -125,8 +125,19 @@ export class BuiltInsParser {
|
|||
private visitIdentifier = (node: Identifier, state: BuiltInsParserState) => {
|
||||
if (node.name === '$env') {
|
||||
state.markEnvAsNeeded();
|
||||
} else if (node.name === '$input' || node.name === '$json') {
|
||||
} else if (
|
||||
node.name === '$input' ||
|
||||
node.name === '$json' ||
|
||||
node.name === 'items' ||
|
||||
// item is deprecated but we still need to support it
|
||||
node.name === 'item'
|
||||
) {
|
||||
state.markInputAsNeeded();
|
||||
} else if (node.name === '$node') {
|
||||
// $node is legacy way of accessing any node's output. We need to
|
||||
// support it for backward compatibility, but we're not gonna
|
||||
// implement any optimizations
|
||||
state.markNeedsAllNodes();
|
||||
} else if (node.name === '$execution') {
|
||||
state.markExecutionAsNeeded();
|
||||
} else if (node.name === '$prevNode') {
|
||||
|
|
Loading…
Reference in a new issue