From 02ab96dc5f6f256b23f91bf9b534f6cd43ceea8f Mon Sep 17 00:00:00 2001 From: arrix Date: Tue, 6 Aug 2013 10:34:13 +0800 Subject: [PATCH] passes z-index8 non-positioned element with opactiy < 1 The MDN article Understanding_z_index/Stacking_and_float is wrong about this --- src/Parse.js | 1 + src/Renderer.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Parse.js b/src/Parse.js index 5ad7b1d..488b38e 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -331,6 +331,7 @@ _html2canvas.Parse = function (images, options) { stack.zIndex = newContext = h2czContext(zIndex); newContext.isPositioned = isPositioned; newContext.isFloated = isFloated; + newContext.opacity = opacity; if (zIndex !== 'auto' || opacity < 1) { newContext.ownStacking = true; diff --git a/src/Renderer.js b/src/Renderer.js index 1d039c9..d516229 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -48,10 +48,12 @@ _html2canvas.Renderer = function(parseQueue, options){ // positioned after static context[zi].forEach(function(v) { - if (v.node.zIndex.isFloated) { - floated.push(v); - } else if (v.node.zIndex.isPositioned) { + if (v.node.zIndex.isPositioned || v.node.zIndex.opacity < 1) { + // http://www.w3.org/TR/css3-color/#transparency + // non-positioned element with opactiy < 1 should be stacked as if it were a positioned element with ‘z-index: 0’ and ‘opacity: 1’. positioned.push(v); + } else if (v.node.zIndex.isFloated) { + floated.push(v); } else { nonPositioned.push(v); }