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

Adding sync method to update atrr from inline style updates #9410

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Added test for serialize method

  • Loading branch information
craftytrickster committed May 19, 2016
commit 34eb0c23f114fe8c05521374ab611c6e7e42d0fb
@@ -7,6 +7,10 @@ use std::env;
use std::fs::{File, remove_file};
use std::path::Path;
use std::process::Command;
use std::sync::Arc;
use style::computed_values::display::T::inline_block;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue};
use style::values::specified::{Length, LengthOrPercentageOrAuto, LengthOrPercentage};

#[test]
fn properties_list_json() {
@@ -51,3 +55,38 @@ fn find_python() -> String {
"python"
}.to_owned()
}

#[test]
fn property_declaration_block_should_serialize_correctly() {
let mut normal = Vec::new();
let mut important = Vec::new();

let length = LengthOrPercentageOrAuto::Length(Length::from_px(70f32));
let value = DeclaredValue::Value(length);
normal.push(PropertyDeclaration::Width(value));

let min_height = LengthOrPercentage::Length(Length::from_px(20f32));
let value = DeclaredValue::Value(min_height);
normal.push(PropertyDeclaration::MinHeight(value));

let value = DeclaredValue::Value(inline_block);
normal.push(PropertyDeclaration::Display(value));

let height = LengthOrPercentageOrAuto::Length(Length::from_px(20f32));
let value = DeclaredValue::Value(height);
important.push(PropertyDeclaration::Height(value));

normal.reverse();
important.reverse();
let block = PropertyDeclarationBlock {
normal: Arc::new(normal),
important: Arc::new(important)
};

let css_string = block.serialize();

assert_eq!(
css_string,
"width: 70px; min-height: 20px; display: inline-block; height: 20px ! important;"
);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.