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

:lang CSS selector support? #446

Closed
fungc opened this issue Feb 19, 2020 · 3 comments
Closed

:lang CSS selector support? #446

fungc opened this issue Feb 19, 2020 · 3 comments

Comments

@fungc
Copy link

fungc commented Feb 19, 2020

Hi guys,
I am trying to produce a PDF, but my HTML has <style> with the :lang CSS selector.
https://www.w3schools.com/cssref/sel_lang.asp

And I have the html attribute like
https://www.w3schools.com/tags/att_global_lang.asp

However, the produced PDF is ignoring styles in body:lang(de) {}

Is there someway I can make this work? Thanks!

@fungc
Copy link
Author

fungc commented Feb 20, 2020

Ok I think I might have found the bug

Suppose we have

attRes.getLang(e) with return "ja" for the html element, but return empty string "" for the body element.

This means getLang is not looking up the parent lang attribute.

Is that expected?

@danfickle
Copy link
Owner

I finally found example 30 from Selectors Level 4 which suggest our behavior is wrong:

In this HTML example, only the BODY matches ''[lang|=fr]'' (because it has a LANG attribute) but both the BODY and the P match :lang(fr) (because both are in French). The P does not match the ''[lang|=fr]'' because it does not have a LANG attribute.

<body lang=fr>
  <p>Je suis français.</p>
</body>

I'll commit a fix that looks up the parent chain for a lang attribute. In the meantime, if you know the element the lang attribute is set on, you could of course use a descendant selector.

html:lang(ja) body { }

@fungc
Copy link
Author

fungc commented Feb 20, 2020

From reading the source code I found that this works with the current version
<meta http-equiv="Content-Language" content="de" />
But yes it would be better to have a fix

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

No branches or pull requests

2 participants