Project

Profile

Help

Bug #5058

closed

Document.createElementNS not implemented in saxon-js 2.2

Added by Michael Gunter over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
2021-08-08
Due date:
% Done:

100%

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

Description

I am currently using saxon-js 2.0.3, and my project runs without issues. I am using createElementNS to create qualified elements.

I have been trying to upgrade to saxon-js 2.2.0. However, my project now gets the following error. The createElementNS method is no longer defined. How does one create qualified elements in the newer version?

                    const linkElement = document.createElementNS("http://www.w3.org/1999/xhtml", "h:a");
                                                         ^
TypeError: document.createElementNS is not a function

Actions #1

Updated by Michael Gunter over 2 years ago

Environment is v14.17.3 on Windows 10.

Actions #2

Updated by Michael Gunter over 2 years ago

Environment is Node v14.17.3 on Windows 10.

Actions #3

Updated by Michael Kay over 2 years ago

How was the variable document initialised?

Saxon on Node.js includes a third-party DOM library, and a document node created using this library certainly does have the createElementNS() method. But your document object might have been created some other way, and be using a different DOM implementation. We would need to see a full repro that demonstrates the problem, I think.

It's also possible that the problem is something to do with the way the Closure compiler renames methods. It's possible that we omitted to mark this as a method name that's externally visible to the application and therefore shouldn't be renamed: we can check that.

Actions #5

Updated by Martin Honnen over 2 years ago

I have never tried to use the W3C DOM API with Saxon-JS 2 but a simple test with Saxon-JS 2.2 and Node.js of

const SaxonJS = require("saxon-js")

const document = SaxonJS.XPath.evaluate(`parse-xml('<html xmlns="http://www.w3.org/1999/xhtml"><body></body></html>')`, []);

console.log(document);

console.log(typeof document.createElement);

console.log(typeof document.createElementNS);

indeed outputs function for createElement but undefined for createElementNS.

Actions #6

Updated by Norm Tovey-Walsh over 2 years ago

  • Status changed from New to In Progress
  • Assignee set to Norm Tovey-Walsh
Actions #7

Updated by Norm Tovey-Walsh over 2 years ago

  • Priority changed from Low to Normal

I've confirmed that the problem is fixed by adding an extern for createElementNS. I've committed the fix.

Actions #9

Updated by Michael Gunter over 2 years ago

Thanks for the quick fix. I was meaning to put together an example but didn't have the time.

Actions #10

Updated by Norm Tovey-Walsh over 2 years ago

  • Status changed from In Progress to Resolved

For the next maintenance release, I've made a more principled fix, incorporating (the relevant parts of) the DOM1 and DOM2 externs. I believe this resolves the issue.

Actions #11

Updated by Debbie Lockett over 2 years ago

  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.3

Bug fix applied in the Saxon-JS 2.3 maintenance release.

Actions #12

Updated by Debbie Lockett over 2 years ago

  • Status changed from Resolved to Closed
Actions #13

Updated by Michael Gunter over 2 years ago

Confirmed this is fixed. Found another bug. Will create a new issue.

Please register to edit this issue

Also available in: Atom PDF Tracking page