nomagick commited on
Commit
be993c2
·
unverified ·
1 Parent(s): 68c4df2

fix: there may be invalid root doc

Browse files
backend/functions/src/services/jsdom.ts CHANGED
@@ -111,9 +111,9 @@ export class JSDomControl extends AsyncService {
111
  }
112
  const textNodes: HTMLElement[] = [];
113
  let rootDoc: Document;
114
- if (allNodes.length === 1 && allNodes[0].nodeName === '#document') {
115
  rootDoc = allNodes[0] as any;
116
- if (rootDoc.documentElement && rootDoc.body?.innerText) {
117
  textNodes.push(rootDoc.body);
118
  }
119
  } else {
 
111
  }
112
  const textNodes: HTMLElement[] = [];
113
  let rootDoc: Document;
114
+ if (allNodes.length === 1 && allNodes[0].nodeName === '#document' && (allNodes[0] as any).documentElement) {
115
  rootDoc = allNodes[0] as any;
116
+ if (rootDoc.body?.innerText) {
117
  textNodes.push(rootDoc.body);
118
  }
119
  } else {