]> khamidou — GitHub mirrors - electron.git/commitdiff
Make BrowserWindow options argument optional
authorEran Tiktin <eran.t@mce-sys.com>
Sat, 21 Nov 2015 04:22:19 +0000 (06:22 +0200)
committerEran Tiktin <eran.t@mce-sys.com>
Sat, 21 Nov 2015 04:22:19 +0000 (06:22 +0200)
Resolves #3473

atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h

index 7f5b78a79780e7d8819b17493e3443a33e63a16c..a5aa4a12668755240faf202144e7e20ed0c9fbf5 100644 (file)
@@ -261,13 +261,23 @@ void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
 #endif
 
 // static
-mate::Wrappable* Window::New(v8::Isolate* isolate,
-                             const mate::Dictionary& options) {
+mate::Wrappable* Window::New(v8::Isolate* isolate, mate::Arguments* args) {
   if (!Browser::Get()->is_ready()) {
     isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
         isolate, "Cannot create BrowserWindow before app is ready")));
     return nullptr;
   }
+
+  if (args->Length() > 1) {
+    args->ThrowError();
+    return nullptr;
+  }
+
+  mate::Dictionary options;
+  if (!(args->Length() == 1 && args->GetNext(&options))) {
+    options = mate::Dictionary::CreateEmpty(isolate);
+  }
+
   return new Window(isolate, options);
 }
 
index 4161584206a7e6a2f01412236084668006bf94a6..757abd205b31701b16a7235110a2aef9f9b3d906 100644 (file)
@@ -38,8 +38,7 @@ class WebContents;
 class Window : public mate::TrackableObject<Window>,
                public NativeWindowObserver {
  public:
-  static mate::Wrappable* New(v8::Isolate* isolate,
-                              const mate::Dictionary& options);
+  static mate::Wrappable* New(v8::Isolate* isolate, mate::Arguments* args);
 
   static void BuildPrototype(v8::Isolate* isolate,
                              v8::Local<v8::ObjectTemplate> prototype);