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,13 +264,10 @@ 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) {
for (let i = 0; i < window.frames.length; ++i) {
const frame = window.frames[i];
if (iframe_same_domain(frame)) {
if (frame.frameElement === elem) {
return func(frame);
}
}
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);
}
return null;
}