Hi,
I am testing fontoxpath in a modern browser environment (Chrome) and I've found that it currently doesn't support ShadowRoot as a contextNode.
In Chrome, a ShadowRoot has a nodeType of 11 (DOCUMENT_FRAGMENT_NODE). Currently, any attempt to evaluate an XPath expression against a ShadowRoot fails, regardless of whether the path is absolute or relative.
For example, the following fails when shadowRoot is passed as the context:
Absolute: //div
Relative: .//div
It appears the engine has strict internal checks (for example, in AbsolutePathExpression.ts and likely within the DomFacade traversal logic) that only recognize DOCUMENT_NODE (9) or ELEMENT_NODE (1) as valid entry points or roots.
Since Shadow DOM is a web standard and ShadowRoot acts as the logical root of a scoped tree, it should be treated as a valid context for XPath evaluation. This would allow fontoxpath to be used effectively with Web Components.
Could you please update the node type validation to include DOCUMENT_FRAGMENT_NODE? This would bring fontoxpath in line with modern browser DOM structures.
Tested on: Chrome (latest), fontoxpath (latest).
Hi,
I am testing fontoxpath in a modern browser environment (Chrome) and I've found that it currently doesn't support ShadowRoot as a contextNode.
In Chrome, a ShadowRoot has a nodeType of 11 (DOCUMENT_FRAGMENT_NODE). Currently, any attempt to evaluate an XPath expression against a ShadowRoot fails, regardless of whether the path is absolute or relative.
For example, the following fails when shadowRoot is passed as the context:
Absolute: //div
Relative: .//div
It appears the engine has strict internal checks (for example, in AbsolutePathExpression.ts and likely within the DomFacade traversal logic) that only recognize DOCUMENT_NODE (9) or ELEMENT_NODE (1) as valid entry points or roots.
Since Shadow DOM is a web standard and ShadowRoot acts as the logical root of a scoped tree, it should be treated as a valid context for XPath evaluation. This would allow fontoxpath to be used effectively with Web Components.
Could you please update the node type validation to include DOCUMENT_FRAGMENT_NODE? This would bring fontoxpath in line with modern browser DOM structures.
Tested on: Chrome (latest), fontoxpath (latest).