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