SaxonJS 1.0.1 fails when calling the key() function; SaxonJS 1.0.0 works well
SaxonJS 1.0.1 stops with a message in the console when the key() function is called. My impression is that this happens during key initalization - it looks like if a null "flags" object is being dereferenced.
The message is:
Uncaught TypeError: Cannot read property 'indexOf' of null
I add a very small set of files that reproduces the problem. Use the html-file, click the button and watch the console.
#1 Updated by Debbie Lockett over 1 year ago
- Assignee set to Debbie Lockett
- Priority changed from Low to Normal
- Applies to JS Branch 1.0 added
Thanks for logging this Pieter, and producing the small example to reproduce the problem. There were some changes in the implementation of the key() function between releases 1.0.0 and 1.0.1 which have produced this bug. Should be straightforward to resolve!
#2 Updated by Pieter Masereeuw over 1 year ago
- Company set to Pieter Masereeuw
- Contact person set to Pieter Masereeuw
Yes, it took me some time to find the spot in my real application, but
after that, the error was surprisingly easy to reproduce.
On 10/05/2017 11:32 AM, Saxonica Developer Community wrote:
#3 Updated by Debbie Lockett over 1 year ago
- Status changed from New to Resolved
- Applies to JS Branch deleted (
- Fix Committed on JS Branch 1.0 added
The SEF supplied is generated using 220.127.116.11. Note that the bug is not produced when using an SEF generated by 18.104.22.168.
The Saxon-JS code changes between 1.0.0 and 1.0.1 were generally to handle changes in the SEF as produced by Saxon-EE 9.8 rather than 9.7. But unfortunately this bug slipped in causing the problem for 9.7 SEFs.
The problem is with the flags variable. The fix is to first check that there is actually a flags attribute on the declaration in the SEF, and if not, default to "" (rather than null, so that the subsequent flags.indexOf() call is OK). So:
var flags = keyDecl.getAttribute("flags");
is replaced by
var flags = keyDecl.hasAttribute("flags") ? keyDecl.getAttribute("flags") : "";
Fix committed on 1.0 branch. (The bug is not found in the trunk branch, due to other code improvements, e.g. the above check is already happening.)
Please register to edit this issue