From 2c3aa42fb4915170b6a071a7bff6fad69976a04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:11:37 +0900 Subject: [PATCH 01/11] Add a test --- crates/swc_css_parser/tests/fixture/issue-8461/input.css | 1 + 1 file changed, 1 insertion(+) create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/input.css diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/input.css b/crates/swc_css_parser/tests/fixture/issue-8461/input.css new file mode 100644 index 000000000000..9cad0f225bed --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/input.css @@ -0,0 +1 @@ +.foo:global(.bar).baz {} \ No newline at end of file From b2115ba5649833da6d5a1d4df8f5da265404c1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:13:48 +0900 Subject: [PATCH 02/11] Add a test --- crates/swc_css_parser/tests/fixture/issue-8461/{ => 1}/input.css | 0 crates/swc_css_parser/tests/fixture/issue-8461/2/input.css | 1 + 2 files changed, 1 insertion(+) rename crates/swc_css_parser/tests/fixture/issue-8461/{ => 1}/input.css (100%) create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/2/input.css diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/input.css b/crates/swc_css_parser/tests/fixture/issue-8461/1/input.css similarity index 100% rename from crates/swc_css_parser/tests/fixture/issue-8461/input.css rename to crates/swc_css_parser/tests/fixture/issue-8461/1/input.css diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/2/input.css b/crates/swc_css_parser/tests/fixture/issue-8461/2/input.css new file mode 100644 index 000000000000..260b4df2b853 --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/2/input.css @@ -0,0 +1 @@ +.foo :global(.bar).baz {} \ No newline at end of file From 0bf3017304317877574d498fe996eca0a74f6ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:35:09 +0900 Subject: [PATCH 03/11] Add tests --- crates/swc_css_modules/tests/fixture/issue-8461/1/input.css | 1 + crates/swc_css_modules/tests/fixture/issue-8461/2/input.css | 1 + 2 files changed, 2 insertions(+) create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/1/input.css create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.css diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/1/input.css b/crates/swc_css_modules/tests/fixture/issue-8461/1/input.css new file mode 100644 index 000000000000..9cad0f225bed --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/1/input.css @@ -0,0 +1 @@ +.foo:global(.bar).baz {} \ No newline at end of file diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.css b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.css new file mode 100644 index 000000000000..260b4df2b853 --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.css @@ -0,0 +1 @@ +.foo :global(.bar).baz {} \ No newline at end of file From d517447f7e19faa5cae612235b3ccc6fdaa6e4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:36:43 +0900 Subject: [PATCH 04/11] Update test refs --- .../issue-8461/1/leading-comments.json | 1 + .../tests/fixture/issue-8461/1/output.json | 151 +++++++++++++++ .../fixture/issue-8461/1/span.swc-stderr | 126 +++++++++++++ .../issue-8461/1/trailing-comments.json | 1 + .../issue-8461/2/leading-comments.json | 1 + .../tests/fixture/issue-8461/2/output.json | 172 ++++++++++++++++++ .../fixture/issue-8461/2/span.swc-stderr | 138 ++++++++++++++ .../issue-8461/2/trailing-comments.json | 1 + 8 files changed, 591 insertions(+) create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/1/leading-comments.json create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/1/output.json create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/1/span.swc-stderr create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/1/trailing-comments.json create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/2/leading-comments.json create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/2/output.json create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/2/span.swc-stderr create mode 100644 crates/swc_css_parser/tests/fixture/issue-8461/2/trailing-comments.json diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/1/leading-comments.json b/crates/swc_css_parser/tests/fixture/issue-8461/1/leading-comments.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/1/leading-comments.json @@ -0,0 +1 @@ +{} diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/1/output.json b/crates/swc_css_parser/tests/fixture/issue-8461/1/output.json new file mode 100644 index 000000000000..37759deb3d1d --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/1/output.json @@ -0,0 +1,151 @@ +{ + "type": "Stylesheet", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "rules": [ + { + "type": "QualifiedRule", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "prelude": { + "type": "SelectorList", + "span": { + "start": 1, + "end": 22, + "ctxt": 0 + }, + "children": [ + { + "type": "ComplexSelector", + "span": { + "start": 1, + "end": 22, + "ctxt": 0 + }, + "children": [ + { + "type": "CompoundSelector", + "span": { + "start": 1, + "end": 22, + "ctxt": 0 + }, + "nestingSelector": null, + "typeSelector": null, + "subclassSelectors": [ + { + "type": "ClassSelector", + "span": { + "start": 1, + "end": 5, + "ctxt": 0 + }, + "text": { + "type": "Ident", + "span": { + "start": 2, + "end": 5, + "ctxt": 0 + }, + "value": "foo", + "raw": "foo" + } + }, + { + "type": "PseudoClassSelector", + "span": { + "start": 5, + "end": 18, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 6, + "end": 12, + "ctxt": 0 + }, + "value": "global", + "raw": "global" + }, + "children": [ + { + "type": "PreservedToken", + "span": { + "start": 13, + "end": 14, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "." + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "bar", + "raw": "bar" + } + } + } + ] + }, + { + "type": "ClassSelector", + "span": { + "start": 18, + "end": 22, + "ctxt": 0 + }, + "text": { + "type": "Ident", + "span": { + "start": 19, + "end": 22, + "ctxt": 0 + }, + "value": "baz", + "raw": "baz" + } + } + ] + } + ] + } + ] + }, + "block": { + "type": "SimpleBlock", + "span": { + "start": 23, + "end": 25, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 23, + "end": 24, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] + } + } + ] +} diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/1/span.swc-stderr b/crates/swc_css_parser/tests/fixture/issue-8461/1/span.swc-stderr new file mode 100644 index 000000000000..87c0aa960b0a --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/1/span.swc-stderr @@ -0,0 +1,126 @@ + + x Stylesheet + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Rule + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x QualifiedRule + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x SelectorList + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ComplexSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x CompoundSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^ + `---- + + x ClassSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^ + `---- + + x PseudoClassSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^^^^^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^^^ + `---- + + x PseudoClassSelectorChildren + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^ + `---- + + x Delim { value: '.' } + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^ + `---- + + x PseudoClassSelectorChildren + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^ + `---- + + x Ident { value: "bar", raw: "bar" } + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^ + `---- + + x ClassSelector + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^^ + `---- + + x LBrace + ,-[$DIR/tests/fixture/issue-8461/1/input.css:1:1] + 1 | .foo:global(.bar).baz {} + : ^ + `---- diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/1/trailing-comments.json b/crates/swc_css_parser/tests/fixture/issue-8461/1/trailing-comments.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/1/trailing-comments.json @@ -0,0 +1 @@ +{} diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/2/leading-comments.json b/crates/swc_css_parser/tests/fixture/issue-8461/2/leading-comments.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/2/leading-comments.json @@ -0,0 +1 @@ +{} diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/2/output.json b/crates/swc_css_parser/tests/fixture/issue-8461/2/output.json new file mode 100644 index 000000000000..f7aa4948c8ff --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/2/output.json @@ -0,0 +1,172 @@ +{ + "type": "Stylesheet", + "span": { + "start": 1, + "end": 26, + "ctxt": 0 + }, + "rules": [ + { + "type": "QualifiedRule", + "span": { + "start": 1, + "end": 26, + "ctxt": 0 + }, + "prelude": { + "type": "SelectorList", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "children": [ + { + "type": "ComplexSelector", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "children": [ + { + "type": "CompoundSelector", + "span": { + "start": 1, + "end": 5, + "ctxt": 0 + }, + "nestingSelector": null, + "typeSelector": null, + "subclassSelectors": [ + { + "type": "ClassSelector", + "span": { + "start": 1, + "end": 5, + "ctxt": 0 + }, + "text": { + "type": "Ident", + "span": { + "start": 2, + "end": 5, + "ctxt": 0 + }, + "value": "foo", + "raw": "foo" + } + } + ] + }, + { + "type": "Combinator", + "span": { + "start": 5, + "end": 6, + "ctxt": 0 + }, + "value": " " + }, + { + "type": "CompoundSelector", + "span": { + "start": 6, + "end": 23, + "ctxt": 0 + }, + "nestingSelector": null, + "typeSelector": null, + "subclassSelectors": [ + { + "type": "PseudoClassSelector", + "span": { + "start": 6, + "end": 19, + "ctxt": 0 + }, + "name": { + "type": "Ident", + "span": { + "start": 7, + "end": 13, + "ctxt": 0 + }, + "value": "global", + "raw": "global" + }, + "children": [ + { + "type": "PreservedToken", + "span": { + "start": 14, + "end": 15, + "ctxt": 0 + }, + "token": { + "Delim": { + "value": "." + } + } + }, + { + "type": "PreservedToken", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "token": { + "Ident": { + "value": "bar", + "raw": "bar" + } + } + } + ] + }, + { + "type": "ClassSelector", + "span": { + "start": 19, + "end": 23, + "ctxt": 0 + }, + "text": { + "type": "Ident", + "span": { + "start": 20, + "end": 23, + "ctxt": 0 + }, + "value": "baz", + "raw": "baz" + } + } + ] + } + ] + } + ] + }, + "block": { + "type": "SimpleBlock", + "span": { + "start": 24, + "end": 26, + "ctxt": 0 + }, + "name": { + "type": "PreservedToken", + "span": { + "start": 24, + "end": 25, + "ctxt": 0 + }, + "token": "LBrace" + }, + "value": [] + } + } + ] +} diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/2/span.swc-stderr b/crates/swc_css_parser/tests/fixture/issue-8461/2/span.swc-stderr new file mode 100644 index 000000000000..13e0ca50cc10 --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/2/span.swc-stderr @@ -0,0 +1,138 @@ + + x Stylesheet + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Rule + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x QualifiedRule + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x SelectorList + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x ComplexSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x CompoundSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^ + `---- + + x ClassSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^ + `---- + + x Combinator + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^ + `---- + + x CompoundSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^^^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^ + `---- + + x PseudoClassSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^^^^^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^^^ + `---- + + x PseudoClassSelectorChildren + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^ + `---- + + x Delim { value: '.' } + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^ + `---- + + x PseudoClassSelectorChildren + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^ + `---- + + x Ident { value: "bar", raw: "bar" } + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^ + `---- + + x SubclassSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^ + `---- + + x ClassSelector + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^^ + `---- + + x Ident + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^^ + `---- + + x SimpleBlock + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^^ + `---- + + x LBrace + ,-[$DIR/tests/fixture/issue-8461/2/input.css:1:1] + 1 | .foo :global(.bar).baz {} + : ^ + `---- diff --git a/crates/swc_css_parser/tests/fixture/issue-8461/2/trailing-comments.json b/crates/swc_css_parser/tests/fixture/issue-8461/2/trailing-comments.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/crates/swc_css_parser/tests/fixture/issue-8461/2/trailing-comments.json @@ -0,0 +1 @@ +{} From a99fdbccea81d5233c893db2c7384bd450c822a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:37:51 +0900 Subject: [PATCH 05/11] Update test refs --- .../tests/fixture/issue-8461/2/input.compiled.css | 1 + .../fixture/issue-8461/2/input.transform.json | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css new file mode 100644 index 000000000000..c9b849fa1aef --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css @@ -0,0 +1 @@ +.__local__foo .bar.__local__baz {} diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json new file mode 100644 index 000000000000..6edada8a6266 --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json @@ -0,0 +1,14 @@ +{ + "baz": [ + { + "name": "__local__baz", + "type": "local" + } + ], + "foo": [ + { + "name": "__local__foo", + "type": "local" + } + ] +} From 8697fe312e5671465c6d897fca0a02fcdc8e296c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:43:08 +0900 Subject: [PATCH 06/11] dbg --- crates/swc_css_modules/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/swc_css_modules/src/lib.rs b/crates/swc_css_modules/src/lib.rs index a0cc0a8c1536..67faaa015473 100644 --- a/crates/swc_css_modules/src/lib.rs +++ b/crates/swc_css_modules/src/lib.rs @@ -671,6 +671,9 @@ fn prepend_left_subclass_selectors( sels: &mut Vec, mut sel_index: usize, ) { + dbg!(&complex_selector_children); + dbg!(&sels); + sels.remove(sel_index); for c in complex_selector_children From 957d1fd189f79e8ca0b5fd644c3d482a97cb29be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 12:52:12 +0900 Subject: [PATCH 07/11] remove --- .../tests/fixture/issue-8461/2/input.compiled.css | 1 - .../fixture/issue-8461/2/input.transform.json | 14 -------------- 2 files changed, 15 deletions(-) delete mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css delete mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css deleted file mode 100644 index c9b849fa1aef..000000000000 --- a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css +++ /dev/null @@ -1 +0,0 @@ -.__local__foo .bar.__local__baz {} diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json deleted file mode 100644 index 6edada8a6266..000000000000 --- a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "baz": [ - { - "name": "__local__baz", - "type": "local" - } - ], - "foo": [ - { - "name": "__local__foo", - "type": "local" - } - ] -} From a08e572bb61a8e911fbc41162d89e6b4d0694246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 13:03:25 +0900 Subject: [PATCH 08/11] more dbg --- crates/swc_css_modules/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/swc_css_modules/src/lib.rs b/crates/swc_css_modules/src/lib.rs index 67faaa015473..b0224641480a 100644 --- a/crates/swc_css_modules/src/lib.rs +++ b/crates/swc_css_modules/src/lib.rs @@ -689,4 +689,7 @@ fn prepend_left_subclass_selectors( sel_index = 0; } + + dbg!(&complex_selector_children); + dbg!(&sels); } From 243bbc11614aaeb9ddeaf2f4a805dde90af9d55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 13:03:40 +0900 Subject: [PATCH 09/11] UTR --- .../tests/fixture/issue-8461/2/input.compiled.css | 1 + .../fixture/issue-8461/2/input.transform.json | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css new file mode 100644 index 000000000000..c9b849fa1aef --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.compiled.css @@ -0,0 +1 @@ +.__local__foo .bar.__local__baz {} diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json new file mode 100644 index 000000000000..6edada8a6266 --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/2/input.transform.json @@ -0,0 +1,14 @@ +{ + "baz": [ + { + "name": "__local__baz", + "type": "local" + } + ], + "foo": [ + { + "name": "__local__foo", + "type": "local" + } + ] +} From a34ccf43f54af8bc4977a38fab3ac4e604182b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 13:07:57 +0900 Subject: [PATCH 10/11] fix --- crates/swc_css_modules/src/lib.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/crates/swc_css_modules/src/lib.rs b/crates/swc_css_modules/src/lib.rs index b0224641480a..d7c2873643f9 100644 --- a/crates/swc_css_modules/src/lib.rs +++ b/crates/swc_css_modules/src/lib.rs @@ -671,9 +671,6 @@ fn prepend_left_subclass_selectors( sels: &mut Vec, mut sel_index: usize, ) { - dbg!(&complex_selector_children); - dbg!(&sels); - sels.remove(sel_index); for c in complex_selector_children @@ -682,14 +679,10 @@ fn prepend_left_subclass_selectors( { c.subclass_selectors.splice(0..0, sels.drain(..sel_index)); - if sels.len() > sel_index { - c.subclass_selectors - .extend(sels[..sel_index + 1].iter().cloned()); + if !sels.is_empty() { + c.subclass_selectors.extend(sels[..].iter().cloned()); } sel_index = 0; } - - dbg!(&complex_selector_children); - dbg!(&sels); } From 5d9053bbd99ab573ab77c4214bea6e6fff225fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 7 May 2024 13:08:03 +0900 Subject: [PATCH 11/11] Update test refs --- .../tests/fixture/issue-8179.compiled.css | 2 +- .../tests/fixture/issue-8461/1/input.compiled.css | 1 + .../fixture/issue-8461/1/input.transform.json | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/1/input.compiled.css create mode 100644 crates/swc_css_modules/tests/fixture/issue-8461/1/input.transform.json diff --git a/crates/swc_css_modules/tests/fixture/issue-8179.compiled.css b/crates/swc_css_modules/tests/fixture/issue-8179.compiled.css index 5a3818351770..d2b81ad524ea 100644 --- a/crates/swc_css_modules/tests/fixture/issue-8179.compiled.css +++ b/crates/swc_css_modules/tests/fixture/issue-8179.compiled.css @@ -1,3 +1,3 @@ -.__local__a.b .c.__local__d { +.__local__a.b.__local__d .c.__local__d { color: red; } diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/1/input.compiled.css b/crates/swc_css_modules/tests/fixture/issue-8461/1/input.compiled.css new file mode 100644 index 000000000000..e5362a4744e1 --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/1/input.compiled.css @@ -0,0 +1 @@ +.__local__foo.bar.__local__baz {} diff --git a/crates/swc_css_modules/tests/fixture/issue-8461/1/input.transform.json b/crates/swc_css_modules/tests/fixture/issue-8461/1/input.transform.json new file mode 100644 index 000000000000..6edada8a6266 --- /dev/null +++ b/crates/swc_css_modules/tests/fixture/issue-8461/1/input.transform.json @@ -0,0 +1,14 @@ +{ + "baz": [ + { + "name": "__local__baz", + "type": "local" + } + ], + "foo": [ + { + "name": "__local__foo", + "type": "local" + } + ] +}