Skip to content

Commit

Permalink
refactor: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Dec 18, 2022
1 parent 6ced45a commit 4c8d4e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions crates/swc_css_compat/src/compiler/mod.rs
@@ -1,8 +1,8 @@
use swc_common::{Spanned, DUMMY_SP};
use swc_css_ast::{
AbsoluteColorBase, AtRule, ComponentValue, MediaAnd, MediaCondition, MediaConditionAllType,
AtRule, ComponentValue, CompoundSelector, MediaAnd, MediaCondition, MediaConditionAllType,
MediaConditionWithoutOr, MediaInParens, MediaQuery, Rule, SupportsCondition,
AbsoluteColorBase, AtRule, ComponentValue, CompoundSelector, MediaAnd, MediaCondition,
MediaConditionAllType, MediaConditionWithoutOr, MediaInParens, MediaQuery, Rule,
SupportsCondition,
};
use swc_css_visit::{VisitMut, VisitMutWith};

Expand All @@ -15,8 +15,8 @@ mod color_space_separated_parameters;
mod custom_media;
mod legacy_rgb_and_hsl;
mod media_query_ranges;
mod utils;
mod selector_not;
mod utils;

/// Compiles a modern CSS file to a CSS file which works with old browsers.
#[derive(Debug)]
Expand Down
27 changes: 20 additions & 7 deletions crates/swc_css_compat/tests/fixture.rs
Expand Up @@ -62,7 +62,6 @@ fn test_nesting(input: PathBuf, suffix: Option<&str>) {
};

testing::run_test(false, |cm, _| {
//
let fm = cm.load_file(&input).unwrap();
let mut ss = parse_stylesheet(&fm);

Expand All @@ -87,7 +86,6 @@ fn test_custom_media_query(input: PathBuf) {
let output = input.with_extension("expect.css");

testing::run_test(false, |cm, _| {
//
let fm = cm.load_file(&input).unwrap();
let mut ss = parse_stylesheet(&fm);

Expand All @@ -109,7 +107,6 @@ fn test_media_query_ranges(input: PathBuf) {
let output = input.with_extension("expect.css");

testing::run_test(false, |cm, _| {
//
let fm = cm.load_file(&input).unwrap();
let mut ss = parse_stylesheet(&fm);

Expand All @@ -131,7 +128,6 @@ fn test_color_hex_alpha(input: PathBuf) {
let output = input.with_extension("expect.css");

testing::run_test(false, |cm, _| {
//
let fm = cm.load_file(&input).unwrap();
let mut ss = parse_stylesheet(&fm);

Expand All @@ -150,19 +146,36 @@ fn test_color_hex_alpha(input: PathBuf) {

#[testing::fixture("tests/color-legacy/**/*.css", exclude("expect.css"))]
fn test_color_space_separated_function_notation(input: PathBuf) {
#[testing::fixture("tests/selector-not/**/*.css", exclude("expect.css"))]
fn test_selector_not(input: PathBuf) {
let output = input.with_extension("expect.css");

testing::run_test(false, |cm, _| {
//
let fm = cm.load_file(&input).unwrap();
let mut ss = parse_stylesheet(&fm);

ss.visit_mut_with(&mut Compiler::new(Config {
process: Features::COLOR_SPACE_SEPARATED_PARAMETERS
| Features::COLOR_ALPHA_PARAMETER
| Features::COLOR_LEGACY_RGB_AND_HSL,
}));

let s = print_stylesheet(&ss);

NormalizedOutput::from(s).compare_to_file(&output).unwrap();

Ok(())
})
.unwrap();
}

#[testing::fixture("tests/selector-not/**/*.css", exclude("expect.css"))]
fn test_selector_not(input: PathBuf) {
let output = input.with_extension("expect.css");

testing::run_test(false, |cm, _| {
let fm = cm.load_file(&input).unwrap();
let mut ss = parse_stylesheet(&fm);

ss.visit_mut_with(&mut Compiler::new(Config {
process: Features::SELECTOR_NOT,
}));

Expand Down

0 comments on commit 4c8d4e4

Please sign in to comment.