File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -2087,7 +2087,6 @@ function xmlPrune(
2087
2087
const out = [ ] ;
2088
2088
for ( let i = 0 ; i < xpr . snapshotLength ; i ++ ) {
2089
2089
const node = xpr . snapshotItem ( i ) ;
2090
- if ( node . nodeType !== 1 ) { continue ; }
2091
2090
out . push ( node ) ;
2092
2091
}
2093
2092
return out ;
@@ -2097,12 +2096,18 @@ function xmlPrune(
2097
2096
if ( selectorCheck !== '' && xmlDoc . querySelector ( selectorCheck ) === null ) {
2098
2097
return xmlDoc ;
2099
2098
}
2100
- const elems = queryAll ( xmlDoc , selector ) ;
2101
- if ( elems . length !== 0 ) {
2102
- if ( log ) { safeSelf ( ) . uboLog ( `xmlPrune: removing ${ elems . length } nodes` ) ; }
2103
- for ( const elem of elems ) {
2104
- elem . remove ( ) ;
2105
- if ( log ) { safeSelf ( ) . uboLog ( `xmlPrune: ${ elem . nodeName } removed` ) ; }
2099
+ const items = queryAll ( xmlDoc , selector ) ;
2100
+ if ( items . length !== 0 ) {
2101
+ if ( log ) { safeSelf ( ) . uboLog ( `xmlPrune: removing ${ items . length } items` ) ; }
2102
+ for ( const item of items ) {
2103
+ if ( item . nodeType === 1 ) {
2104
+ item . remove ( ) ;
2105
+ } else if ( item . nodeType === 2 ) {
2106
+ item . ownerElement . removeAttribute ( item . nodeName ) ;
2107
+ }
2108
+ if ( log ) {
2109
+ safeSelf ( ) . uboLog ( `xmlPrune: ${ item . constructor . name } .${ item . nodeName } removed` ) ;
2110
+ }
2106
2111
}
2107
2112
}
2108
2113
} catch ( ex ) {
You can’t perform that action at this time.
0 commit comments