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

Text spacing not !important does not account for actual font-size [78fd32, 24afc2, 9e45ec] #1688

Closed
WilcoFiers opened this issue Aug 18, 2021 · 2 comments · Fixed by #1923
Closed
Assignees

Comments

@WilcoFiers
Copy link
Member

This issue applies to the following three rules:

This is a false positive. The rule fails the div for not having a letter-spacing that's less than 0.15 times the font-size, but then the p element reduces the font-size, and so in actuality the text ends up with letter spacing that is sufficient.

<div style="font-size: 16px; letter-spacing: 2px !important">
  <p style="font-size: 10px;">
    The toy brought back fond memories of being lost in the rain forest.
  </p>
</div>
@Jym77
Copy link
Collaborator

Jym77 commented Aug 19, 2021

Great catch!

It's going to be annoying to correctly express…
🤔

wide enough: for each text node descendant whose parent's cascaded letter-spacing is the one specified in the style attribute of the target, the computed value of its [=the parent of text node] letter-spacing property is at least 0.12 times the computed value of its [=the parent of text node] font-size property; or

In your example, the text node's parent's cascaded letter-spacing is the one defined in the div's style, but it is 0.12 times the text node's parent's computed font-size (10px), so it's OK…

This formulation should also catch cases where the p inside the div specifies another letter-spacing.

@Jym77
Copy link
Collaborator

Jym77 commented Aug 23, 2021

Working on this (and #1687) on Alfa's doc, this is what I ended up with:
Replace the current

For each test target, at least one of the following is true:

- **not important**: the [computed][] value of its [letter-spacing][] property is not [important][]; or
- **wide enough**: the [computed][] value of its [letter-spacing][] property is at least 0.12 times the [computed][] value of its [font-size][] property; or
- **cascade**: the [cascaded][] value of its [letter-spacing][] property is not a value [declared][] in its `style` attribute.

by

For each test target, at least one of the following is true:

- **not important**: the [computed][] value of its [letter-spacing][] property is not [important][]; or
- **wide enough**: for each non-[whitespace][] only text node descendant of this target, either its parent is [wide enough][#wide-enough], or its parent's [cascaded][] [letter-spacing][] property is not the one [declared][] in the `style` attribute of the target.

An element has a <dfn id="wide-enough">wide enough letter spacing</dfn> if the computed value of its [letter-spacing][] property is at least 0.12 times the computed value of its [font-size][] property.

There is an annoying part with defining "wide enough" just after the expectation. I think this is better than trying to inline that in the bullet list. It's not really possible to have it as separate definition (or rather, we'd need one for each of the three rules since they are about different properties, and that would be defs used in one rule each, which is a bit annoying).

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