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

Regression in :before pseudo element rendering (when async: true) #361

Closed
usmonster opened this issue Mar 26, 2014 · 6 comments
Closed

Regression in :before pseudo element rendering (when async: true) #361

usmonster opened this issue Mar 26, 2014 · 6 comments

Comments

@usmonster
Copy link
Contributor

When setting async: true, certain :before content specified in the CSS does not appear on the rendered canvas. This issue seems to have been introduced in #270 (e115180 specifically), though I haven't yet thoroughly read through the commit to identify the root cause.

I first noticed this when trying to capture the main, not-logged-in page of http://www.github.com . The 4 circles below "Why you’ll love GitHub" are blank when using the version cited and later, but content does appear when using older versions. (Unrelated issue that the content itself is not correct.. possibly related to #226 and/or fonts/proxies?)

If it helps, the CSS responsible for the content is of this form:

.octicon-organization:before {
    content: '\f037';
}

I haven't had time to test whether this issue also affects :after content, or whether the fact that the content is escaped has anything to do with it, but it's a definite regression in any case.

Thanks for a great tool, and keep up the amazing work!

@usmonster usmonster changed the title Regression in :before pseudo element rendering Regression in :before pseudo element rendering (when async: true) Mar 26, 2014
@STRML
Copy link

STRML commented Aug 26, 2014

@usmonster I wrote #270 under another account; here's the issue as I see it:

The PR contained a few loops that ran through all css (via document.styleSheets) and turned pseudo elements into actual elements. It did so by detecting their presence, cloning the class, and creating an actual DOM node before or after the affected node.

The issue is that the content rule has no effect on regular nodes, so content is not rendered.
A fix would simply read that content rule while creating the pseudo-pseudo elements in the DOM in order to fill it with actual content.

@niklasvh
Copy link
Owner

The whole lib has been rewritten (merged into master yesterday), and one of the many changes it introduced was async parsing (in a secondary hidden contentWindow).

Any old code, including this PR has been replaced.

@STRML
Copy link

STRML commented Aug 26, 2014

@niklasvh Great news! How is the speed on the new release compared to the old async?

@niklasvh
Copy link
Owner

Hasn't been benchmarked yet, still some issues (#421) to be resolved. It won't need to be thread blocking though, so DOM can change while the parsing/rendering is occuring.

@usmonster
Copy link
Contributor Author

Awesome! So it's always async by default, then? Good stuff. :]

@niklasvh
Copy link
Owner

The rendering is currently async by default, the parsing still needs to be implemented.

For reference:
https://github.com/niklasvh/html2canvas/blob/master/src/core.js#L10
https://github.com/niklasvh/html2canvas/blob/master/src/nodeparser.js#L29-L39

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

3 participants