@openxmldev/linq-to-xml
Version:
LINQ to XML for TypeScript
31 lines • 822 B
JavaScript
/**
* @author Thomas Barnekow
* @license MIT
*/
import { XDocument, XElement } from './internal.js';
/**
* Represents a node or an attribute in an XML tree.
*/
export class XObject {
constructor() {
/** @internal */
this._parent = null;
}
/**
* Gets the `XDocument` object for this `XObject`.
*/
get document() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let object = this;
while (object._parent)
object = object._parent;
return object instanceof XDocument ? object : null;
}
/**
* Gets the parent `XElement` of this `XObject`.
*/
get parent() {
return this._parent instanceof XElement ? this._parent : null;
}
}
//# sourceMappingURL=XObject.js.map