File tree Expand file tree Collapse file tree 1 file changed +24
-18
lines changed Expand file tree Collapse file tree 1 file changed +24
-18
lines changed Original file line number Diff line number Diff line change 5050 }
5151 },
5252 setIframeUrl () {
53- const iframeDoc = this .iframeEl .contentWindow .document ;
54- iframeDoc .open ()
55- .write (
56- `
57- <body onload="window.location.href='${ this .src } '; parent.postMessage('${ this .iframeLoadedMessage } ', '*')"></body>
58- <script>
59- window.document.onreadystatechange = function () {
60- if (window.document.readyState === 'complete') {
61- parent.postMessage('${ this .iframeOnReadyStateChangeMessage } ', '*')
62- }
63- };
64- <\/ script>
65- `
66- );
67- iframeDoc .close (); // iframe onload event happens
53+ if (! this .iframeEl .contentWindow ) {
54+ this .initIframe ()
55+ }
56+ this .$nextTick (() => {
57+ const iframeDoc = this .iframeEl .contentWindow .document ;
58+ iframeDoc .open ()
59+ .write (`
60+ <body onload="window.location.href='${ this .src } '; parent.postMessage('${ this .iframeLoadedMessage } ', '*')"></body>
61+ <script>
62+ window.document.onreadystatechange = function () {
63+ if (window.document.readyState === 'complete') {
64+ parent.postMessage('${ this .iframeOnReadyStateChangeMessage } ', '*')
65+ }
66+ };
67+ <\/ script>
68+ ` );
69+ iframeDoc .close (); // iframe onload event happens
70+ })
6871 },
6972 reinitIframe: debounce (function () {
7073 this .removeIframe ();
105108 }, false );
106109 }
107110 },
108- mounted () {
111+ created () {
109112 this .listenForEvents ();
110113 this .initIframe ();
111114 },
112115 watch: {
113- src () {
114- this .reinitIframe ();
116+ src: {
117+ immediate: true ,
118+ handler () {
119+ this .reinitIframe ();
120+ }
115121 }
116122 },
117123 render (createElement ) {
You can’t perform that action at this time.
0 commit comments