@xmldom/xmldom 0.9.0-beta.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,84 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.9.0](https://github.com/xmldom/xmldom/compare/0.9.0-beta.11...0.9.0)
8
+
9
+ - [Discussion](https://github.com/xmldom/xmldom/discussions/435)
10
+ - [Summary on dev.to](https://dev.to/karfau/release-090-of-xmldomxmldom-4106)
11
+
12
+ ### Features
13
+
14
+ - feat: expose all DOM level 2 element prototypes [`#637`](https://github.com/xmldom/xmldom/pull/637) / [`#40`](https://github.com/xmldom/xmldom/issues/40)
15
+ - feat: add iterator function to NodeList and NamedNodeMap [`#634`](https://github.com/xmldom/xmldom/pull/634) / [`#633`](https://github.com/xmldom/xmldom/issues/633)
16
+
17
+ ### Fixed
18
+
19
+ - parse empty/whitspace only doctype internal subset [`#692`](https://github.com/xmldom/xmldom/pull/692)
20
+ - avoid prototype clash in namespace prefix [`#554`](https://github.com/xmldom/xmldom/pull/554)
21
+ - report fatalError when doctype is inside elements [`#550`](https://github.com/xmldom/xmldom/pull/550)
22
+
23
+ ### Other
24
+
25
+ - test: add fuzz target and regression tests [`#556`](https://github.com/xmldom/xmldom/pull/556)
26
+ - chore: improve .gitignore and provide .envrc.template [`#697`](https://github.com/xmldom/xmldom/pull/697)
27
+ - chore: Apply security best practices [`#546`](https://github.com/xmldom/xmldom/pull/546)
28
+ - ci: check test coverage in PRs [`#524`](https://github.com/xmldom/xmldom/pull/524)
29
+ - docs: add missing commas to readme [`#566`](https://github.com/xmldom/xmldom/pull/566)
30
+ - docs: click to copy install command in readme [`#644`](https://github.com/xmldom/xmldom/pull/644)
31
+ - docs: enhance jsdoc comments [`#511`](https://github.com/xmldom/xmldom/pull/511)
32
+
33
+ Thank you, [@kboshold](https://github.com/kboshold), [@edi9999](https://github.com/edi9999), [@apupier](https://github.com/apupier),
34
+ [@shunkica](https://github.com/shunkica), [@homer0](https://github.com/homer0), [@jhauga](https://github.com/jhauga),
35
+ [@UdayKharatmol](https://github.com/UdayKharatmol), for your contributions
36
+
37
+
38
+ ## [0.9.0-beta.11](https://github.com/xmldom/xmldom/compare/0.9.0-beta.10...0.9.0-beta.11)
39
+
40
+ ### Fixed
41
+
42
+ - report more non well-formed cases [`#519`](https://github.com/xmldom/xmldom/pull/519) / [`#45`](https://github.com/xmldom/xmldom/issues/45) / [`#125`](https://github.com/xmldom/xmldom/issues/125) / [`#467`](https://github.com/xmldom/xmldom/issues/467)
43
+ BREAKING-CHANGE: Reports more not well-formed documents as fatalError
44
+ and drop broken support for optional and unclosed tags in HTML.
45
+
46
+ ### Other
47
+
48
+ - Translate/drop non English comments [`#518`](https://github.com/xmldom/xmldom/pull/518)
49
+ - use node v16 for development [`#517`](https://github.com/xmldom/xmldom/pull/517)
50
+
51
+ Thank you, [@brodybits](https://github.com/brodybits), [@cbettinger](https://github.com/cbettinger), [@josecarlosrx](https://github.com/josecarlosrx), for your contributions
52
+
53
+
54
+ ## [0.9.0-beta.10](https://github.com/xmldom/xmldom/compare/0.9.0-beta.9...0.9.0-beta.10)
55
+
56
+ ### Fixed
57
+
58
+ - dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
59
+
60
+ ### Chore
61
+
62
+ - use prettier plugin for jsdoc [`#513`](https://github.com/xmldom/xmldom/pull/513)
63
+
64
+ Thank you, [@qtow](https://github.com/qtow), [@shunkica](https://github.com/shunkica), [@homer0](https://github.com/homer0), for your contributions
65
+
66
+
67
+ ## [0.8.10](https://github.com/xmldom/xmldom/compare/0.8.9...0.8.10)
68
+
69
+ ### Fixed
70
+
71
+ - dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
72
+
73
+ Thank you, [@qtow](https://github.com/qtow), for your contributions
74
+
75
+
76
+ ## [0.7.13](https://github.com/xmldom/xmldom/compare/0.7.12...0.7.13)
77
+
78
+ ### Fixed
79
+
80
+ - dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
81
+
82
+ Thank you, [@qtow](https://github.com/qtow), for your contributions
83
+
84
+
7
85
  ## [0.9.0-beta.9](https://github.com/xmldom/xmldom/compare/0.9.0-beta.8...0.9.0-beta.9)
8
86
 
9
87
  ### Fixed
package/index.d.ts CHANGED
@@ -6,12 +6,12 @@ declare module '@xmldom/xmldom' {
6
6
  * Since xmldom can not rely on `Object.assign`,
7
7
  * it uses/provides a simplified version that is sufficient for its needs.
8
8
  *
9
- * @throws TypeError if target is not an object
10
- *
9
+ * @throws {TypeError}
10
+ * If target is not an object.
11
11
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
12
12
  * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
13
13
  */
14
- function assign<T, S>(target:T, source:S): T & S;
14
+ function assign<T, S>(target: T, source: S): T & S;
15
15
  /**
16
16
  * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.
17
17
  *
@@ -29,9 +29,11 @@ declare module '@xmldom/xmldom' {
29
29
  /**
30
30
  * All mime types that are allowed as input to `DOMParser.parseFromString`
31
31
  *
32
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
33
- * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
34
- * @see DOMParser.prototype.parseFromString
32
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
33
+ * MDN
34
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
35
+ * WHATWG HTML Spec
36
+ * @see {@link DOMParser.prototype.parseFromString}
35
37
  */
36
38
  enum MIME_TYPE {
37
39
  /**
@@ -40,13 +42,15 @@ declare module '@xmldom/xmldom' {
40
42
  * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
41
43
  * @see https://en.wikipedia.org/wiki/HTML Wikipedia
42
44
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
43
- * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
45
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
46
+ * WHATWG HTML Spec
44
47
  */
45
48
  HTML = 'text/html',
46
49
  /**
47
50
  * `application/xml`, the standard mime type for XML documents.
48
51
  *
49
- * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
52
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
53
+ * registration
50
54
  * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
51
55
  * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
52
56
  */
@@ -63,7 +67,8 @@ declare module '@xmldom/xmldom' {
63
67
  * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
64
68
  * but is parsed as an XML document.
65
69
  *
66
- * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
70
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
71
+ * registration
67
72
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
68
73
  * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
69
74
  */
@@ -103,7 +108,7 @@ declare module '@xmldom/xmldom' {
103
108
  XML = 'http://www.w3.org/XML/1998/namespace',
104
109
 
105
110
  /**
106
- * The `xmlns:` namespace
111
+ * The `xmlns:` namespace.
107
112
  *
108
113
  * @see https://www.w3.org/2000/xmlns/
109
114
  */
@@ -114,13 +119,14 @@ declare module '@xmldom/xmldom' {
114
119
  * A custom error that will not be caught by XMLReader aka the SAX parser.
115
120
  */
116
121
  class ParseError extends Error {
117
- constructor(message:string, locator?:any);
122
+ constructor(message: string, locator?: any);
118
123
  }
119
124
  // END ./lib/conventions.js
120
125
 
121
126
  // START ./lib/dom.js
122
127
  /**
123
128
  * The error class for errors reported by the DOM API.
129
+ *
124
130
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException
125
131
  * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
126
132
  * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
@@ -131,17 +137,16 @@ declare module '@xmldom/xmldom' {
131
137
 
132
138
  interface DOMImplementation {
133
139
  /**
134
- * The DOMImplementation interface represents an object providing methods
135
- * which are not dependent on any particular document.
140
+ * The DOMImplementation interface represents an object providing methods which are not
141
+ * dependent on any particular document.
136
142
  * Such an object is returned by the `Document.implementation` property.
137
143
  *
138
- * __The individual methods describe the differences compared to the specs.__
139
- *
140
- * @constructor
144
+ * __The individual methods describe the differences compared to the specs.__.
141
145
  *
146
+ * @class
142
147
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
143
- * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core
144
- * (Initial)
148
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1
149
+ * Core (Initial)
145
150
  * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
146
151
  * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
147
152
  * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
@@ -156,14 +161,12 @@ declare module '@xmldom/xmldom' {
156
161
  * `type` set to `'xml'`).
157
162
  * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
158
163
  *
159
- * @returns {Document} the XML document
160
- *
161
- * @see DOMImplementation.createHTMLDocument
162
- *
164
+ * @returns {Document} The XML document.
165
+ * @see {@link DOMImplementation.createHTMLDocument}
163
166
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
164
167
  * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
165
- * Level 2 Core (initial)
166
- * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
168
+ * Level 2 Core (initial)
169
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
167
170
  */
168
171
  createDocument(
169
172
  namespaceURI: string | null,
@@ -178,15 +181,14 @@ declare module '@xmldom/xmldom' {
178
181
  * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
179
182
  *
180
183
  * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument`
181
- * upon document creation or can be put into the document via methods like
182
- * `Node.insertBefore()` or `Node.replaceChild()`
183
- *
184
+ * upon document creation or can be put into the document via methods
185
+ * like `Node.insertBefore()` or `Node.replaceChild()`
184
186
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
185
- * MDN
187
+ * MDN
186
188
  * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
187
- * Level 2 Core
189
+ * Level 2 Core
188
190
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living
189
- * Standard
191
+ * Standard
190
192
  */
191
193
  createDocumentType(
192
194
  qualifiedName: string,
@@ -202,8 +204,7 @@ declare module '@xmldom/xmldom' {
202
204
  * omitted)
203
205
  * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
204
206
  *
205
- * @see DOMImplementation.createDocument
206
- *
207
+ * @see {@link DOMImplementation.createDocument}
207
208
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
208
209
  * @see https://dom.spec.whatwg.org/#html-document
209
210
  */
@@ -211,14 +212,15 @@ declare module '@xmldom/xmldom' {
211
212
 
212
213
  /**
213
214
  * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given
214
- * feature is supported. The different implementations fairly diverged in what kind of features
215
- * were reported. The latest version of the spec settled to force this method to always return
216
- * true, where the functionality was accurate and in use.
217
- *
218
- * @deprecated It is deprecated and modern browsers return true in all cases.
215
+ * feature is supported. The different implementations fairly diverged in what kind of
216
+ * features were reported. The latest version of the spec settled to force this method to
217
+ * always return true, where the functionality was accurate and in use.
219
218
  *
219
+ * @deprecated
220
+ * It is deprecated and modern browsers return true in all cases.
220
221
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
221
- * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
222
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1
223
+ * Core
222
224
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
223
225
  */
224
226
  hasFeature(feature: string, version?: string): true;
@@ -234,15 +236,14 @@ declare module '@xmldom/xmldom' {
234
236
  var DOMParser: DOMParserStatic;
235
237
  interface DOMParserStatic {
236
238
  /**
237
- * The DOMParser interface provides the ability to parse XML or HTML source code
238
- * from a string into a DOM `Document`.
239
+ * The DOMParser interface provides the ability to parse XML or HTML source code from a
240
+ * string into a DOM `Document`.
239
241
  *
240
242
  * _xmldom is different from the spec in that it allows an `options` parameter,
241
- * to control the behavior._
243
+ * to control the behavior._.
242
244
  *
245
+ * @class
243
246
  * @param {DOMParserOptions} [options]
244
- * @constructor
245
- *
246
247
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
247
248
  * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
248
249
  */
@@ -250,37 +251,41 @@ declare module '@xmldom/xmldom' {
250
251
  }
251
252
 
252
253
  /**
253
- * The DOMParser interface provides the ability to parse XML or HTML source code
254
- * from a string into a DOM `Document`.
254
+ * The DOMParser interface provides the ability to parse XML or HTML source code from a string
255
+ * into a DOM `Document`.
255
256
  *
256
257
  * _xmldom is different from the spec in that it allows an `options` parameter,
257
- * to control the behavior._
258
+ * to control the behavior._.
258
259
  *
259
260
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
260
261
  * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
261
262
  */
262
263
  interface DOMParser {
263
264
  /**
264
- * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
265
+ * Parses `source` using the options in the way configured by the `DOMParserOptions` of
266
+ * `this`
265
267
  * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created, otherwise an XML
266
268
  * `Document` is created.
267
269
  *
268
270
  * __It behaves different from the description in the living standard__:
269
- * - Uses the `options` passed to the `DOMParser` constructor to modify the
270
- * behavior.
271
- * - Any unexpected input is reported to `onError` with either a `warning`, `error` or `fatalError` level.
272
- * - Any `fatalError` throws a `ParseError` which prevents further processing.
273
- * - Any error thrown by `onError` is converted to a `ParseError` which prevents further processing
274
- * - If no `Document` was created during parsing it is reported as a `fatalError`.
275
- *
276
- * @throws ParseError for any `fatalError` or anything that is thrown by `onError`
277
- * @throws TypeError for any invalid `mimeType`
278
- * @returns the `Document` node
279
- *
271
+ * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
272
+ * - Any unexpected input is reported to `onError` with either a `warning`, `error` or
273
+ * `fatalError` level.
274
+ * - Any `fatalError` throws a `ParseError` which prevents further processing.
275
+ * - Any error thrown by `onError` is converted to a `ParseError` which prevents further
276
+ * processing - If no `Document` was created during parsing it is reported as a `fatalError`.
277
+ *
278
+ * @returns The `Document` node.
279
+ * @throws {ParseError}
280
+ * for any `fatalError` or anything that is thrown by `onError`
281
+ * @throws {TypeError} for any invalid `mimeType`
280
282
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
281
283
  * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
282
284
  */
283
- parseFromString(source: string, mimeType: MIME_TYPE = MIME_TYPE.XML_TEXT): Document;
285
+ parseFromString(
286
+ source: string,
287
+ mimeType: MIME_TYPE = MIME_TYPE.XML_TEXT
288
+ ): Document;
284
289
  }
285
290
 
286
291
  interface XMLSerializer {
@@ -293,14 +298,14 @@ declare module '@xmldom/xmldom' {
293
298
  * which is used to copy values from the options before they are used for parsing.
294
299
  *
295
300
  * @private
296
- * @see conventions.assign
301
+ * @see {@link conventions.assign}
297
302
  */
298
303
  readonly assign?: typeof Object.assign;
299
304
  /**
300
305
  * For internal testing: The class for creating an instance for handling events from the SAX
301
306
  * parser.
302
- * __**Warning: By configuring a faulty implementation,
303
- * the specified behavior can completely be broken.**__
307
+ * *****Warning: By configuring a faulty implementation,
308
+ * the specified behavior can completely be broken*****.
304
309
  *
305
310
  * @private
306
311
  */
@@ -312,8 +317,9 @@ declare module '@xmldom/xmldom' {
312
317
  * For backwards compatibility:
313
318
  * If it is a function, it will be used as a value for `onError`,
314
319
  * but it receives different argument types than before 0.9.0.
315
- * @throws If it is an object.
320
+ *
316
321
  * @deprecated
322
+ * @throws {TypeError} If it is an object.
317
323
  */
318
324
  readonly errorHandler?: ErrorHandlerFunction;
319
325
 
@@ -339,15 +345,17 @@ declare module '@xmldom/xmldom' {
339
345
  * If the provided method throws, a `ParserError` is thrown,
340
346
  * which prevents any further processing.
341
347
  *
342
- * Be aware that many `warning`s are considered an error
343
- * that prevents further processing in most implementations.
344
- *
345
- * @param level the error level as reported by the SAXParser
346
- * @param message the error message
347
- * @param context the DOMHandler instance used for parsing
348
- *
349
- * @see onErrorStopParsing
350
- * @see onWarningStopParsing
348
+ * Be aware that many `warning`s are considered an error that prevents further processing in
349
+ * most implementations.
350
+ *
351
+ * @param level
352
+ * The error level as reported by the SAXParser.
353
+ * @param message
354
+ * The error message.
355
+ * @param context
356
+ * The DOMHandler instance used for parsing.
357
+ * @see {@link onErrorStopParsing}
358
+ * @see {@link onWarningStopParsing}
351
359
  */
352
360
  readonly onError?: ErrorHandlerFunction;
353
361
 
@@ -369,16 +377,16 @@ declare module '@xmldom/xmldom' {
369
377
  * A method that prevents any further parsing when an `error`
370
378
  * with level `error` is reported during parsing.
371
379
  *
372
- * @see DOMParserOptions.onError
373
- * @see onWarningStopParsing
380
+ * @see {@link DOMParserOptions.onError}
381
+ * @see {@link onWarningStopParsing}
374
382
  */
375
383
  function onErrorStopParsing(): void | never;
376
384
  /**
377
385
  * A method that prevents any further parsing when an `error`
378
386
  * with any level is reported during parsing.
379
387
  *
380
- * @see DOMParserOptions.onError
381
- * @see onErrorStopParsing
388
+ * @see {@link DOMParserOptions.onError}
389
+ * @see {@link onErrorStopParsing}
382
390
  */
383
391
  function onWarningStopParsing(): never;
384
392
  // END ./lib/dom-parser.js
package/lib/.eslintrc.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  extends:
2
2
  - 'plugin:es5/no-es2015'
3
- - 'plugin:node/recommended'
3
+ - 'plugin:n/recommended'