Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Checking instanceof PixelArray

  • Loading branch information...
commit 09023539c499b1bb24600a1ab6661e06ee92224e 1 parent cdfca98
@tj tj authored
Showing with 7 additions and 6 deletions.
  1. +1 −2  lib/context2d.js
  2. +0 −2  src/CanvasGradient.cc
  3. +6 −2 src/ImageData.cc
View
3  lib/context2d.js
@@ -483,6 +483,5 @@ Context2d.prototype.createImageData = function(width, height){
height = width.height;
width = width.width;
}
- var arr = new PixelArray(width, height);
- return new ImageData(arr);
+ return new ImageData(new PixelArray(width, height));
};
View
2  src/CanvasGradient.cc
@@ -36,8 +36,6 @@ Handle<Value>
Gradient::New(const Arguments &args) {
HandleScope scope;
- // TODO: separate concerns / validate args
-
// Linear
if (4 == args.Length()) {
Gradient *grad = new Gradient(
View
8 src/ImageData.cc
@@ -36,8 +36,12 @@ ImageData::Initialize(Handle<Object> target) {
Handle<Value>
ImageData::New(const Arguments &args) {
HandleScope scope;
- // TODO: arg assertions
- PixelArray *arr = ObjectWrap::Unwrap<PixelArray>(args[0]->ToObject());
+ Local<Object> obj = args[0]->ToObject();
+
+ if (!PixelArray::constructor->HasInstance(obj))
+ return ThrowException(Exception::TypeError(String::New("CanvasPixelArray expected")));
+
+ PixelArray *arr = ObjectWrap::Unwrap<PixelArray>(obj);
ImageData *imageData = new ImageData(arr);
args.This()->Set(String::NewSymbol("data"), args[0]);
imageData->Wrap(args.This());
Please sign in to comment.
Something went wrong with that request. Please try again.