Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/registerCustomXPathFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ export function adaptXPathValueToJavascriptValue(
sequenceType.mult === SequenceMultiplicity.ONE_OR_MORE
) {
return valueSequence.getAllValues().map((value) => {
if (isSubtypeOf(value.type, ValueType.ATTRIBUTE)) {
throw new Error('Cannot pass attribute nodes to custom functions');
}
return transformXPathItemToJavascriptObject(value, executionParameters).next(
IterationHint.NONE,
).value;
Expand Down
13 changes: 6 additions & 7 deletions test/specs/parsing/registerCustomXPathFunction.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,12 @@ describe('registerCustomXPathFunction', () => {
);
});

it('disallows attributes as parameters', () => {
chai.assert.throws(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse this test as 'does allow attributes as parameters'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll reverse the logic!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and force-pushed changes.

() =>
evaluateXPathToString('test:custom-function3(//@*)', documentNode, null, null, {
namespaceResolver: identityNamespaceResolver,
}),
'Cannot pass attribute nodes',
it('allows attributes as parameters', () => {
chai.assert.equal(
evaluateXPathToString('test:custom-function3(//@*)', documentNode, null, null, {
namespaceResolver: identityNamespaceResolver,
}),
'someValue',
);
});

Expand Down
Loading