Revision ed3d553d

View differences:

src/v8_typed_array.cc
88 88

  
89 89
  static v8::Handle<v8::Value> V8New(const v8::Arguments& args) {
90 90
    if (!args.IsConstructCall())
91
      return ThrowTypeError("Constructor cannot be called as a function.");
91
      return node::FromConstructorTemplate(GetTemplate(), args);
92 92

  
93 93
    // To match Chrome, we allow "new ArrayBuffer()".
94 94
    // if (args.Length() != 1)
......
241 241
 private:
242 242
  static v8::Handle<v8::Value> V8New(const v8::Arguments& args) {
243 243
    if (!args.IsConstructCall())
244
      return ThrowTypeError("Constructor cannot be called as a function.");
244
      return node::FromConstructorTemplate(GetTemplate(), args);
245 245

  
246 246
    // To match Chrome, we allow "new Float32Array()".
247 247
    // if (args.Length() != 1)
......
613 613
 private:
614 614
  static v8::Handle<v8::Value> V8New(const v8::Arguments& args) {
615 615
    if (!args.IsConstructCall())
616
      return ThrowTypeError("Constructor cannot be called as a function.");
616
      return node::FromConstructorTemplate(GetTemplate(), args);
617 617

  
618 618
    if (args.Length() < 1)
619 619
      return ThrowError("Wrong number of arguments.");
test/simple/test-typed-arrays.js
50 50
  obj = new DataView(obj.buffer || obj);
51 51
  assert.equal(obj.toString(), '[object DataView]');
52 52
  assert.equal(Object.prototype.toString.call(obj), '[object DataView]');
53

  
54
  // Calling constructor as function should work.
55
  clazz(32);
53 56
});
54 57

  
58
// Calling constructor as function should work.
59
DataView(ArrayBuffer(32));
60

  
55 61
var buffer = new ArrayBuffer(16);
56 62
var uint8 = new Uint8Array(buffer);
57 63
var uint16 = new Uint16Array(buffer);

Also available in: Unified diff