We should use feature detection. Thanks @brendandahl
This commit is contained in:
parent
d70e6ab40c
commit
a30199527e
@ -10,10 +10,10 @@
|
|||||||
if (typeof Uint8Array.prototype.subarray === 'undefined') {
|
if (typeof Uint8Array.prototype.subarray === 'undefined') {
|
||||||
Uint8Array.prototype.subarray = function subarray(start, end) {
|
Uint8Array.prototype.subarray = function subarray(start, end) {
|
||||||
return new Uint8Array(this.slice(start, end));
|
return new Uint8Array(this.slice(start, end));
|
||||||
}
|
};
|
||||||
Float32Array.prototype.subarray = function subarray(start, end) {
|
Float32Array.prototype.subarray = function subarray(start, end) {
|
||||||
return new Float32Array(this.slice(start, end));
|
return new Float32Array(this.slice(start, end));
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// some mobile version might not support Float64Array
|
// some mobile version might not support Float64Array
|
||||||
@ -79,9 +79,17 @@
|
|||||||
|
|
||||||
// Object.defineProperty() ?
|
// Object.defineProperty() ?
|
||||||
(function checkObjectDefinePropertyCompatibility() {
|
(function checkObjectDefinePropertyCompatibility() {
|
||||||
// safari 5 and 6 cannot use this on DOM objects and thus it's unusable,
|
if (typeof Object.defineProperty !== 'undefined') {
|
||||||
if ((typeof Object.defineProperty !== 'undefined') &&
|
// some browsers (e.g. safari) cannot use defineProperty() on DOM objects
|
||||||
!/Safari/.test(navigator.userAgent)) return;
|
// and thus the native version is not sufficient
|
||||||
|
var definePropertyPossible = true;
|
||||||
|
try {
|
||||||
|
Object.defineProperty(new Image(), 'id', { value: 'test' });
|
||||||
|
} catch (e) {
|
||||||
|
definePropertyPossible = false;
|
||||||
|
}
|
||||||
|
if (definePropertyPossible) return;
|
||||||
|
}
|
||||||
|
|
||||||
Object.defineProperty = function objectDefineProperty(obj, name, def) {
|
Object.defineProperty = function objectDefineProperty(obj, name, def) {
|
||||||
delete obj[name];
|
delete obj[name];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user