mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
don't process pseudo elements for hidden elements; cleanup pseudo elements after render
This commit is contained in:
@ -212,10 +212,12 @@ _html2canvas.Preload = function( options ) {
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
var uid = 0, injectStyle;
|
||||
function injectPseudoElements(el) {
|
||||
if(!_html2canvas.Util.isElementVisible(el)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var before = getPseudoElement(el, ':before'),
|
||||
after = getPseudoElement(el, ':after');
|
||||
if(!before && !after) {
|
||||
@ -258,6 +260,17 @@ _html2canvas.Preload = function( options ) {
|
||||
}
|
||||
}
|
||||
|
||||
function cleanupPseudoElements(){
|
||||
if(!injectStyle) {
|
||||
return;
|
||||
}
|
||||
injectStyle.parentNode.removeChild(injectStyle);
|
||||
injectStyle = undefined;
|
||||
|
||||
[].slice.apply(element.all || element.getElementsByTagName('*'))
|
||||
.forEach(removePseudoElements);
|
||||
}
|
||||
|
||||
function getPseudoElement(el, which) {
|
||||
var elStyle = window.getComputedStyle(el, which);
|
||||
if(!elStyle || !elStyle.content) { return; }
|
||||
@ -380,19 +393,14 @@ _html2canvas.Preload = function( options ) {
|
||||
}
|
||||
}
|
||||
|
||||
if(injectStyle) {
|
||||
injectStyle.parentNode.removeChild(injectStyle);
|
||||
injectStyle = undefined;
|
||||
|
||||
[].slice.apply(element.all || element.getElementsByTagName('*'))
|
||||
.forEach(removePseudoElements);
|
||||
}
|
||||
cleanupPseudoElements();
|
||||
},
|
||||
|
||||
renderingDone: function() {
|
||||
if (timeoutTimer) {
|
||||
window.clearTimeout(timeoutTimer);
|
||||
}
|
||||
cleanupPseudoElements();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user