Simplify logic for checking if an element is a frame

This commit is contained in:
Jay Kamat 2018-01-19 15:25:03 -05:00
parent 12d729c3bc
commit 968367b042
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -278,10 +278,13 @@ window._qutebrowser.webelem = (function() {
// Check if elem is an iframe, and if so, return the result of func on it.
// If no iframes match, return null
function call_if_frame(elem, func) {
const frame = elem.contentWindow;
// Check if elem is a frame, and if so, call func on the window
if (frame && iframe_same_domain(frame) && frame.frameElement) {
return func(frame);
if ("contentWindow" in elem) {
const frame = elem.contentWindow;
if (iframe_same_domain(frame) &&
"frameElement" in elem.contentWindow) {
return func(frame);
}
}
return null;
}