Static
bodyStatic
documentStatic
addAdd event listener with SSR protection This is one of the few element methods we keep as it has special SSR handling
Optional
options: boolean | AddEventListenerOptionsStatic
configureConfigure the shim with custom DOM implementation.
Static
createStatic
createStatic
initializeInitialize the shim by attempting to detect browser environment. If in a browser, use the native DOM objects; otherwise, leave them unset.
Static
isCheck if code is running in a browser environment. This can be useful for conditional logic based on environment.
Static
isHTMLElementStatic
isOptional
value: booleanStatic
isCheck if DOM shim is using a custom (non-browser) implementation.
Static
queryOptional
node: ParentNodeStatic
queryOptional
node: ParentNode
DOMShim provides a configurable interface for core DOM operations.
This allows Campfire to work in both browser environments (using native DOM) and server environments (using a DOM implementation like jsdom or happy-dom).
Usage examples:
Browser environment (automatic initialization):
Server-side rendering with custom DOM implementation:
Note: This implementation uses a "minimal API" approach, where only document-level methods (createElement, querySelector, etc.) are provided by CfDom, and element-level operations are performed directly on the elements themselves.