Project

Profile

Help

Feature #5530

closed

For Saxon-JS under Node, expose global as ixsl:window() or ixsl:global()

Added by Martin Honnen over 2 years ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
IXSL extensions
Sprint/Milestone:
-
Start date:
2022-05-21
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2, Trunk
Fix Committed on JS Branch:
2, Trunk
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

For Saxon-JS in the browser, the function https://www.saxonica.com/saxon-js/documentation2/index.html#!ixsl-extension/functions/window gives access to the window object which is the gobal object in the browser environment. The global object under Node.js serves the same purpose but it isn't exposed in Saxon-JS under Node, it appears.

I think the use of JavaScript from Saxon-JS would benefit from having that global object exposed as e.g. ixsl:window(), or, if that breaks things, to create a new ixsl:global(), which, in the browser, returns the window object and under Node.sj returns the global object.

The reason: if you want, for instance, from XSLT/XPath call Javascript constructors like new URL(...), you can do so using e.g. Reflect.construct(URL, [...]) in JavaScript or ixsl:window() => ixsl:call('Reflect.construct', [ ixsl:window()?URL, [ ...] ]) in the browser but there is no way to do the same currently under Node.js as you would need to have ixsl:window() return the global object or you would need a new ixsl:global() to use e.g. ixsl:global() => ixsl:call('Reflect.construct', [ ixsl:global()?URL, [ ...] ]).


Related issues

Related to SaxonJS - Feature #5057: Constructing JS objectsClosed2021-08-07

Actions
Actions #1

Updated by Norm Tovey-Walsh over 2 years ago

That makes sense to me. I can't decide which I like better, abusing ixsl:window on Node.js to return the global object or adding a new ixsl:global function.

I would have sworn there was also a feature request on file to support calls to new without reflection, but I'm not able to locate it just at the moment.

Actions #3

Updated by Norm Tovey-Walsh over 2 years ago

Actions #4

Updated by Norm Tovey-Walsh over 2 years ago

  • Status changed from New to In Progress

I've sorted out a hack whereby the ixsl:window() function returns the global object on Node.js.

Actions #6

Updated by Michael Kay over 2 years ago

I'm inclined to stick with ixsl:window; but you could argue it both ways.

Actions #7

Updated by Debbie Lockett 8 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to SaxonJS 2.5
  • Applies to JS Branch 2, Trunk added
  • Fix Committed on JS Branch 2, Trunk added

The fix to return the global object on Node.js was committed on the saxonjs2 and main branches on 2022-05-23. So this change actually went out in the SaxonJS 2.5 maintenance release.

The documentation had not yet been updated, but I have now done that (committed on saxonjs2 and main). The SaxonJS 2 documentation online has been updated.

Please register to edit this issue

Also available in: Atom PDF Tracking page