mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
8bea01b81d
Previously, pseudo elements would be processed as they were found in the DOM tree, which was an expensive operation as each element's computed :before and :after style was checked for 'content' styles. This commit traverses the user's stylesheets for :before and :after selectors, gathers the classes affected, selects all elements that likely have a pseudo element present, then checks computed style. If there is actually an element present, it is created but *not* appended to the DOM until after all elements have been processed. After all elements have been found and created, they are added to the DOM in a single batch, and the original pseudo elements are hidden in a single batch. This prevents the layout invalidation / relayout loop that was occuring previously, and in my tests speeds parsing by as much as 50% or more, depending on how many pseudo elements your page uses. Additionally, this commit contains a bugfix to the handling of ":before" pseudo elements; the browser effectively inserts them as the first child of the element, not before the element. This fixes a few rendering inconsistencies and complicated pages look almost perfect in my tests. |
||
---|---|---|
.. | ||
html2canvas.js | ||
html2canvas.min.js |