@@ -46,8 +46,8 @@ if (typeof DOMParser === 'function') {
4646 * @returns - Document.
4747 */
4848 parseFromString = ( html : string , tagName ?: string ) : Document => {
49+ /* istanbul ignore if */
4950 if ( tagName ) {
50- /* istanbul ignore next */
5151 html = `<${ tagName } >${ html } </${ tagName } >` ;
5252 }
5353
@@ -74,6 +74,7 @@ if (typeof document === 'object' && document.implementation) {
7474 * @returns - Document
7575 */
7676 parseFromDocument = function ( html : string , tagName ?: string ) : Document {
77+ /* istanbul ignore if */
7778 if ( tagName ) {
7879 const element = htmlDocument . documentElement . querySelector ( tagName ) ;
7980
@@ -113,6 +114,7 @@ if (template && template.content) {
113114 } ;
114115}
115116
117+ /* istanbul ignore next */
116118const createNodeList = ( ) => document . createDocumentFragment ( ) . childNodes ;
117119
118120/**
@@ -136,11 +138,13 @@ export default function domparser(html: string): NodeList {
136138 // so make sure to remove them if they don't actually exist
137139 if ( ! HEAD_TAG_REGEX . test ( html ) ) {
138140 const element = doc . querySelector ( HEAD ) ;
141+ /* istanbul ignore next */
139142 element ?. parentNode ?. removeChild ( element ) ;
140143 }
141144
142145 if ( ! BODY_TAG_REGEX . test ( html ) ) {
143146 const element = doc . querySelector ( BODY ) ;
147+ /* istanbul ignore next */
144148 element ?. parentNode ?. removeChild ( element ) ;
145149 }
146150
@@ -153,6 +157,7 @@ export default function domparser(html: string): NodeList {
153157
154158 // if there's a sibling element, then return both elements
155159 if ( BODY_TAG_REGEX . test ( html ) && HEAD_TAG_REGEX . test ( html ) ) {
160+ /* istanbul ignore next */
156161 return elements [ 0 ] . parentNode ?. childNodes ?? createNodeList ( ) ;
157162 }
158163
@@ -166,7 +171,10 @@ export default function domparser(html: string): NodeList {
166171 return parseFromTemplate ( html ) ;
167172 }
168173
174+ /* istanbul ignore next */
169175 const element = parseFromDocument ( html , BODY ) . querySelector ( BODY ) ;
176+
177+ /* istanbul ignore next */
170178 return element ?. childNodes ?? createNodeList ( ) ;
171179 }
172180 }
0 commit comments