Merge pull request #14 from kxt/13-fix-lazy-images-laziness-check
Fix laziness check in fix_lazy_images
This commit is contained in:
commit
102304544d
1 changed files with 9 additions and 2 deletions
|
@ -1248,8 +1248,7 @@ impl Readability {
|
||||||
let srcset = node_attr.get("srcset");
|
let srcset = node_attr.get("srcset");
|
||||||
let class = node_attr.get("class");
|
let class = node_attr.get("class");
|
||||||
if (src.is_some() || srcset.is_some())
|
if (src.is_some() || srcset.is_some())
|
||||||
&& class.is_some()
|
&& class.and_then(|classname| classname.find("lazy")).is_none()
|
||||||
&& !class.unwrap().contains("lazy")
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3160,6 +3159,7 @@ characters. For that reason, this <p> tag could not be a byline because it's too
|
||||||
<source media="(min-width:465px)" srcset="img_white_flower.jpg">
|
<source media="(min-width:465px)" srcset="img_white_flower.jpg">
|
||||||
<img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
|
<img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
|
||||||
</picture>
|
</picture>
|
||||||
|
<img id="no-lazy-class" src="https://image.url/" data-attrs="{"src":"https://other.url/1.png","alt":""}"/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"#;
|
"#;
|
||||||
|
@ -3189,6 +3189,13 @@ characters. For that reason, this <p> tag could not be a byline because it's too
|
||||||
lazy_loaded_attrs.get("data-src"),
|
lazy_loaded_attrs.get("data-src"),
|
||||||
lazy_loaded_attrs.get("src")
|
lazy_loaded_attrs.get("src")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let no_lazy_class = doc.root_node.select_first("#no-lazy-class").unwrap();
|
||||||
|
let no_lazy_class_attrs = no_lazy_class.attributes.borrow();
|
||||||
|
assert_eq!(
|
||||||
|
no_lazy_class_attrs.get("src").unwrap(),
|
||||||
|
"https://image.url/"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Reference in a new issue