fontoxpath
fontoxpath copied to clipboard
slimdom.DocumentFragment as context or variable
trafficstars
When I pass in a slimdom.DocumentFragment as the context or as the value of a variable, it doesn't seem to work correctly when converting to a string. I'm not sure if this is expected to work or not. I can't find anything in the spec about document fragments. So I'm reporting here, looking for more information.
const slimdom = require("slimdom")
const fontoxpath = require ("fontoxpath")
// Create the document <foo>Test</foo> and convert to string
let d = new slimdom.Document();
d.appendChild(d.createElement("foo"))
d.documentElement.appendChild(new slimdom.Text("Test"))
console.log(fontoxpath.evaluateXPathToString("string($d)", undefined, undefined, {d: d}));
console.log(fontoxpath.evaluateXPathToString("string(.)", d, undefined));
// Now try with a document fragment
let f = d.createDocumentFragment();
f.appendChild(d.createElement("foo"))
f.firstChild.appendChild(new slimdom.Text("Test"))
console.log(fontoxpath.evaluateXPathToString("string($f)", undefined, undefined, {f: f}));
console.log(fontoxpath.evaluateXPathToString("string(.)", f, undefined));
Expected results:
Test
Test
Test
Test
Actual results:
Test
Test
Interestingly, if I call console.log(fontoxpath.evaluateXPathToNodes(".", f, undefined)), it returns the node, so something seems to be happening here...