|
35 | 35 | Blob.prototype.webkitSlice || |
36 | 36 | Blob.prototype.mozSlice) |
37 | 37 |
|
| 38 | + loadImage.bufferSlice = |
| 39 | + loadImage.global.ArrayBuffer.prototype.slice || |
| 40 | + function (begin, end) { |
| 41 | + // Polyfill for IE10, which does not support ArrayBuffer.slice |
| 42 | + // eslint-disable-next-line no-param-reassign |
| 43 | + end = end || this.byteLength - begin |
| 44 | + var arr1 = new Uint8Array(this, begin, end) |
| 45 | + var arr2 = new Uint8Array(end) |
| 46 | + arr2.set(arr1) |
| 47 | + return arr2.buffer |
| 48 | + } |
| 49 | + |
38 | 50 | loadImage.metaDataParsers = { |
39 | 51 | jpeg: { |
40 | 52 | 0xffe1: [], // APP1 marker |
|
89 | 101 | var markerLength |
90 | 102 | var parsers |
91 | 103 | var i |
92 | | - var arr1 |
93 | | - var arr2 |
94 | 104 | // Check for the JPEG marker (0xffd8): |
95 | 105 | if (dataView.getUint16(0) === 0xffd8) { |
96 | 106 | while (offset < maxOffset) { |
|
136 | 146 | // Meta length must be longer than JPEG marker (2) |
137 | 147 | // plus APPn marker (2), followed by length bytes (2): |
138 | 148 | if (!options.disableImageHead && headLength > 6) { |
139 | | - if (buffer.slice) { |
140 | | - data.imageHead = buffer.slice(0, headLength) |
141 | | - } else { |
142 | | - // Workaround for IE10, which does not support |
143 | | - // ArrayBuffer.slice: |
144 | | - arr1 = new Uint8Array(buffer, 0, headLength) |
145 | | - arr2 = new Uint8Array(headLength) |
146 | | - arr2.set(arr1) |
147 | | - data.imageHead = arr2.buffer |
148 | | - } |
| 149 | + data.imageHead = loadImage.bufferSlice.call(buffer, 0, headLength) |
149 | 150 | } |
150 | 151 | } else { |
151 | 152 | // eslint-disable-next-line no-console |
|
0 commit comments