Skip to content

Commit dc794a0

Browse files
authored
Merge pull request #1076 from sergioalcaraz/fix_type_error
Fix TypeError: Cannot read properties of null
2 parents 14a7635 + 2405fc6 commit dc794a0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

webroot/js/inject-iframe.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if (elem) {
7777
url: this._arguments && this._arguments[1],
7878
type: this.getResponseHeader('Content-Type'),
7979
};
80-
iframe.contentWindow.postMessage(`ajax-completed$$${JSON.stringify(params)}`, window.location.origin);
80+
iframe.contentWindow?.postMessage(`ajax-completed$$${JSON.stringify(params)}`, window.location.origin);
8181
}
8282
if (original) {
8383
return original.apply(this, [].slice.call(arguments));
@@ -124,7 +124,7 @@ if (elem) {
124124
url,
125125
type: response.headers.get('Content-Type'),
126126
};
127-
iframe.contentWindow.postMessage(`ajax-completed$$${JSON.stringify(params)}`, window.location.origin);
127+
iframe.contentWindow?.postMessage(`ajax-completed$$${JSON.stringify(params)}`, window.location.origin);
128128
}
129129
return response;
130130
} catch (error) {
@@ -138,7 +138,7 @@ if (elem) {
138138
type: null,
139139
error: error.message,
140140
};
141-
iframe.contentWindow.postMessage(`ajax-completed$$${JSON.stringify(params)}`, window.location.origin);
141+
iframe.contentWindow?.postMessage(`ajax-completed$$${JSON.stringify(params)}`, window.location.origin);
142142
throw error;
143143
}
144144
};

0 commit comments

Comments
 (0)