diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-03-02 19:24:12 -0600 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-03-06 12:54:46 -0600 |
commit | c4801e2a16277c619a2b6fac36537e0f38a52abf (patch) | |
tree | 85e687482080a8d12299484de41196e182b4fe1b /app/assets/javascripts/behaviors | |
parent | 02ce31339366689084c3544e1fa78623a90b99de (diff) | |
download | gitlab-ce-c4801e2a16277c619a2b6fac36537e0f38a52abf.tar.gz |
Fix up off index when reading canvas and something failed
Diffstat (limited to 'app/assets/javascripts/behaviors')
-rw-r--r-- | app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js b/app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js index f6798c6cee1..f31716d4c07 100644 --- a/app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js +++ b/app/assets/javascripts/behaviors/gl_emoji/unicode_support_map.js @@ -74,6 +74,7 @@ function testUnicodeSupportMap(testMap) { .reduce((list, testKey) => list.concat(testMap[testKey]), []).length; const canvas = document.createElement('canvas'); + (window.gl || window).testEmojiUnicodeSupportMapCanvas = canvas; const ctx = canvas.getContext('2d'); canvas.width = (2 * fontSize); canvas.height = (numTestEntries * fontSize); @@ -95,7 +96,9 @@ function testUnicodeSupportMap(testMap) { let readIndex = 0; testMapKeys.forEach((testKey) => { const testEntry = testMap[testKey]; - const isTestSatisfied = [].concat(testEntry).every(() => { + // This needs to be a `reduce` instead of `every` because we need to + // keep the `readIndex` in sync from the writes by running all entries + const isTestSatisfied = [].concat(testEntry).reduce((isSatisfied) => { // Sample along the vertical-middle for a couple of characters const imageData = ctx.getImageData( 0, @@ -121,8 +124,8 @@ function testUnicodeSupportMap(testMap) { } readIndex += 1; - return isValidEmoji; - }); + return isSatisfied && isValidEmoji; + }, true); resultMap[testKey] = isTestSatisfied; }); |