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

Support prefixing line-clamp #1322

Open
jathak opened this issue Jun 15, 2020 · 3 comments
Open

Support prefixing line-clamp #1322

jathak opened this issue Jun 15, 2020 · 3 comments
Labels

Comments

@jathak
Copy link

jathak commented Jun 15, 2020

While the standard line-clamp property is not yet supported in any browsers, the prefixed -webkit-line-clamp is unusual in that it is supported in all modern browsers, including Firefox.

-webkit-line-clamp, unlike the standard line-clamp, also requires display: -webkit-box and -webkit-box-orient: vertical, so ideally Autoprefixer should add those properties as well.

Input

.example {
  line-clamp: 2;
}

Expected Output (for all current browsers)

.example {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
}
@ai ai added the support label Jun 16, 2020
@ai
Copy link
Member

ai commented Jun 16, 2020

Thanks for the links, they are very helpful for us.

Unfortunately, because of architectural limits (and project goal), we can’t insert display: -webkit-box and -webkit-box-orient: vertical (Autoprefixer adds simple prefix and convert syntaxes, but do not work with polyfills).

Imagine if the user will write CSS like this and got an unexpected result because they didn’t know how line-clamp is implemented inside:

.bad {
  line-clamp: 2;
  display: inline-block; /* this property will override display: -webkit-box and break the hack */
}

What do you think if the user should write (and Autoprefixer will insert only -webkit-line-clamp: 2)?

.example {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  line-clamp: 2; /* Autoprefixer will insert -webkit-line-clamp: 2 above */
}

@ai
Copy link
Member

ai commented Jun 16, 2020

Do you want to save your name in the project history? It is not hard to add line-clamp support:

  1. Add a feature to data/prefixes.js. You can use other features as an example (caniuse-lite file will use the same name as feat option from Can I Use URL).
  2. Then you will need a “hack” to override prefixes to -webkit-. You can use appearance hack as an example.
  3. Here is a place to load your hack.
  4. Examples to write tests.

@lukewarlow
Copy link
Contributor

Due to the above mentioned complex nature of the interop between line-clamp and -webkit-line-clamp this issue should probably wait until there's at least one implementation of the standard version to validate that the output is actually useful?

Tracking bugs for reference:

Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1540681
Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=305376

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

No branches or pull requests

4 participants
@ai @jathak @lukewarlow and others