Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse sizes attribute implementation #10989

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

unit test added

  • Loading branch information
sneha1302 committed May 3, 2016
commit 935f197486af2232e1fe187fbee16f080d642d06
@@ -410,6 +410,7 @@ fn image_dimension_setter(element: &Element, attr: Atom, value: u32) {
element.set_attribute(&attr, value);
}


pub fn parse_a_sizes_attribute(input: DOMString, width: Option<u32>) -> Vec<Size> {
let mut sizes = Vec::<Size>::new();
let unparsed_sizes = input.deref().split(',').collect::<Vec<_>>();

Some generated files are not rendered by default. Learn more.

@@ -12,5 +12,6 @@ doctest = false
msg = {path = "../../../components/msg"}
plugins = {path = "../../../components/plugins"}
script = {path = "../../../components/script"}
style = {path = "../../../components/style"}
util = {path = "../../../components/util"}
url = {version = "1.0.0", features = ["heap_size"]}
@@ -4,7 +4,11 @@

#![feature(plugin)]
#![plugin(plugins)]

//use cssparser::Parser;
use script::dom::htmlimageelement::parse_a_sizes_attribute;
//use style::values::specified::{Length, ViewportPercentageLength};
use script::dom::htmlimageelement::Size;
use util::str::DOMString;

#[test]
@@ -16,6 +20,24 @@ fn some_parse_sizes_test() {
assert_eq!(result.len(), 3);
}

//testing the second element which has two expressions
#[test]
fn some_parse_sizes_1_test() {
let mut result = parse_a_sizes_attribute(DOMString::from("(min-width: 900px) 1000px,
(max-width: 900px) and (min-width: 400px) 50em,
100vw "),
None);
let trimmed = "100vw";
let mut component = result.pop();
let mut component_secondlast = result.pop();
if component_secondlast.is_some() {
let component_query = component_secondlast.unwrap().query;
if component_query.is_some(){
let component_query_expr = component_query.unwrap().expressions;
assert_eq!(component_query_expr.len() , 2);
}
}
}
extern crate msg;
extern crate script;
extern crate url;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.