@rxap/xml-parser
Version:
Provides a set of decorators and services for parsing and serializing XML documents into TypeScript classes. It simplifies the process of mapping XML elements and attributes to class properties, handling data validation, and serializing objects back into
21 lines (20 loc) • 906 B
TypeScript
/**
* A decorator factory that assigns a specific HTML tag name to a class and configures its metadata for element parsing.
*
* This function returns a decorator function that, when applied to a class, sets a static `TAG` property on the class
* to the provided `tag` argument. It also ensures that the class has metadata related to element parsing. If no parser
* metadata is present, it initializes an empty parser array in the metadata.
*
* @param tag The HTML tag name to be associated with the target class.
* @returns A class decorator that sets the `TAG` property and configures element parsing metadata on the target class.
*
* ### Example
* ```typescript
* @ElementDef('custom-element')
* class MyCustomElement {
* // class body
* }
* console.log(MyCustomElement.TAG); // Outputs: 'custom-element'
* ```
*/
export declare function ElementDef(tag: string): (target: any) => void;