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

Use -initial-letter if it is available #1

Open
grorg opened this issue Oct 15, 2014 · 2 comments
Open

Use -initial-letter if it is available #1

grorg opened this issue Oct 15, 2014 · 2 comments

Comments

@grorg
Copy link

grorg commented Oct 15, 2014

First!!

Let's assume you can do this: window.CSS && window.CSS.supports("-webkit-initial-letter", "1");

I suggest you need two flags:

A. onlyExecuteIfNativeIsMissing (or something like that) where the JS will early return if the test above returned false. This would allow an author to write CSS rules that use initial-letter as well as include dropcap.js and not have them conflict.

B. preferNativeImplementation where dropcap.js would use initial-letter rather than setting the styles on the objects. This is actually quite annoying to do thanks to the 💩 that is the CSS OM, where you can't create a pseudo-style directly, but you have to create a whole new style rule, etc.

@sylvain-galineau
Copy link
Contributor

Good idea. Added to the list!

@sylvain-galineau
Copy link
Contributor

Update!

I have added support for A through the Dropcap.options.runEvenIfInitialLetterExists property (defaults to true)

Regarding B:

  • As you point out, generating additional CSSOM rules is painful. Not so much creating additional rules but generating selectors is a bit awkward. One relatively easy way to support this would be to allow the caller to pass in a querySelector string instead of an HTMLElement or NodeList; when they do that we'd support preferNativeImplementation. It's not great but it's a start.
  • But once I do the above I'll run into a wrinkle with WebKit Nightlies: the spec has swapped the order of the parameters so I'd sometimes get the wrong result in WK using a valid value. I think I'll try to submit a patch for this, then maybe hack this into dropcap.js...

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

2 participants