index.d.ts 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. declare module '@xmldom/xmldom' {
  2. // START ./lib/conventions.js
  3. /**
  4. * Since xmldom can not rely on `Object.assign`,
  5. * it uses/provides a simplified version that is sufficient for its needs.
  6. *
  7. * @throws {TypeError}
  8. * If target is not an object.
  9. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  10. * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
  11. */
  12. function assign<T, S>(target: T, source: S): T & S;
  13. /**
  14. * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that
  15. * the HTML namespace is provided as the default.
  16. *
  17. * @param {string} mimeType
  18. * @returns {boolean}
  19. * @see https://dom.spec.whatwg.org/#dom-document-createelement
  20. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
  21. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
  22. */
  23. function hasDefaultHTMLNamespace(
  24. mimeType: string
  25. ): mimeType is typeof MIME_TYPE.HTML | typeof MIME_TYPE.XML_XHTML_APPLICATION;
  26. /**
  27. * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.
  28. *
  29. * @see https://www.iana.org/assignments/media-types/text/html
  30. * @see https://en.wikipedia.org/wiki/HTML
  31. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
  32. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
  33. */
  34. function isHTMLMimeType(mimeType: string): mimeType is typeof MIME_TYPE.HTML;
  35. /**
  36. * Only returns true if `mimeType` is one of the allowed values for `DOMParser.parseFromString`.
  37. */
  38. function isValidMimeType(mimeType: string): mimeType is MIME_TYPE;
  39. /**
  40. * All mime types that are allowed as input to `DOMParser.parseFromString`
  41. *
  42. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
  43. * MDN
  44. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
  45. * WHATWG HTML Spec
  46. * @see {@link DOMParser.prototype.parseFromString}
  47. */
  48. type MIME_TYPE = (typeof MIME_TYPE)[keyof typeof MIME_TYPE];
  49. /**
  50. * All mime types that are allowed as input to `DOMParser.parseFromString`
  51. *
  52. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
  53. * MDN
  54. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
  55. * WHATWG HTML Spec
  56. * @see {@link DOMParser.prototype.parseFromString}
  57. */
  58. var MIME_TYPE: {
  59. /**
  60. * `text/html`, the only mime type that triggers treating an XML document as HTML.
  61. *
  62. * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
  63. * @see https://en.wikipedia.org/wiki/HTML Wikipedia
  64. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
  65. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
  66. * WHATWG HTML Spec
  67. */
  68. readonly HTML: 'text/html';
  69. /**
  70. * `application/xml`, the standard mime type for XML documents.
  71. *
  72. * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
  73. * registration
  74. * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
  75. * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
  76. */
  77. readonly XML_APPLICATION: 'application/xml';
  78. /**
  79. * `text/html`, an alias for `application/xml`.
  80. *
  81. * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
  82. * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
  83. * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
  84. */
  85. readonly XML_TEXT: 'text/xml';
  86. /**
  87. * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
  88. * but is parsed as an XML document.
  89. *
  90. * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
  91. * registration
  92. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
  93. * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
  94. */
  95. readonly XML_XHTML_APPLICATION: 'application/xhtml+xml';
  96. /**
  97. * `image/svg+xml`,
  98. *
  99. * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
  100. * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
  101. * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
  102. */
  103. readonly XML_SVG_IMAGE: 'image/svg+xml';
  104. };
  105. /**
  106. * Namespaces that are used in xmldom.
  107. *
  108. * @see http://www.w3.org/TR/REC-xml-names
  109. */
  110. type NAMESPACE = (typeof NAMESPACE)[keyof typeof NAMESPACE];
  111. /**
  112. * Namespaces that are used in xmldom.
  113. *
  114. * @see http://www.w3.org/TR/REC-xml-names
  115. */
  116. var NAMESPACE: {
  117. /**
  118. * The XHTML namespace.
  119. *
  120. * @see http://www.w3.org/1999/xhtml
  121. */
  122. readonly HTML: 'http://www.w3.org/1999/xhtml';
  123. /**
  124. * The SVG namespace.
  125. *
  126. * @see http://www.w3.org/2000/svg
  127. */
  128. readonly SVG: 'http://www.w3.org/2000/svg';
  129. /**
  130. * The `xml:` namespace.
  131. *
  132. * @see http://www.w3.org/XML/1998/namespace
  133. */
  134. readonly XML: 'http://www.w3.org/XML/1998/namespace';
  135. /**
  136. * The `xmlns:` namespace.
  137. *
  138. * @see https://www.w3.org/2000/xmlns/
  139. */
  140. readonly XMLNS: 'http://www.w3.org/2000/xmlns/';
  141. };
  142. // END ./lib/conventions.js
  143. // START ./lib/errors.js
  144. type DOMExceptionName =
  145. (typeof DOMExceptionName)[keyof typeof DOMExceptionName];
  146. var DOMExceptionName: {
  147. /**
  148. * the default value as defined by the spec
  149. */
  150. readonly Error: 'Error';
  151. /**
  152. * @deprecated
  153. * Use RangeError instead.
  154. */
  155. readonly IndexSizeError: 'IndexSizeError';
  156. /**
  157. * @deprecated
  158. * Just to match the related static code, not part of the spec.
  159. */
  160. readonly DomstringSizeError: 'DomstringSizeError';
  161. readonly HierarchyRequestError: 'HierarchyRequestError';
  162. readonly WrongDocumentError: 'WrongDocumentError';
  163. readonly InvalidCharacterError: 'InvalidCharacterError';
  164. /**
  165. * @deprecated
  166. * Just to match the related static code, not part of the spec.
  167. */
  168. readonly NoDataAllowedError: 'NoDataAllowedError';
  169. readonly NoModificationAllowedError: 'NoModificationAllowedError';
  170. readonly NotFoundError: 'NotFoundError';
  171. readonly NotSupportedError: 'NotSupportedError';
  172. readonly InUseAttributeError: 'InUseAttributeError';
  173. readonly InvalidStateError: 'InvalidStateError';
  174. readonly SyntaxError: 'SyntaxError';
  175. readonly InvalidModificationError: 'InvalidModificationError';
  176. readonly NamespaceError: 'NamespaceError';
  177. /**
  178. * @deprecated
  179. * Use TypeError for invalid arguments,
  180. * "NotSupportedError" DOMException for unsupported operations,
  181. * and "NotAllowedError" DOMException for denied requests instead.
  182. */
  183. readonly InvalidAccessError: 'InvalidAccessError';
  184. /**
  185. * @deprecated
  186. * Just to match the related static code, not part of the spec.
  187. */
  188. readonly ValidationError: 'ValidationError';
  189. /**
  190. * @deprecated
  191. * Use TypeError instead.
  192. */
  193. readonly TypeMismatchError: 'TypeMismatchError';
  194. readonly SecurityError: 'SecurityError';
  195. readonly NetworkError: 'NetworkError';
  196. readonly AbortError: 'AbortError';
  197. /**
  198. * @deprecated
  199. * Just to match the related static code, not part of the spec.
  200. */
  201. readonly URLMismatchError: 'URLMismatchError';
  202. readonly QuotaExceededError: 'QuotaExceededError';
  203. readonly TimeoutError: 'TimeoutError';
  204. readonly InvalidNodeTypeError: 'InvalidNodeTypeError';
  205. readonly DataCloneError: 'DataCloneError';
  206. readonly EncodingError: 'EncodingError';
  207. readonly NotReadableError: 'NotReadableError';
  208. readonly UnknownError: 'UnknownError';
  209. readonly ConstraintError: 'ConstraintError';
  210. readonly DataError: 'DataError';
  211. readonly TransactionInactiveError: 'TransactionInactiveError';
  212. readonly ReadOnlyError: 'ReadOnlyError';
  213. readonly VersionError: 'VersionError';
  214. readonly OperationError: 'OperationError';
  215. readonly NotAllowedError: 'NotAllowedError';
  216. readonly OptOutError: 'OptOutError';
  217. };
  218. type ExceptionCode = (typeof ExceptionCode)[keyof typeof ExceptionCode];
  219. var ExceptionCode: {
  220. readonly INDEX_SIZE_ERR: 1;
  221. readonly DOMSTRING_SIZE_ERR: 2;
  222. readonly HIERARCHY_REQUEST_ERR: 3;
  223. readonly WRONG_DOCUMENT_ERR: 4;
  224. readonly INVALID_CHARACTER_ERR: 5;
  225. readonly NO_DATA_ALLOWED_ERR: 6;
  226. readonly NO_MODIFICATION_ALLOWED_ERR: 7;
  227. readonly NOT_FOUND_ERR: 8;
  228. readonly NOT_SUPPORTED_ERR: 9;
  229. readonly INUSE_ATTRIBUTE_ERR: 10;
  230. readonly INVALID_STATE_ERR: 11;
  231. readonly SYNTAX_ERR: 12;
  232. readonly INVALID_MODIFICATION_ERR: 13;
  233. readonly NAMESPACE_ERR: 14;
  234. readonly INVALID_ACCESS_ERR: 15;
  235. readonly VALIDATION_ERR: 16;
  236. readonly TYPE_MISMATCH_ERR: 17;
  237. readonly SECURITY_ERR: 18;
  238. readonly NETWORK_ERR: 19;
  239. readonly ABORT_ERR: 20;
  240. readonly URL_MISMATCH_ERR: 21;
  241. readonly QUOTA_EXCEEDED_ERR: 22;
  242. readonly TIMEOUT_ERR: 23;
  243. readonly INVALID_NODE_TYPE_ERR: 24;
  244. readonly DATA_CLONE_ERR: 25;
  245. };
  246. /**
  247. * DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an
  248. * operation is impossible to perform (either for logical reasons, because data is lost, or
  249. * because the implementation has become unstable). In general, DOM methods return specific
  250. * error values in ordinary processing situations, such as out-of-bound errors when using
  251. * NodeList.
  252. *
  253. * Implementations should raise other exceptions under other circumstances. For example,
  254. * implementations should raise an implementation-dependent exception if a null argument is
  255. * passed when null was not expected.
  256. *
  257. * This implementation supports the following usages:
  258. * 1. according to the living standard (both arguments are optional):
  259. * ```
  260. * new DOMException("message (can be empty)", DOMExceptionNames.HierarchyRequestError)
  261. * ```
  262. * 2. according to previous xmldom implementation (only the first argument is required):
  263. * ```
  264. * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "optional message")
  265. * ```
  266. * both result in the proper name being set.
  267. *
  268. * @see https://webidl.spec.whatwg.org/#idl-DOMException
  269. * @see https://webidl.spec.whatwg.org/#dfn-error-names-table
  270. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187
  271. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
  272. * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
  273. */
  274. class DOMException extends Error {
  275. constructor(message?: string, name?: DOMExceptionName | string);
  276. constructor(code?: ExceptionCode, message?: string);
  277. readonly name: DOMExceptionName;
  278. readonly code: ExceptionCode | 0;
  279. static readonly INDEX_SIZE_ERR: 1;
  280. static readonly DOMSTRING_SIZE_ERR: 2;
  281. static readonly HIERARCHY_REQUEST_ERR: 3;
  282. static readonly WRONG_DOCUMENT_ERR: 4;
  283. static readonly INVALID_CHARACTER_ERR: 5;
  284. static readonly NO_DATA_ALLOWED_ERR: 6;
  285. static readonly NO_MODIFICATION_ALLOWED_ERR: 7;
  286. static readonly NOT_FOUND_ERR: 8;
  287. static readonly NOT_SUPPORTED_ERR: 9;
  288. static readonly INUSE_ATTRIBUTE_ERR: 10;
  289. static readonly INVALID_STATE_ERR: 11;
  290. static readonly SYNTAX_ERR: 12;
  291. static readonly INVALID_MODIFICATION_ERR: 13;
  292. static readonly NAMESPACE_ERR: 14;
  293. static readonly INVALID_ACCESS_ERR: 15;
  294. static readonly VALIDATION_ERR: 16;
  295. static readonly TYPE_MISMATCH_ERR: 17;
  296. static readonly SECURITY_ERR: 18;
  297. static readonly NETWORK_ERR: 19;
  298. static readonly ABORT_ERR: 20;
  299. static readonly URL_MISMATCH_ERR: 21;
  300. static readonly QUOTA_EXCEEDED_ERR: 22;
  301. static readonly TIMEOUT_ERR: 23;
  302. static readonly INVALID_NODE_TYPE_ERR: 24;
  303. static readonly DATA_CLONE_ERR: 25;
  304. }
  305. /**
  306. * Creates an error that will not be caught by XMLReader aka the SAX parser.
  307. */
  308. class ParseError extends Error {
  309. constructor(message: string, locator?: any, cause?: Error);
  310. readonly message: string;
  311. readonly locator?: any;
  312. }
  313. // END ./lib/errors.js
  314. // START ./lib/dom.js
  315. type InstanceOf<T> = {
  316. // instanceof pre ts 5.3
  317. (val: unknown): val is T;
  318. // instanceof post ts 5.3
  319. [Symbol.hasInstance](val: unknown): val is T;
  320. };
  321. type GetRootNodeOptions = {
  322. composed?: boolean;
  323. };
  324. /**
  325. * The DOM Node interface is an abstract base class upon which many other DOM API objects are
  326. * based, thus letting those object types to be used similarly and often interchangeably. As an
  327. * abstract class, there is no such thing as a plain Node object. All objects that implement
  328. * Node functionality are based on one of its subclasses. Most notable are Document, Element,
  329. * and DocumentFragment.
  330. *
  331. * In addition, every kind of DOM node is represented by an interface based on Node. These
  332. * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are
  333. * all based on), and DocumentType.
  334. *
  335. * In some cases, a particular feature of the base Node interface may not apply to one of its
  336. * child interfaces; in that case, the inheriting node may return null or throw an exception,
  337. * depending on circumstances. For example, attempting to add children to a node type that
  338. * cannot have children will throw an exception.
  339. *
  340. * **This behavior is slightly different from the in the specs**:
  341. * - unimplemented interfaces: EventTarget
  342. *
  343. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
  344. * @see https://dom.spec.whatwg.org/#node
  345. * @prettierignore
  346. */
  347. interface Node {
  348. /**
  349. * Returns the children.
  350. *
  351. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/childNodes)
  352. */
  353. readonly childNodes: NodeList;
  354. /**
  355. * Returns the first child.
  356. *
  357. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/firstChild)
  358. */
  359. readonly firstChild: Node | null;
  360. /**
  361. * Returns the last child.
  362. *
  363. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lastChild)
  364. */
  365. readonly lastChild: Node | null;
  366. /**
  367. * The local part of the qualified name of this node.
  368. */
  369. localName: string | null;
  370. /**
  371. * Always returns `about:blank` currently.
  372. *
  373. * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI)
  374. */
  375. readonly baseURI: 'about:blank';
  376. /**
  377. * Returns true if this node is inside of a document or is the document node itself.
  378. *
  379. * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected)
  380. */
  381. readonly isConnected: boolean;
  382. /**
  383. * The namespace URI of this node.
  384. */
  385. readonly namespaceURI: string | null;
  386. /**
  387. * Returns the next sibling.
  388. *
  389. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)
  390. */
  391. readonly nextSibling: Node | null;
  392. /**
  393. * Returns a string appropriate for the type of node.
  394. *
  395. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeName)
  396. */
  397. readonly nodeName: string;
  398. /**
  399. * Returns the type of node.
  400. *
  401. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeType)
  402. */
  403. readonly nodeType: number;
  404. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) */
  405. nodeValue: string | null;
  406. /**
  407. * Returns the node document. Returns null for documents.
  408. *
  409. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument)
  410. */
  411. readonly ownerDocument: Document | null;
  412. /**
  413. * Returns the parent.
  414. *
  415. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentNode)
  416. */
  417. readonly parentNode: Node | null;
  418. /**
  419. * Returns the parent `Node` if it is of type `Element`, otherwise `null`.
  420. *
  421. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentElement)
  422. */
  423. readonly parentElement: Element | null;
  424. /**
  425. * The prefix of the namespace for this node.
  426. */
  427. prefix: string | null;
  428. /**
  429. * Returns the previous sibling.
  430. *
  431. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/previousSibling)
  432. */
  433. readonly previousSibling: Node | null;
  434. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/textContent) */
  435. textContent: string | null;
  436. /**
  437. * Zero based line position inside the parsed source,
  438. * if the `locator` was not disabled.
  439. */
  440. lineNumber?: number;
  441. /**
  442. * One based column position inside the parsed source,
  443. * if the `locator` was not disabled.
  444. */
  445. columnNumber?: number;
  446. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/appendChild) */
  447. appendChild(node: Node): Node;
  448. /**
  449. * Checks whether `other` is an inclusive descendant of this node.
  450. *
  451. * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/contains)
  452. */
  453. contains(other: Node | null | undefined): boolean;
  454. /**
  455. * Searches for the root node of this node.
  456. *
  457. * **This behavior is slightly different from the one in the specs**:
  458. * - ignores `options.composed`, since `ShadowRoot`s are unsupported, therefore always
  459. * returning root.
  460. *
  461. * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode)
  462. *
  463. * @see https://dom.spec.whatwg.org/#dom-node-getrootnode
  464. * @see https://dom.spec.whatwg.org/#concept-shadow-including-root
  465. */
  466. getRootNode(options: GetRootNodeOptions): Node;
  467. /**
  468. * Checks whether the given node is equal to this node.
  469. *
  470. * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isEqualNode)
  471. */
  472. isEqualNode(other: Node): boolean;
  473. /**
  474. * Checks whether the given node is this node.
  475. *
  476. * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isSameNode)
  477. */
  478. isSameNode(other: Node): boolean;
  479. /**
  480. * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
  481. *
  482. * @throws {DOMException}
  483. * May throw a DOMException if operations within {@link Element#setAttributeNode} or
  484. * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their
  485. * specific constraints.
  486. *
  487. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/cloneNode)
  488. */
  489. cloneNode(deep?: boolean): Node;
  490. /**
  491. * Returns a bitmask indicating the position of other relative to node.
  492. *
  493. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/compareDocumentPosition)
  494. */
  495. compareDocumentPosition(other: Node): number;
  496. /**
  497. * Returns whether node has children.
  498. *
  499. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/hasChildNodes)
  500. */
  501. hasChildNodes(): boolean;
  502. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/insertBefore) */
  503. insertBefore(node: Node, child: Node | null): Node;
  504. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/isDefaultNamespace) */
  505. isDefaultNamespace(namespace: string | null): boolean;
  506. /**
  507. * Checks whether the DOM implementation implements a specific feature and its version.
  508. *
  509. * @deprecated
  510. * Since `DOMImplementation.hasFeature` is deprecated and always returns true.
  511. * @param feature
  512. * The package name of the feature to test. This is the same name that can be passed to the
  513. * method `hasFeature` on `DOMImplementation`.
  514. * @param version
  515. * This is the version number of the package name to test.
  516. * @since Introduced in DOM Level 2
  517. * @see {@link DOMImplementation.hasFeature}
  518. */
  519. isSupported(feature: string, version: string): true;
  520. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lookupNamespaceURI) */
  521. lookupNamespaceURI(prefix: string | null): string | null;
  522. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lookupPrefix) */
  523. lookupPrefix(namespace: string | null): string | null;
  524. /**
  525. * Removes empty exclusive Text nodes and concatenates the data of remaining contiguous
  526. * exclusive Text nodes into the first of their nodes.
  527. *
  528. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/normalize)
  529. */
  530. normalize(): void;
  531. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/removeChild) */
  532. removeChild(child: Node): Node;
  533. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/replaceChild) */
  534. replaceChild(node: Node, child: Node): Node;
  535. /** node is an element. */
  536. readonly ELEMENT_NODE: 1;
  537. readonly ATTRIBUTE_NODE: 2;
  538. /** node is a Text node. */
  539. readonly TEXT_NODE: 3;
  540. /** node is a CDATASection node. */
  541. readonly CDATA_SECTION_NODE: 4;
  542. readonly ENTITY_REFERENCE_NODE: 5;
  543. readonly ENTITY_NODE: 6;
  544. /** node is a ProcessingInstruction node. */
  545. readonly PROCESSING_INSTRUCTION_NODE: 7;
  546. /** node is a Comment node. */
  547. readonly COMMENT_NODE: 8;
  548. /** node is a document. */
  549. readonly DOCUMENT_NODE: 9;
  550. /** node is a doctype. */
  551. readonly DOCUMENT_TYPE_NODE: 10;
  552. /** node is a DocumentFragment node. */
  553. readonly DOCUMENT_FRAGMENT_NODE: 11;
  554. readonly NOTATION_NODE: 12;
  555. /** Set when node and other are not in the same tree. */
  556. readonly DOCUMENT_POSITION_DISCONNECTED: 0x01;
  557. /** Set when other is preceding node. */
  558. readonly DOCUMENT_POSITION_PRECEDING: 0x02;
  559. /** Set when other is following node. */
  560. readonly DOCUMENT_POSITION_FOLLOWING: 0x04;
  561. /** Set when other is an ancestor of node. */
  562. readonly DOCUMENT_POSITION_CONTAINS: 0x08;
  563. /** Set when other is a descendant of node. */
  564. readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
  565. readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
  566. }
  567. var Node: InstanceOf<Node> & {
  568. /** node is an element. */
  569. readonly ELEMENT_NODE: 1;
  570. readonly ATTRIBUTE_NODE: 2;
  571. /** node is a Text node. */
  572. readonly TEXT_NODE: 3;
  573. /** node is a CDATASection node. */
  574. readonly CDATA_SECTION_NODE: 4;
  575. readonly ENTITY_REFERENCE_NODE: 5;
  576. readonly ENTITY_NODE: 6;
  577. /** node is a ProcessingInstruction node. */
  578. readonly PROCESSING_INSTRUCTION_NODE: 7;
  579. /** node is a Comment node. */
  580. readonly COMMENT_NODE: 8;
  581. /** node is a document. */
  582. readonly DOCUMENT_NODE: 9;
  583. /** node is a doctype. */
  584. readonly DOCUMENT_TYPE_NODE: 10;
  585. /** node is a DocumentFragment node. */
  586. readonly DOCUMENT_FRAGMENT_NODE: 11;
  587. readonly NOTATION_NODE: 12;
  588. /** Set when node and other are not in the same tree. */
  589. readonly DOCUMENT_POSITION_DISCONNECTED: 0x01;
  590. /** Set when other is preceding node. */
  591. readonly DOCUMENT_POSITION_PRECEDING: 0x02;
  592. /** Set when other is following node. */
  593. readonly DOCUMENT_POSITION_FOLLOWING: 0x04;
  594. /** Set when other is an ancestor of node. */
  595. readonly DOCUMENT_POSITION_CONTAINS: 0x08;
  596. /** Set when other is a descendant of node. */
  597. readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
  598. readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
  599. };
  600. /**
  601. * A DOM element's attribute as an object. In most DOM methods, you will probably directly
  602. * retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g.,
  603. * Element.getAttributeNode()) or means of iterating give Attr types.
  604. *
  605. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr)
  606. */
  607. interface Attr extends Node {
  608. readonly nodeType: typeof Node.ATTRIBUTE_NODE;
  609. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/name) */
  610. readonly name: string;
  611. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/namespaceURI) */
  612. readonly namespaceURI: string | null;
  613. readonly ownerDocument: Document;
  614. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/ownerElement) */
  615. readonly ownerElement: Element | null;
  616. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/prefix) */
  617. readonly prefix: string | null;
  618. /**
  619. * @deprecated
  620. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/specified)
  621. */
  622. readonly specified: true;
  623. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */
  624. value: string;
  625. }
  626. /**
  627. * A DOM element's attribute as an object. In most DOM methods, you will probably directly
  628. * retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g.,
  629. * Element.getAttributeNode()) or means of iterating give Attr types.
  630. *
  631. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr)
  632. */
  633. var Attr: InstanceOf<Attr>;
  634. /**
  635. * Objects implementing the NamedNodeMap interface are used to represent collections of nodes
  636. * that can be accessed by name.
  637. * Note that NamedNodeMap does not inherit from NodeList;
  638. * NamedNodeMaps are not maintained in any particular order.
  639. * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal
  640. * index,
  641. * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
  642. * and does not imply that the DOM specifies an order to these Nodes.
  643. * NamedNodeMap objects in the DOM are live.
  644. * used for attributes or DocumentType entities
  645. *
  646. * This implementation only supports property indices, but does not support named properties,
  647. * as specified in the living standard.
  648. *
  649. * @see https://dom.spec.whatwg.org/#interface-namednodemap
  650. * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names
  651. */
  652. class NamedNodeMap implements Iterable<Attr> {
  653. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/length) */
  654. readonly length: number;
  655. /**
  656. * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and
  657. * document.
  658. *
  659. * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
  660. */
  661. getNamedItem(qualifiedName: string): Attr | null;
  662. /**
  663. * Get an attribute by namespace and local name.
  664. *
  665. * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
  666. */
  667. getNamedItemNS(namespace: string | null, localName: string): Attr | null;
  668. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/item) */
  669. item(index: number): Attr | null;
  670. /**
  671. * Removes an attribute specified by the local name.
  672. *
  673. * @throws {DOMException}
  674. * With code:
  675. * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.
  676. * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
  677. * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
  678. */
  679. removeNamedItem(qualifiedName: string): Attr;
  680. /**
  681. * Removes an attribute specified by the namespace and local name.
  682. *
  683. * @throws {DOMException}
  684. * With code:
  685. * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and
  686. * local name is found.
  687. * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
  688. * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
  689. */
  690. removeNamedItemNS(namespace: string | null, localName: string): Attr;
  691. /**
  692. * Set an attribute.
  693. *
  694. * @throws {DOMException}
  695. * With code:
  696. * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another
  697. * element.
  698. * @see https://dom.spec.whatwg.org/#concept-element-attributes-set
  699. */
  700. setNamedItem(attr: Attr): Attr | null;
  701. /**
  702. * Set an attribute, replacing an existing attribute with the same local name and namespace
  703. * URI if one exists.
  704. *
  705. * @throws {DOMException}
  706. * Throws a DOMException with the name "InUseAttributeError" if the attribute is already an
  707. * attribute of another element.
  708. * @see https://dom.spec.whatwg.org/#concept-element-attributes-set
  709. */
  710. setNamedItemNS(attr: Attr): Attr | null;
  711. [index: number]: Attr;
  712. [Symbol.iterator](): Iterator<Attr>;
  713. }
  714. /**
  715. * NodeList objects are collections of nodes, usually returned by properties such as
  716. * Node.childNodes and methods such as document.querySelectorAll().
  717. *
  718. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList)
  719. */
  720. class NodeList<T extends Node = Node> implements Iterable<T> {
  721. /**
  722. * Returns the number of nodes in the collection.
  723. *
  724. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/length)
  725. */
  726. readonly length: number;
  727. /**
  728. * Returns the node with index index from the collection. The nodes are sorted in tree order.
  729. *
  730. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/item)
  731. */
  732. item(index: number): T | null;
  733. /**
  734. * Returns a string representation of the NodeList.
  735. */
  736. toString(nodeFilter: (node: T) => T | undefined): string;
  737. /**
  738. * Filters the NodeList based on a predicate.
  739. *
  740. * @private
  741. */
  742. filter(predicate: (node: T) => boolean): T[];
  743. /**
  744. * Returns the first index at which a given node can be found in the NodeList, or -1 if it is
  745. * not present.
  746. *
  747. * @private
  748. */
  749. indexOf(node: T): number;
  750. /**
  751. * Index based access returns `undefined`, when accessing indexes >= `length`.
  752. * But it would break a lot of code (like `Array.from` usages),
  753. * if it would be typed as `T | undefined`.
  754. */
  755. [index: number]: T;
  756. [Symbol.iterator](): Iterator<T>;
  757. }
  758. /**
  759. * Represents a live collection of nodes that is automatically updated when its associated
  760. * document changes.
  761. */
  762. interface LiveNodeList<T extends Node = Node> extends NodeList<T> {}
  763. /**
  764. * Represents a live collection of nodes that is automatically updated when its associated
  765. * document changes.
  766. */
  767. var LiveNodeList: InstanceOf<LiveNodeList>;
  768. /**
  769. * Element is the most general base class from which all objects in a Document inherit. It only
  770. * has methods and properties common to all kinds of elements. More specific classes inherit from
  771. * Element.
  772. *
  773. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element)
  774. */
  775. interface Element extends Node {
  776. readonly nodeType: typeof Node.ELEMENT_NODE;
  777. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/attributes) */
  778. readonly attributes: NamedNodeMap;
  779. /**
  780. * Returns the HTML-uppercased qualified name.
  781. *
  782. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/tagName)
  783. */
  784. readonly tagName: string;
  785. /**
  786. * Returns element's first attribute whose qualified name is qualifiedName, and null if there
  787. * is no such attribute otherwise.
  788. *
  789. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttribute)
  790. */
  791. getAttribute(qualifiedName: string): string | null;
  792. /**
  793. * Returns element's attribute whose namespace is namespace and local name is localName, and
  794. * null if there is no such attribute otherwise.
  795. *
  796. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNS)
  797. */
  798. getAttributeNS(namespace: string | null, localName: string): string | null;
  799. /**
  800. * Returns the qualified names of all element's attributes. Can contain duplicates.
  801. *
  802. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNames)
  803. */
  804. getAttributeNames(): string[];
  805. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNode) */
  806. getAttributeNode(qualifiedName: string): Attr | null;
  807. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNodeNS) */
  808. getAttributeNodeNS(
  809. namespace: string | null,
  810. localName: string
  811. ): Attr | null;
  812. /**
  813. * Returns a LiveNodeList of all child elements which have **all** of the given class
  814. * name(s).
  815. *
  816. * Returns an empty list if `classNames` is an empty string or only contains HTML white space
  817. * characters.
  818. *
  819. * Warning: This returns a live LiveNodeList.
  820. * Changes in the DOM will reflect in the array as the changes occur.
  821. * If an element selected by this array no longer qualifies for the selector,
  822. * it will automatically be removed. Be aware of this for iteration purposes.
  823. *
  824. * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
  825. * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
  826. */
  827. getElementsByClassName(classNames: string): LiveNodeList<Element>;
  828. /**
  829. * Returns a LiveNodeList of elements with the given qualifiedName.
  830. * Searching for all descendants can be done by passing `*` as `qualifiedName`.
  831. *
  832. * All descendants of the specified element are searched, but not the element itself.
  833. * The returned list is live, which means it updates itself with the DOM tree automatically.
  834. * Therefore, there is no need to call `Element.getElementsByTagName()`
  835. * with the same element and arguments repeatedly if the DOM changes in between calls.
  836. *
  837. * When called on an HTML element in an HTML document,
  838. * `getElementsByTagName` lower-cases the argument before searching for it.
  839. * This is undesirable when trying to match camel-cased SVG elements (such as
  840. * `<linearGradient>`) in an HTML document.
  841. * Instead, use `Element.getElementsByTagNameNS()`,
  842. * which preserves the capitalization of the tag name.
  843. *
  844. * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
  845. * except that it only searches for elements that are descendants of the specified element.
  846. *
  847. * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
  848. * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
  849. */
  850. getElementsByTagName(qualifiedName: string): LiveNodeList<Element>;
  851. /**
  852. * Returns a `LiveNodeList` of elements with the given tag name belonging to the given
  853. * namespace. It is similar to `Document.getElementsByTagNameNS`, except that its search is
  854. * restricted to descendants of the specified element.
  855. *
  856. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS)
  857. * */
  858. getElementsByTagNameNS(
  859. namespaceURI: string | null,
  860. localName: string
  861. ): LiveNodeList<Element>;
  862. getQualifiedName(): string;
  863. /**
  864. * Returns true if element has an attribute whose qualified name is qualifiedName, and false
  865. * otherwise.
  866. *
  867. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttribute)
  868. */
  869. hasAttribute(qualifiedName: string): boolean;
  870. /**
  871. * Returns true if element has an attribute whose namespace is namespace and local name is
  872. * localName.
  873. *
  874. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributeNS)
  875. */
  876. hasAttributeNS(namespace: string | null, localName: string): boolean;
  877. /**
  878. * Returns true if element has attributes, and false otherwise.
  879. *
  880. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributes)
  881. */
  882. hasAttributes(): boolean;
  883. /**
  884. * Removes element's first attribute whose qualified name is qualifiedName.
  885. *
  886. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttribute)
  887. */
  888. removeAttribute(qualifiedName: string): void;
  889. /**
  890. * Removes element's attribute whose namespace is namespace and local name is localName.
  891. *
  892. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNS)
  893. */
  894. removeAttributeNS(namespace: string | null, localName: string): void;
  895. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNode) */
  896. removeAttributeNode(attr: Attr): Attr;
  897. /**
  898. * Sets the value of element's first attribute whose qualified name is qualifiedName to value.
  899. *
  900. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttribute)
  901. */
  902. setAttribute(qualifiedName: string, value: string): void;
  903. /**
  904. * Sets the value of element's attribute whose namespace is namespace and local name is
  905. * localName to value.
  906. *
  907. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNS)
  908. */
  909. setAttributeNS(
  910. namespace: string | null,
  911. qualifiedName: string,
  912. value: string
  913. ): void;
  914. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNode) */
  915. setAttributeNode(attr: Attr): Attr | null;
  916. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNodeNS) */
  917. setAttributeNodeNS(attr: Attr): Attr | null;
  918. }
  919. /**
  920. * Element is the most general base class from which all objects in a Document inherit. It only
  921. * has methods and properties common to all kinds of elements. More specific classes inherit from
  922. * Element.
  923. *
  924. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element)
  925. */
  926. var Element: InstanceOf<Element>;
  927. /**
  928. * The CharacterData abstract interface represents a Node object that contains characters. This
  929. * is an abstract interface, meaning there aren't any object of type CharacterData: it is
  930. * implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't
  931. * abstract.
  932. *
  933. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData)
  934. */
  935. interface CharacterData extends Node {
  936. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/data) */
  937. data: string;
  938. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/length) */
  939. readonly length: number;
  940. readonly ownerDocument: Document;
  941. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/appendData) */
  942. appendData(data: string): void;
  943. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/deleteData) */
  944. deleteData(offset: number, count: number): void;
  945. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/insertData) */
  946. insertData(offset: number, data: string): void;
  947. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceData) */
  948. replaceData(offset: number, count: number, data: string): void;
  949. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */
  950. substringData(offset: number, count: number): string;
  951. }
  952. /**
  953. * The CharacterData abstract interface represents a Node object that contains characters. This
  954. * is an abstract interface, meaning there aren't any object of type CharacterData: it is
  955. * implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't
  956. * abstract.
  957. *
  958. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData)
  959. */
  960. var CharacterData: InstanceOf<CharacterData>;
  961. /**
  962. * The textual content of Element or Attr. If an element has no markup within its content, it has
  963. * a single child implementing Text that contains the element's text. However, if the element
  964. * contains markup, it is parsed into information items and Text nodes that form its children.
  965. *
  966. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Text)
  967. */
  968. interface Text extends CharacterData {
  969. nodeName: '#text' | '#cdata-section';
  970. nodeType: typeof Node.TEXT_NODE | typeof Node.CDATA_SECTION_NODE;
  971. /**
  972. * Splits data at the given offset and returns the remainder as Text node.
  973. *
  974. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Text/splitText)
  975. */
  976. splitText(offset: number): Text;
  977. }
  978. /**
  979. * The textual content of Element or Attr. If an element has no markup within its content, it has
  980. * a single child implementing Text that contains the element's text. However, if the element
  981. * contains markup, it is parsed into information items and Text nodes that form its children.
  982. *
  983. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Text)
  984. */
  985. var Text: InstanceOf<Text>;
  986. /**
  987. * The Comment interface represents textual notations within markup; although it is generally not
  988. * visually shown, such comments are available to be read in the source view. Comments are
  989. * represented in HTML and XML as content between '<!--' and '-->'. In XML, like inside SVG or
  990. * MathML markup, the character sequence '--' cannot be used within a comment.
  991. *
  992. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Comment)
  993. */
  994. interface Comment extends CharacterData {
  995. nodeName: '#comment';
  996. nodeType: typeof Node.COMMENT_NODE;
  997. }
  998. /**
  999. * The Comment interface represents textual notations within markup; although it is generally not
  1000. * visually shown, such comments are available to be read in the source view. Comments are
  1001. * represented in HTML and XML as content between '<!--' and '-->'. In XML, like inside SVG or
  1002. * MathML markup, the character sequence '--' cannot be used within a comment.
  1003. *
  1004. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Comment)
  1005. */
  1006. var Comment: InstanceOf<Comment>;
  1007. /**
  1008. * A CDATA section that can be used within XML to include extended portions of unescaped text.
  1009. * The symbols < and & don’t need escaping as they normally do when inside a CDATA section.
  1010. *
  1011. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CDATASection)
  1012. */
  1013. interface CDATASection extends Text {
  1014. nodeName: '#cdata-section';
  1015. nodeType: typeof Node.CDATA_SECTION_NODE;
  1016. }
  1017. /**
  1018. * A CDATA section that can be used within XML to include extended portions of unescaped text.
  1019. * The symbols < and & don’t need escaping as they normally do when inside a CDATA section.
  1020. *
  1021. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CDATASection)
  1022. */
  1023. var CDATASection: InstanceOf<CDATASection>;
  1024. /**
  1025. * The DocumentFragment interface represents a minimal document object that has no parent.
  1026. * It is used as a lightweight version of Document that stores a segment of a document structure
  1027. * comprised of nodes just like a standard document.
  1028. * The key difference is due to the fact that the document fragment isn't part
  1029. * of the active document tree structure.
  1030. * Changes made to the fragment don't affect the document.
  1031. */
  1032. interface DocumentFragment extends Node {
  1033. readonly ownerDocument: Document;
  1034. getElementById(elementId: string): Element | null;
  1035. }
  1036. var DocumentFragment: InstanceOf<DocumentFragment>;
  1037. interface Entity extends Node {
  1038. nodeType: typeof Node.ENTITY_NODE;
  1039. }
  1040. var Entity: InstanceOf<Entity>;
  1041. interface EntityReference extends Node {
  1042. nodeType: typeof Node.ENTITY_REFERENCE_NODE;
  1043. }
  1044. var EntityReference: InstanceOf<EntityReference>;
  1045. interface Notation extends Node {
  1046. nodeType: typeof Node.NOTATION_NODE;
  1047. }
  1048. var Notation: InstanceOf<Notation>;
  1049. interface ProcessingInstruction extends CharacterData {
  1050. nodeType: typeof Node.PROCESSING_INSTRUCTION_NODE;
  1051. /**
  1052. * A string representing the textual data contained in this object.
  1053. * For `ProcessingInstruction`, that means everything that goes after the `target`, excluding
  1054. * `?>`.
  1055. *
  1056. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/data)
  1057. */
  1058. data: string;
  1059. /**
  1060. * A string containing the name of the application.
  1061. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ProcessingInstruction/target) */
  1062. readonly target: string;
  1063. }
  1064. var ProcessingInstruction: InstanceOf<ProcessingInstruction>;
  1065. interface Document extends Node {
  1066. /**
  1067. * The mime type of the document is determined at creation time and can not be modified.
  1068. *
  1069. * @see https://dom.spec.whatwg.org/#concept-document-content-type
  1070. * @see {@link DOMImplementation}
  1071. * @see {@link MIME_TYPE}
  1072. */
  1073. readonly contentType: MIME_TYPE;
  1074. /**
  1075. * @see https://dom.spec.whatwg.org/#concept-document-type
  1076. * @see {@link DOMImplementation}
  1077. */
  1078. readonly type: 'html' | 'xml';
  1079. /**
  1080. * The implementation that created this document.
  1081. *
  1082. * @readonly
  1083. */
  1084. readonly implementation: DOMImplementation;
  1085. readonly ownerDocument: Document;
  1086. readonly nodeName: '#document';
  1087. readonly nodeType: typeof Node.DOCUMENT_NODE;
  1088. readonly doctype: DocumentType | null;
  1089. /**
  1090. * Gets a reference to the root node of the document.
  1091. *
  1092. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/documentElement)
  1093. */
  1094. readonly documentElement: Element | null;
  1095. /**
  1096. * Creates an attribute object with a specified name.
  1097. *
  1098. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttribute)
  1099. */
  1100. createAttribute(localName: string): Attr;
  1101. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttributeNS) */
  1102. createAttributeNS(namespace: string | null, qualifiedName: string): Attr;
  1103. /**
  1104. * Returns a CDATASection node whose data is data.
  1105. *
  1106. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createCDATASection)
  1107. */
  1108. createCDATASection(data: string): CDATASection;
  1109. /**
  1110. * Creates a comment object with the specified data.
  1111. *
  1112. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createComment)
  1113. */
  1114. createComment(data: string): Comment;
  1115. /**
  1116. * Creates a new document.
  1117. *
  1118. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createDocumentFragment)
  1119. */
  1120. createDocumentFragment(): DocumentFragment;
  1121. createElement(tagName: string): Element;
  1122. /**
  1123. * Returns an element with namespace namespace. Its namespace prefix will be everything before
  1124. * ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E)
  1125. * in qualifiedName or qualifiedName.
  1126. *
  1127. * If localName does not match the Name production an "InvalidCharacterError" DOMException will
  1128. * be thrown.
  1129. *
  1130. * If one of the following conditions is true a "NamespaceError" DOMException will be thrown:
  1131. *
  1132. * localName does not match the QName production.
  1133. * Namespace prefix is not null and namespace is the empty string.
  1134. * Namespace prefix is "xml" and namespace is not the XML namespace.
  1135. * qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace.
  1136. * namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".
  1137. *
  1138. * When supplied, options's is can be used to create a customized built-in element.
  1139. *
  1140. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createElementNS)
  1141. */
  1142. createElementNS(namespace: string | null, qualifiedName: string): Element;
  1143. /**
  1144. * Creates an EntityReference object.
  1145. * The current implementation does not fill the `childNodes` with those of the corresponding
  1146. * `Entity`
  1147. *
  1148. * The name of the entity to reference. No namespace well-formedness checks are performed.
  1149. *
  1150. * @deprecated
  1151. * In DOM Level 4.
  1152. * @returns {EntityReference}
  1153. * @throws {DOMException}
  1154. * With code `INVALID_CHARACTER_ERR` when `name` is not valid.
  1155. * @throws {DOMException}
  1156. * with code `NOT_SUPPORTED_ERR` when the document is of type `html`
  1157. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
  1158. */
  1159. createEntityReference(name: string): EntityReference;
  1160. /**
  1161. * Returns a ProcessingInstruction node whose target is target and data is data. If target does
  1162. * not match the Name production an "InvalidCharacterError" DOMException will be thrown. If
  1163. * data contains "?>" an "InvalidCharacterError" DOMException will be thrown.
  1164. *
  1165. * [MDN
  1166. * Reference](https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction)
  1167. */
  1168. createProcessingInstruction(
  1169. target: string,
  1170. data: string
  1171. ): ProcessingInstruction;
  1172. /**
  1173. * Creates a text string from the specified value.
  1174. *
  1175. * @param data
  1176. * String that specifies the nodeValue property of the text node.
  1177. *
  1178. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createTextNode)
  1179. */
  1180. createTextNode(data: string): Text;
  1181. /**
  1182. * Returns a reference to the first object with the specified value of the ID attribute.
  1183. */
  1184. getElementById(elementId: string): Element | null;
  1185. /**
  1186. * Returns a LiveNodeList of all child elements which have **all** of the given class
  1187. * name(s).
  1188. *
  1189. * Returns an empty list if `classNames` is an empty string or only contains HTML white space
  1190. * characters.
  1191. *
  1192. * Warning: This returns a live LiveNodeList.
  1193. * Changes in the DOM will reflect in the array as the changes occur.
  1194. * If an element selected by this array no longer qualifies for the selector,
  1195. * it will automatically be removed. Be aware of this for iteration purposes.
  1196. *
  1197. * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
  1198. * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
  1199. */
  1200. getElementsByClassName(classNames: string): LiveNodeList<Element>;
  1201. /**
  1202. * Returns a LiveNodeList of elements with the given qualifiedName.
  1203. * Searching for all descendants can be done by passing `*` as `qualifiedName`.
  1204. *
  1205. * The complete document is searched, including the root node.
  1206. * The returned list is live, which means it updates itself with the DOM tree automatically.
  1207. * Therefore, there is no need to call `Element.getElementsByTagName()`
  1208. * with the same element and arguments repeatedly if the DOM changes in between calls.
  1209. *
  1210. * When called on an HTML element in an HTML document,
  1211. * `getElementsByTagName` lower-cases the argument before searching for it.
  1212. * This is undesirable when trying to match camel-cased SVG elements (such as
  1213. * `<linearGradient>`) in an HTML document.
  1214. * Instead, use `Element.getElementsByTagNameNS()`,
  1215. * which preserves the capitalization of the tag name.
  1216. *
  1217. * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
  1218. * except that it only searches for elements that are descendants of the specified element.
  1219. *
  1220. * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
  1221. * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
  1222. */
  1223. getElementsByTagName(qualifiedName: string): LiveNodeList<Element>;
  1224. /**
  1225. * Returns a `LiveNodeList` of elements with the given tag name belonging to the given
  1226. * namespace. The complete document is searched, including the root node.
  1227. *
  1228. * The returned list is live, which means it updates itself with the DOM tree automatically.
  1229. * Therefore, there is no need to call `Element.getElementsByTagName()`
  1230. * with the same element and arguments repeatedly if the DOM changes in between calls.
  1231. *
  1232. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS)
  1233. * */
  1234. getElementsByTagNameNS(
  1235. namespaceURI: string | null,
  1236. localName: string
  1237. ): LiveNodeList<Element>;
  1238. /**
  1239. * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
  1240. *
  1241. * If node is a document or a shadow root, throws a "NotSupportedError" DOMException.
  1242. *
  1243. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/importNode)
  1244. */
  1245. importNode<T extends Node>(node: T, deep?: boolean): T;
  1246. }
  1247. var Document: InstanceOf<Document>;
  1248. /**
  1249. * A Node containing a doctype.
  1250. *
  1251. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType)
  1252. */
  1253. interface DocumentType extends Node {
  1254. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/name) */
  1255. readonly name: string;
  1256. readonly internalSubset: string;
  1257. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/publicId) */
  1258. readonly publicId: string;
  1259. /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/systemId) */
  1260. readonly systemId: string;
  1261. }
  1262. var DocumentType: InstanceOf<DocumentFragment>;
  1263. class DOMImplementation {
  1264. /**
  1265. * The DOMImplementation interface represents an object providing methods which are not
  1266. * dependent on any particular document.
  1267. * Such an object is returned by the `Document.implementation` property.
  1268. *
  1269. * __The individual methods describe the differences compared to the specs.__.
  1270. *
  1271. * @class
  1272. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
  1273. * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1
  1274. * Core (Initial)
  1275. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
  1276. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
  1277. * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
  1278. */
  1279. constructor();
  1280. /**
  1281. * Creates an XML Document object of the specified type with its document element.
  1282. *
  1283. * __It behaves slightly different from the description in the living standard__:
  1284. * - There is no interface/class `XMLDocument`, it returns a `Document` instance (with it's
  1285. * `type` set to `'xml'`).
  1286. * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
  1287. *
  1288. * @returns {Document}
  1289. * The XML document.
  1290. * @see {@link DOMImplementation.createHTMLDocument}
  1291. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
  1292. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
  1293. * Level 2 Core (initial)
  1294. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
  1295. */
  1296. createDocument(
  1297. namespaceURI: NAMESPACE | string | null,
  1298. qualifiedName: string,
  1299. doctype?: DocumentType | null
  1300. ): Document;
  1301. /**
  1302. * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
  1303. *
  1304. * __This behavior is slightly different from the in the specs__:
  1305. * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
  1306. *
  1307. * @returns {DocumentType}
  1308. * which can either be used with `DOMImplementation.createDocument`
  1309. * upon document creation or can be put into the document via methods like
  1310. * `Node.insertBefore()` or `Node.replaceChild()`
  1311. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
  1312. * MDN
  1313. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
  1314. * Level 2 Core
  1315. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living
  1316. * Standard
  1317. */
  1318. createDocumentType(
  1319. qualifiedName: string,
  1320. publicId?: string,
  1321. systemId?: string
  1322. ): DocumentType;
  1323. /**
  1324. * Returns an HTML document, that might already have a basic DOM structure.
  1325. *
  1326. * __It behaves slightly different from the description in the living standard__:
  1327. * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are
  1328. * omitted)
  1329. * - several properties and methods are missing - Nothing related to events is implemented.
  1330. *
  1331. * @see {@link DOMImplementation.createDocument}
  1332. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
  1333. * @see https://dom.spec.whatwg.org/#html-document
  1334. */
  1335. createHTMLDocument(title?: string | false): Document;
  1336. /**
  1337. * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given
  1338. * feature is supported. The different implementations fairly diverged in what kind of
  1339. * features were reported. The latest version of the spec settled to force this method to
  1340. * always return true, where the functionality was accurate and in use.
  1341. *
  1342. * @deprecated
  1343. * It is deprecated and modern browsers return true in all cases.
  1344. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
  1345. * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1
  1346. * Core
  1347. * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
  1348. */
  1349. hasFeature(feature: string, version?: string): true;
  1350. }
  1351. class XMLSerializer {
  1352. serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
  1353. }
  1354. // END ./lib/dom.js
  1355. // START ./lib/dom-parser.js
  1356. /**
  1357. * The DOMParser interface provides the ability to parse XML or HTML source code from a string
  1358. * into a DOM `Document`.
  1359. *
  1360. * _xmldom is different from the spec in that it allows an `options` parameter,
  1361. * to control the behavior._.
  1362. *
  1363. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
  1364. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
  1365. */
  1366. class DOMParser {
  1367. /**
  1368. * The DOMParser interface provides the ability to parse XML or HTML source code from a
  1369. * string into a DOM `Document`.
  1370. *
  1371. * _xmldom is different from the spec in that it allows an `options` parameter,
  1372. * to control the behavior._.
  1373. *
  1374. * @class
  1375. * @param {DOMParserOptions} [options]
  1376. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
  1377. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
  1378. */
  1379. constructor(options?: DOMParserOptions);
  1380. /**
  1381. * Parses `source` using the options in the way configured by the `DOMParserOptions` of
  1382. * `this`
  1383. * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created, otherwise an XML
  1384. * `Document` is created.
  1385. *
  1386. * __It behaves different from the description in the living standard__:
  1387. * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
  1388. * - Any unexpected input is reported to `onError` with either a `warning`, `error` or
  1389. * `fatalError` level.
  1390. * - Any `fatalError` throws a `ParseError` which prevents further processing.
  1391. * - Any error thrown by `onError` is converted to a `ParseError` which prevents further
  1392. * processing - If no `Document` was created during parsing it is reported as a `fatalError`.
  1393. *
  1394. * @returns
  1395. * The `Document` node.
  1396. * @throws {ParseError}
  1397. * for any `fatalError` or anything that is thrown by `onError`
  1398. * @throws {TypeError}
  1399. * for any invalid `mimeType`
  1400. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
  1401. * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
  1402. */
  1403. parseFromString(source: string, mimeType: MIME_TYPE | string): Document;
  1404. }
  1405. interface DOMParserOptions {
  1406. /**
  1407. * The method to use instead of `Object.assign` (defaults to `conventions.assign`),
  1408. * which is used to copy values from the options before they are used for parsing.
  1409. *
  1410. * @private
  1411. * @see {@link assign}
  1412. */
  1413. readonly assign?: typeof Object.assign;
  1414. /**
  1415. * For internal testing: The class for creating an instance for handling events from the SAX
  1416. * parser.
  1417. * *****Warning: By configuring a faulty implementation,
  1418. * the specified behavior can completely be broken*****.
  1419. *
  1420. * @private
  1421. */
  1422. readonly domHandler?: unknown;
  1423. /**
  1424. * DEPRECATED: Use `onError` instead!
  1425. *
  1426. * For backwards compatibility:
  1427. * If it is a function, it will be used as a value for `onError`,
  1428. * but it receives different argument types than before 0.9.0.
  1429. *
  1430. * @deprecated
  1431. * @throws {TypeError}
  1432. * If it is an object.
  1433. */
  1434. readonly errorHandler?: ErrorHandlerFunction;
  1435. /**
  1436. * Configures if the nodes created during parsing
  1437. * will have a `lineNumber` and a `columnNumber` attribute
  1438. * describing their location in the XML string.
  1439. * Default is true.
  1440. */
  1441. readonly locator?: boolean;
  1442. /**
  1443. * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
  1444. * which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
  1445. * including some Unicode "newline" characters.
  1446. *
  1447. * @see {@link normalizeLineEndings}
  1448. */
  1449. readonly normalizeLineEndings?: (source: string) => string;
  1450. /**
  1451. * A function invoked for every error that occurs during parsing.
  1452. *
  1453. * If it is not provided, all errors are reported to `console.error`
  1454. * and only `fatalError`s are thrown as a `ParseError`,
  1455. * which prevents any further processing.
  1456. * If the provided method throws, a `ParserError` is thrown,
  1457. * which prevents any further processing.
  1458. *
  1459. * Be aware that many `warning`s are considered an error that prevents further processing in
  1460. * most implementations.
  1461. *
  1462. * @param level
  1463. * The error level as reported by the SAXParser.
  1464. * @param message
  1465. * The error message.
  1466. * @param context
  1467. * The DOMHandler instance used for parsing.
  1468. * @see {@link onErrorStopParsing}
  1469. * @see {@link onWarningStopParsing}
  1470. */
  1471. readonly onError?: ErrorHandlerFunction;
  1472. /**
  1473. * The XML namespaces that should be assumed when parsing.
  1474. * The default namespace can be provided by the key that is the empty string.
  1475. * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
  1476. * the default namespace that will be used,
  1477. * will be overridden according to the specification.
  1478. */
  1479. readonly xmlns?: Readonly<Record<string, string | null | undefined>>;
  1480. }
  1481. interface ErrorHandlerFunction {
  1482. (
  1483. level: 'warning' | 'error' | 'fatalError',
  1484. msg: string,
  1485. context: any
  1486. ): void;
  1487. }
  1488. /**
  1489. * Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
  1490. * including some Unicode "newline" characters:
  1491. *
  1492. * > XML parsed entities are often stored in computer files which,
  1493. * > for editing convenience, are organized into lines.
  1494. * > These lines are typically separated by some combination
  1495. * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
  1496. * >
  1497. * > To simplify the tasks of applications, the XML processor must behave
  1498. * > as if it normalized all line breaks in external parsed entities (including the document entity)
  1499. * > on input, before parsing, by translating the following to a single #xA character:
  1500. * >
  1501. * > 1. the two-character sequence #xD #xA,
  1502. * > 2. the two-character sequence #xD #x85,
  1503. * > 3. the single character #x85,
  1504. * > 4. the single character #x2028,
  1505. * > 5. the single character #x2029,
  1506. * > 6. any #xD character that is not immediately followed by #xA or #x85.
  1507. *
  1508. * @prettierignore
  1509. */
  1510. function normalizeLineEndings(input: string): string;
  1511. /**
  1512. * A method that prevents any further parsing when an `error`
  1513. * with level `error` is reported during parsing.
  1514. *
  1515. * @see {@link DOMParserOptions.onError}
  1516. * @see {@link onWarningStopParsing}
  1517. */
  1518. function onErrorStopParsing(): void | never;
  1519. /**
  1520. * A method that prevents any further parsing when an `error`
  1521. * with any level is reported during parsing.
  1522. *
  1523. * @see {@link DOMParserOptions.onError}
  1524. * @see {@link onErrorStopParsing}
  1525. */
  1526. function onWarningStopParsing(): never;
  1527. // END ./lib/dom-parser.js
  1528. }