Stop iterating over every frame to check if element is frame

This commit is contained in:
Jay Kamat 2018-01-17 13:08:04 -05:00
parent 8500509532
commit c5e688f26c
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -264,14 +264,11 @@ 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) {
for (let i = 0; i < window.frames.length; ++i) { const frame = elem.contentWindow;
const frame = window.frames[i]; // Check if elem is a frame, and if so, call func on the window
if (iframe_same_domain(frame)) { if (frame && iframe_same_domain(frame) && frame.frameElement) {
if (frame.frameElement === elem) {
return func(frame); return func(frame);
} }
}
}
return null; return null;
} }