Bug #5058
closed
Document.createElementNS not implemented in saxon-js 2.2
Fix Committed on JS Branch:
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
Environment is v14.17.3 on Windows 10.
Environment is Node v14.17.3 on Windows 10.
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.
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
.
- Status changed from New to In Progress
- Assignee set to Norm Tovey-Walsh
- 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.
Thanks for the quick fix. I was meaning to put together an example but didn't have the time.
- 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.
- % 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.
- Status changed from Resolved to Closed
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