paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

IE10 and others: DataView missing prototypes and getters #385

Open Xotic750 opened 8 years ago

Xotic750 commented 8 years ago

IE10's DataView does not appear to be ES6 compliant. It's listed as being compatible on MDN. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset

try {
    console.log(DataView.prototype.buffer);
} catch (e) {
    console.log(e);
}
try {
    console.log(DataView.prototype.byteLength);
} catch (e) {
    console.log(e);
}
try {
    console.log(DataView.prototype.byteOffset);
} catch (e) {
    console.log(e);
}
var a = Object.getPrototypeOf(new DataView(new ArrayBuffer(4)));
console.log(a);
var x = Object.getOwnPropertyDescriptor(a, 'byteLength').get;
console.log(x);
console.log(x.call(new DataView(new ArrayBuffer(4))));

http://jsfiddle.net/Xotic750/08zng894/3/

Xotic750 commented 8 years ago

Opera 12.16, also listed in MDN, also seems to have similar problems. Safari 5.1, listed in MDN, also seems the same. Chrome 26, similar. FireFox 15, also.

ljharb commented 8 years ago

Currently the es6-shim doesn't attempt to detect, patch, or implement anything relating to Typed Arrays, including ArrayBuffer and DataView.

Xotic750 commented 8 years ago

Hopefully some day though, huh?

ljharb commented 8 years ago

Possibly never - their sole use case is for performance, and you can't get that performance without native support.

Xotic750 commented 8 years ago

Hmm. This forces me to rethink my isArrayBuffer/isDataView routines. I changed them to to detect ES6 Arraybuffers (which they do just fine), and if es6-shim can't or has no plan on fixing such issues with these legacy implementations then I'm back to the "when is an ArrayBuffer not" dilemma. :/

I can't think of a simple way to fix the deficiencies anyhow.