File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ function init() {
186
186
187
187
return isPlain
188
188
? `{ ${ props . join ( ', ' ) } }`
189
- : `${ value . constructor ?. name || 'Object' } { ${ props . join ( ', ' ) } }` ;
189
+ : `${ value . constructor ?. name ?? 'Object' } { ${ props . join ( ', ' ) } }` ;
190
190
}
191
191
192
192
return String ( value ) ;
@@ -210,22 +210,19 @@ function init() {
210
210
211
211
const textArea = document . createElement ( 'textarea' ) ;
212
212
textArea . value = text ;
213
- textArea . style . position = 'fixed' ;
214
- textArea . style . top = '0' ;
215
- textArea . style . left = '0' ;
216
- textArea . style . opacity = '0' ;
213
+ textArea . classList . add ( 'copy-fallback' ) ;
217
214
document . body . appendChild ( textArea ) ;
218
215
textArea . focus ( ) ;
219
216
textArea . select ( ) ;
220
217
221
218
try {
222
219
const successful = document . execCommand ( 'copy' ) ;
223
220
document . body . removeChild ( textArea ) ;
224
- if ( successful ) return Promise . resolve ( ) ;
225
- return Promise . reject ( new Error ( 'Copy command was unsuccessful' ) ) ;
221
+ if ( successful ) return true ;
222
+ throw new Error ( 'Copy command was unsuccessful' ) ;
226
223
} catch ( err ) {
227
224
document . body . removeChild ( textArea ) ;
228
- return Promise . reject ( err ) ;
225
+ throw err ;
229
226
}
230
227
}
231
228
Original file line number Diff line number Diff line change 220
220
}
221
221
}
222
222
}
223
+
224
+ .copy-fallback {
225
+ position : fixed ;
226
+ top : 0 ;
227
+ left : 0 ;
228
+ opacity : 0 ;
229
+ }
You can’t perform that action at this time.
0 commit comments