ExCSS icon indicating copy to clipboard operation
ExCSS copied to clipboard

Janky at-rule catches FillDeclaration in an infinite loop

Open phil-scott-78 opened this issue 3 years ago • 3 comments

I pointed this at a tailwind css file with a @apply rule and the ParseStylesheet gets caught in an infinite loop in StylesheetComposer at FillDeclarations trying to handle the AtKeyword.

Quick little reproduction.

var parser = new StylesheetParser();
var r = parser.Parse(@"
.test {
    @apply ml-2;
}
");

As an aside, it would be pretty slick if things like this weren't ignored but included in the results.

phil-scott-78 avatar Apr 05 '22 20:04 phil-scott-78

Thanks for posting this. While the engine shouldn't land in an endless loop, I'm not sure what to do with the rule since it's not part of the CSS2/3 standard. The @apply tag proposal was abandoned in favor of shadow parts. However some CSS pre-processors make use of it.

The rules currently supported are those listed in the At-rule specs https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule

So the question is whether a malformed rule is something to code for. While this is fine for Tailwind, I don't know if it makes sense to try to add specific At rules as children of properties. Perhaps a generic catch-all rule would suffice - I'll have to think through this one.

TylerBrinks avatar Apr 06 '22 17:04 TylerBrinks

Yeah, I agree that not a ton of effort should be spent on non-standard things like this. It being discarded wouldn't be an unexpected behavior to me

phil-scott-78 avatar Apr 06 '22 18:04 phil-scott-78