File tree Expand file tree Collapse file tree 2 files changed +26
-16
lines changed Expand file tree Collapse file tree 2 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -262,15 +262,20 @@ class LiveTranslatorManager {
262
262
}
263
263
if ( badges . length ) {
264
264
let position = { top : 0 , left : 0 } ;
265
- if ( node instanceof Text ) {
266
- const clientRect = getBoundingClientRect ( node ) ;
267
- position . top = clientRect . top + window . scrollY ;
268
- position . left = clientRect . left + window . screenX ;
265
+ try {
266
+ if ( node instanceof Text ) {
267
+ const clientRect = getBoundingClientRect ( node ) ;
268
+ position . top = clientRect . top + window . scrollY ;
269
+ position . left = clientRect . left + window . screenX ;
270
+ }
271
+ else {
272
+ const clientRect = node . getClientRects ( ) [ 0 ] ;
273
+ position . top = clientRect . top + clientRect . height - 10 + window . scrollY ;
274
+ position . left = clientRect . left + window . screenX ;
275
+ }
269
276
}
270
- else {
271
- const clientRect = node . getClientRects ( ) [ 0 ] ;
272
- position . top = clientRect . top + clientRect . height - 10 + window . scrollY ;
273
- position . left = clientRect . left + window . screenX ;
277
+ catch ( error ) {
278
+ console . error ( error , node , node . tagName ) ;
274
279
}
275
280
const container = document . createElement ( 'span' ) ;
276
281
container . classList . add ( 'live-translator-badge-container' ) ;
Original file line number Diff line number Diff line change @@ -308,14 +308,19 @@ class LiveTranslatorManager {
308
308
309
309
if ( badges . length ) {
310
310
let position = { top : 0 , left : 0 }
311
- if ( node instanceof Text ) {
312
- const clientRect = getBoundingClientRect ( node )
313
- position . top = clientRect . top + window . scrollY
314
- position . left = clientRect . left + window . screenX
315
- } else {
316
- const clientRect = node . getClientRects ( ) [ 0 ]
317
- position . top = clientRect . top + clientRect . height - 10 + window . scrollY
318
- position . left = clientRect . left + window . screenX
311
+ try {
312
+ if ( node instanceof Text ) {
313
+ const clientRect = getBoundingClientRect ( node )
314
+ position . top = clientRect . top + window . scrollY
315
+ position . left = clientRect . left + window . screenX
316
+ } else {
317
+ const clientRect = node . getClientRects ( ) [ 0 ]
318
+ position . top = clientRect . top + clientRect . height - 10 + window . scrollY
319
+ position . left = clientRect . left + window . screenX
320
+ }
321
+ } catch ( error ) {
322
+ console . error ( error , node , node . tagName ) ;
323
+
319
324
}
320
325
const container = document . createElement ( 'span' )
321
326
container . classList . add ( 'live-translator-badge-container' )
You can’t perform that action at this time.
0 commit comments