File tree 1 file changed +9
-6
lines changed
packages/frontend/components/share-preview
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 1
1
export const SharePreviewComponent = class extends HTMLElement {
2
2
connectedCallback ( ) {
3
+ this . $form = this . closest ( "form" ) ;
3
4
this . $$outputs = this . querySelectorAll ( "output" ) ;
4
5
for ( const $output of this . $$outputs ) {
5
6
this . updatePreview ( $output ) ;
@@ -12,15 +13,17 @@ export const SharePreviewComponent = class extends HTMLElement {
12
13
* Resize parent window to fit output preview and input form
13
14
*/
14
15
resizeWindow ( ) {
15
- const { scrollWidth, scrollHeight } = this . closest ( "form" ) ;
16
+ if ( this . $form ) {
17
+ const { scrollWidth, scrollHeight } = this . $form ;
16
18
17
- const chromeWidth = window . outerWidth - window . innerWidth ;
18
- const chromeHeight = window . outerHeight - window . innerHeight ;
19
+ const chromeWidth = window . outerWidth - window . innerWidth ;
20
+ const chromeHeight = window . outerHeight - window . innerHeight ;
19
21
20
- const width = scrollWidth + chromeWidth ;
21
- const height = scrollHeight + chromeHeight ;
22
+ const width = scrollWidth + chromeWidth ;
23
+ const height = scrollHeight + chromeHeight ;
22
24
23
- window . resizeTo ( width , height ) ;
25
+ window . resizeTo ( width , height ) ;
26
+ }
24
27
}
25
28
26
29
/**
You can’t perform that action at this time.
0 commit comments