Handle src='' in an iframe element. Without this, infinitely creates iframes with the same url.

This commit is contained in:
Glenn Watson 2014-09-16 13:13:58 +10:00
parent 8a02fe0fc6
commit 111de569ac

View file

@ -75,9 +75,14 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
fn get_url(&self) -> Option<Url> {
let element: &JSRef<Element> = ElementCast::from_ref(self);
element.get_attribute(Null, "src").root().and_then(|src| {
let window = window_from_node(self).root();
UrlParser::new().base_url(&window.deref().page().get_url())
.parse(src.deref().value().as_slice()).ok()
let url = src.deref().value();
if url.as_slice().is_empty() {
None
} else {
let window = window_from_node(self).root();
UrlParser::new().base_url(&window.deref().page().get_url())
.parse(url.as_slice()).ok()
}
})
}