From f00b23a9ec5f784c4262f16ad9e01e5ff9a2be85 Mon Sep 17 00:00:00 2001 From: Grom-S Date: Thu, 21 Nov 2013 20:37:40 +0200 Subject: [PATCH] incorect z-index sorting fixed If you omit compare function in javascript `sort()` method it will sort lexicographically (in dictionary order) according to the string conversion of each element. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters For example [0, 9, 8, 10].sort() will place element with z-index 10 on 2nd position of the array --- src/Renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renderer.js b/src/Renderer.js index 99afa23..8f8fd69 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -39,7 +39,7 @@ _html2canvas.Renderer = function(parseQueue, options){ })(parseQueue); function sortZ(context) { - Object.keys(context).sort().forEach(function(zi) { + Object.keys(context).sort(function(a, b) { return a - b; }).forEach(function(zi) { var nonPositioned = [], floated = [], positioned = [],