-
Notifications
You must be signed in to change notification settings - Fork 70
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
layoutDropcap: dcap.dcapjsStrut is not invalidated for dynamic content (ReactJS). #19
Comments
* ContentManager, server, env: Separated production and preview keys. * App, server, log: Added version logging. * BlogPage, LandingPage: Added estimated read time. * BlogPage, LandingPage: Only external links open in a new window. * Router: Switched next and previous posts. * BlogPage: Added styles for secondary headers. * BlogPage: Added H2 styling. * BlogPage, LandingPage: Added temporary workaround for dropcap issue adobe-webplatform/dropcap.js#19 * BlogPage: Updated dropcap styling. * readme, license, package: Updated readme and license. * package: Version bump.
My apologies for the delay and thank you for reporting this. I will try to fix this shortly. |
I am not really familiar with React and the exact scenario you are mentioning; but it does sound that, even though the dropcap element is still there, the |
Relevant code in question: https://github.com/adobe-webplatform/dropcap.js/blob/master/src/layout.js#L126-L140
Description:
The
.dcapjsStrut
property holding the cache of the strut<span>
of the designated dropcap element (dcap
in the code) is not invalidated in anyway on subsequent reruns of.layoutDropcap
.The outdated cache is a problem for reconciliation-based frameworks such as ReactJS. When new content is loaded into an application using dropcap.js, the dropcap's content and children are replaced, but the element itself stays the same. The lack of an actual strut
<span>
leads to expected bugs:Here's the expected behaviour:
Workaround:
The current workaround is to set
.dcapjsStrut
of any dropcap elements tonull
before runningDropcap.layout()
.Solution:
One solution would be to give a class to the strut
<span>
, and query the dropcap element for that instead of saving it as an attribute of the element. The class would be something like._dropcap-strut
and could even be a configurable option.If that solution works, I'll gladly go ahead and make a PR for it!
The text was updated successfully, but these errors were encountered: