Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JavaScript parsing error in IE 10 and earlier #6396

Merged
merged 4 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Change Log
* Fixed glTF support to handle skinned meshes when no skin is supplied. [#6061](https://github.com/AnalyticalGraphicsInc/cesium/issues/6061)
* Allow loadWithXhr to work with string URLs in a web worker.
* Fix Firefox WebGL console warnings. [#5912](https://github.com/AnalyticalGraphicsInc/cesium/issues/5912)
* Fix parsing Cesium.js in older browsers that do not support all TypedArray types. [#6396](https://github.com/AnalyticalGraphicsInc/cesium/pull/6396)

##### Additions :tada:
* Improved `MapboxImageryProvider` performance by 300% via `tiles.mapbox.com` subdomain switching. [#6426](https://github.com/AnalyticalGraphicsInc/cesium/issues/6426)
Expand Down
17 changes: 16 additions & 1 deletion Source/Core/FeatureDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
defined,
Fullscreen) {
'use strict';
/*global CanvasPixelArray*/

var theNavigator;
if (typeof navigator !== 'undefined') {
Expand Down Expand Up @@ -196,6 +197,19 @@ define([
return supportsImageRenderingPixelated() ? imageRenderingValueResult : undefined;
}

var typedArrayTypes = [];
if (typeof ArrayBuffer !== 'undefined') {
typedArrayTypes.push(Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array);

if (typeof Uint8ClampedArray !== 'undefined') {
typedArrayTypes.push(Uint8ClampedArray);
}

if (typeof CanvasPixelArray !== 'undefined') {
typedArrayTypes.push(CanvasPixelArray);
}
}

/**
* A set of functions to detect whether the current browser supports
* various features.
Expand All @@ -219,7 +233,8 @@ define([
hardwareConcurrency : defaultValue(theNavigator.hardwareConcurrency, 3),
supportsPointerEvents : supportsPointerEvents,
supportsImageRenderingPixelated: supportsImageRenderingPixelated,
imageRenderingValue: imageRenderingValue
imageRenderingValue: imageRenderingValue,
typedArrayTypes: typedArrayTypes
};

/**
Expand Down
68 changes: 23 additions & 45 deletions Source/Core/arraySlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ define([
FeatureDetection) {
'use strict';

var slice = function(array, begin, end) {
/**
* Create a shallow copy of an array from begin to end.
*
* @param {Array} array The array to fill.
* @param {Number} [begin=0] The index to start at.
* @param {Number} [end=array.length] The index to end at which is not included.
*
* @returns {Array} The resulting array.
* @private
*/
function arraySlice(array, begin, end) {
//>>includeStart('debug', pragmas.debug);
Check.defined('array', array);
if (defined(begin)) {
Expand All @@ -20,54 +30,22 @@ define([
Check.typeOf.number('end', end);
}
//>>includeEnd('debug');
return array.slice(begin, end);
};

if (FeatureDetection.supportsTypedArrays()) {
var tempArray = new Uint8Array(1);
if (typeof tempArray.slice !== 'function') {
var typedArrayTypes = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];
slice = function(array, begin, end) {
//>>includeStart('debug', pragmas.debug);
Check.defined('array', array);
if (defined(begin)) {
Check.typeOf.number('begin', begin);
}
if (defined(end)) {
Check.typeOf.number('end', end);
}
//>>includeEnd('debug');

if (typeof array.slice === 'function') {
return array.slice(begin, end);
}

var copy = Array.prototype.slice.call(array, begin, end);
var length = typedArrayTypes.length;
for (var i = 0; i < length; ++i) {
if (array instanceof typedArrayTypes[i]) {
copy = new typedArrayTypes[i](copy);
break;
}
}
if (typeof array.slice === 'function') {
return array.slice(begin, end);
}

return copy;
};
var copy = Array.prototype.slice.call(array, begin, end);
var typedArrayTypes = FeatureDetection.typedArrayTypes;
var length = typedArrayTypes.length;
for (var i = 0; i < length; ++i) {
if (array instanceof typedArrayTypes[i]) {
copy = new typedArrayTypes[i](copy);
break;
}
}
}

/**
* Create a shallow copy of an array from begin to end.
*
* @param {Array} array The array to fill.
* @param {Number} [begin=0] The index to start at.
* @param {Number} [end=array.length] The index to end at which is not included.
*
* @returns {Array} The resulting array.
* @private
*/
function arraySlice(array, begin, end) {
return slice(array, begin, end);
return copy;
}

return arraySlice;
Expand Down
18 changes: 1 addition & 17 deletions Specs/equals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,9 @@ define([
], function(
FeatureDetection) {
'use strict';
/*global CanvasPixelArray*/

var typedArrayTypes = [];

// Earlier versions of IE do not support typed arrays
if (FeatureDetection.supportsTypedArrays()) {
typedArrayTypes.push(Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array);

if (typeof Uint8ClampedArray !== 'undefined') {
typedArrayTypes.push(Uint8ClampedArray);
}

if (typeof CanvasPixelArray !== 'undefined') {
typedArrayTypes.push(CanvasPixelArray);
}
}

function isTypedArray(o) {
return typedArrayTypes.some(function(type) {
return FeatureDetection.typedArrayTypes.some(function(type) {
return o instanceof type;
});
}
Expand Down