File tree Expand file tree Collapse file tree 6 files changed +7
-5
lines changed Expand file tree Collapse file tree 6 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ export interface ExtractedRect {
129
129
zoom : number ;
130
130
}
131
131
132
- function getRect ( el : HTMLElement | Node , baseZoom = 1 ) : ExtractedRect {
132
+ export function getRect ( el : HTMLElement | Node , baseZoom = 1 ) : ExtractedRect {
133
133
let originalRect : DOMRect ;
134
134
let newZoom = 1 ;
135
135
if ( ! ( el instanceof HTMLElement ) ) {
@@ -229,8 +229,8 @@ export function visibleRect(
229
229
}
230
230
231
231
// check if the element is covered by another element
232
- // zoom can cause the element to be covered by another element
233
- if ( baseZoom ! == 1 && isElementCovered ( el , rect ) ) {
232
+ // if the element is zoomed, the coverage check should be done with the original zoom
233
+ if ( baseZoom = == 1 && isElementCovered ( el , rect ) ) {
234
234
return false ;
235
235
}
236
236
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
getDocument ,
17
17
getNodeAttributes ,
18
18
getPseudoElementContent ,
19
+ getRect ,
19
20
logger ,
20
21
midsceneGenerateHash ,
21
22
setDataForNode ,
@@ -252,9 +253,10 @@ export function extractTextWithPosition(
252
253
return elementInfo ;
253
254
}
254
255
256
+ const rect = getRect ( node , baseZoom ) ;
255
257
for ( let i = 0 ; i < node . childNodes . length ; i ++ ) {
256
258
logger ( 'will dfs' , node . childNodes [ i ] ) ;
257
- dfs ( node . childNodes [ i ] , `${ nodePath } -${ i } ` , elementInfo ? .zoom ) ;
259
+ dfs ( node . childNodes [ i ] , `${ nodePath } -${ i } ` , rect . zoom ) ;
258
260
}
259
261
260
262
if ( ! elementInfo ) {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export async function launchPage(
10
10
} ,
11
11
) {
12
12
const browser = await puppeteer . launch ( {
13
- headless : typeof opt ?. headless === 'boolean' ? opt . headless : true ,
13
+ headless : typeof opt ?. headless === 'boolean' ? opt . headless : false ,
14
14
} ) ;
15
15
const originPage = ( await browser . pages ( ) ) [ 0 ] ;
16
16
const viewportConfig = {
You can’t perform that action at this time.
0 commit comments