Browse Source

Setting onload

v1.x
Tj Holowaychuk 14 years ago
parent
commit
6b35fa523c
  1. 6
      src/Image.cc
  2. 1
      src/Image.h

6
src/Image.cc

@ -73,9 +73,11 @@ Image::SetSrc(Local<String>, Local<Value> val, const AccessorInfo &info) {
if (val->IsString()) {
String::AsciiValue src(val);
Image *img = ObjectWrap::Unwrap<Image>(info.This());
if (info.This()->Get(String::New("onload"))->IsFunction())
printf("function\n");
img->filename = *src;
Handle<Value> onload = info.This()->Get(String::New("onload"));
if (onload->IsFunction()) {
img->onload = Persistent<Function>::New(Handle<Function>::Cast(onload));
}
}
}

1
src/Image.h

@ -15,6 +15,7 @@ using namespace v8;
class Image: public node::ObjectWrap {
public:
char *filename;
Persistent<Function> onload;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> Inspect(const Arguments &args);

Loading…
Cancel
Save