Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix ArrayBuffer cloning (util.clone) #59

Merged
merged 1 commit into from

2 participants

@bpl
bpl commented

Util.clone wasn't able to clone an ArrayBuffer. Firstly, it referenced non-existent variable source when it seems that arg was actually meant. Secondly, DataView methods setUint8 and getUint8 were wrongly capitalized.

This should also fix issue #55.

@bpl bpl Fix ArrayBuffer cloning (util.clone)
Util.clone wasn't able to clone an ArrayBuffer. Firstly, it referenced
non-existent variable "source" when it seems that "arg" was actually meant.
Secondly, DataView methods setUint8 and getUint8 were wrongly capitalized.

The third change (target.byteLength -> arg.byteLength) is just for
consistency.
94cad4d
@benvanik benvanik merged commit 209ca93 into benvanik:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 7, 2011
  1. @bpl

    Fix ArrayBuffer cloning (util.clone)

    bpl authored
    Util.clone wasn't able to clone an ArrayBuffer. Firstly, it referenced
    non-existent variable "source" when it seems that "arg" was actually meant.
    Secondly, DataView methods setUint8 and getUint8 were wrongly capitalized.
    
    The third change (target.byteLength -> arg.byteLength) is just for
    consistency.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 core/shared/Utilities.js
View
8 core/shared/Utilities.js
@@ -224,10 +224,10 @@ function scrollIntoViewIfNeeded(el) {
} else if (arg instanceof ArrayBuffer) {
// There may be a better way to do this, but I don't know it
var target = new ArrayBuffer(arg.byteLength);
- var sourceView = new DataView(arg, 0, source.byteLength);
- var targetView = new DataView(target, 0, target.byteLength);
- for (var n = 0; n < source.byteLength; n++) {
- targetView.setUInt8(n, sourceView.getUInt8(n));
+ var sourceView = new DataView(arg, 0, arg.byteLength);
+ var targetView = new DataView(target, 0, arg.byteLength);
+ for (var n = 0; n < arg.byteLength; n++) {
+ targetView.setUint8(n, sourceView.getUint8(n));
}
return target;
} else if (util.isTypedArray(arg)) {
Something went wrong with that request. Please try again.