mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
Make primivive[].clone() work in older browsers and in Rhino
This commit is contained in:
parent
840b9dfe8b
commit
6817618b4e
|
@ -140,6 +140,15 @@ function $rt_arraycls(cls) {
|
|||
return str;
|
||||
};
|
||||
$rt_setCloneMethod(arraycls.prototype, function () {
|
||||
var dataCopy;
|
||||
if ('slice' in this.data) {
|
||||
dataCopy = this.data.slice();
|
||||
} else {
|
||||
dataCopy = new this.data.constructor(this.data.length);
|
||||
for (var i = 0; i < dataCopy.length; ++i) {
|
||||
dataCopy[i] = this.data[i];
|
||||
}
|
||||
}
|
||||
return new arraycls(this.data.slice());
|
||||
});
|
||||
var name = "[" + cls.$meta.binaryName;
|
||||
|
|
Loading…
Reference in New Issue
Block a user