@@ -11,21 +11,21 @@ const HEAD_TAG_REGEX = /<head[^]*>/i;
1111const BODY_TAG_REGEX = / < b o d y [ ^ ] * > / i;
1212
1313// falls back to `parseFromString` if `createHTMLDocument` cannot be used
14- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14+ /* eslint-disable @typescript-eslint/no-unused-vars */
15+ /* istanbul ignore start */
1516let parseFromDocument = ( html : string , tagName ?: string ) : Document => {
16- /* istanbul ignore next */
1717 throw new Error (
1818 'This browser does not support `document.implementation.createHTMLDocument`' ,
1919 ) ;
2020} ;
2121
22- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2322let parseFromString = ( html : string , tagName ?: string ) : Document => {
24- /* istanbul ignore next */
2523 throw new Error (
2624 'This browser does not support `DOMParser.prototype.parseFromString`' ,
2725 ) ;
2826} ;
27+ /* istanbul ignore stop */
28+ /* eslint-enable @typescript-eslint/no-unused-vars */
2929
3030const DOMParser = typeof window === 'object' && window . DOMParser ;
3131
@@ -46,10 +46,11 @@ if (typeof DOMParser === 'function') {
4646 * @returns - Document.
4747 */
4848 parseFromString = ( html : string , tagName ?: string ) : Document => {
49- /* istanbul ignore if */
49+ /* istanbul ignore start */
5050 if ( tagName ) {
5151 html = `<${ tagName } >${ html } </${ tagName } >` ;
5252 }
53+ /* istanbul ignore stop */
5354
5455 return domParser . parseFromString ( html , mimeType ) ;
5556 } ;
@@ -74,7 +75,7 @@ if (typeof document === 'object' && document.implementation) {
7475 * @returns - Document
7576 */
7677 parseFromDocument = function ( html : string , tagName ?: string ) : Document {
77- /* istanbul ignore if */
78+ /* istanbul ignore start */
7879 if ( tagName ) {
7980 const element = htmlDocument . documentElement . querySelector ( tagName ) ;
8081
@@ -84,6 +85,7 @@ if (typeof document === 'object' && document.implementation) {
8485
8586 return htmlDocument ;
8687 }
88+ /* istanbul ignore stop */
8789
8890 htmlDocument . documentElement . innerHTML = html ;
8991 return htmlDocument ;
@@ -114,8 +116,8 @@ if (template && template.content) {
114116 } ;
115117}
116118
117- /* istanbul ignore next */
118- const createNodeList = ( ) => document . createDocumentFragment ( ) . childNodes ;
119+ const createNodeList = /* istanbul ignore next */ ( ) =>
120+ document . createDocumentFragment ( ) . childNodes ;
119121
120122/**
121123 * Parses HTML string to DOM nodes.
@@ -171,11 +173,11 @@ export default function domparser(html: string): NodeList {
171173 return parseFromTemplate ( html ) ;
172174 }
173175
174- /* istanbul ignore next */
176+ /* istanbul ignore start */
175177 const element = parseFromDocument ( html , BODY ) . querySelector ( BODY ) ;
176178
177- /* istanbul ignore next */
178179 return element ?. childNodes ?? createNodeList ( ) ;
180+ /* istanbul ignore stop */
179181 }
180182 }
181183}
0 commit comments