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

CSS parser includes all media under "all" #2

Open
pjt33 opened this issue Aug 31, 2022 · 0 comments
Open

CSS parser includes all media under "all" #2

pjt33 opened this issue Aug 31, 2022 · 0 comments

Comments

@pjt33
Copy link

pjt33 commented Aug 31, 2022

Consider the following CSS:

@media print {
    foo { bar: baz }
}

This should only affect media "print". However, it's being parsed by ParseStyleBlocks and inserted under media "all" before being parsed again by ParseMediaStyleBlocks and inserted under media "print".

Code which demonstrates this:

var testCSS = @"
@media print {
    foo { bar: baz }
}";
var css = CssData.Parse(adapter, testCSS, false);
Assert(css.GetCssBlock("foo", "print").First().Properties["bar"] == "baz");
Assert(!css.GetCssBlock("foo", "all").Any(block => block.Properties.ContainsKey("bar")));

This bug then has knock-on effects because the default CSS includes an @media print section with h1 { page-break-before: always }, which is thoroughly undesirable in the WPF renderer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant