open-agreements
Version:
Open-source legal template filling CLI and library
29 lines • 1.26 kB
TypeScript
/**
* Defensive XML access helpers for OOXML-style DOMs.
*
* DOCX parts in the wild may mix namespace-bound attributes/elements with
* prefixed or bare names. These helpers centralize the fallback order without
* changing each caller's null handling.
*/
export type AttributeSafeOptions = {
/**
* Treat empty strings as missing and continue through fallbacks.
* Leave false for the canonical DOM getAttributeNS/getAttribute semantics.
*/
emptyIsMissing?: boolean;
/** Include a final bare local-name lookup after namespace/prefix fallbacks. */
bareFallback?: boolean;
};
/**
* Read an attribute by namespace, then optional prefix, then bare local name.
*/
export declare function getAttributeSafe(el: Element, ns: string, localName: string, prefix?: string, options?: AttributeSafeOptions): string | null;
/**
* Return the first descendant element matching namespace/local-name, or null.
*/
export declare function getFirstChild(parent: Element | Document, ns: string, localName: string): Element | null;
/**
* Return the first descendant element matching tag name, or null.
*/
export declare function findChild(parent: Element | Document, tagName: string): Element | null;
//# sourceMappingURL=xml-helpers.d.ts.map