Loading lib/jsduck/ast.rb +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ module JsDuck elsif var && var["init"] && function?(var["init"]) make_method(to_s(var["id"]), var["init"]) # (function() {}) elsif exp && function?(exp) make_method(exp["id"] ? to_s(exp["id"]) : "", exp) # foo: function() {} elsif property?(ast) && function?(ast["value"]) make_method(key_value(ast["key"]), ast["value"]) Loading spec/ast_method_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ describe "JsDuck::Ast detects method with" do detect("/** */ var foo = Ext.emptyFn")[:name].should == "foo" end it "function expression with name" do detect("/** */ (function foo(){})")[:name].should == "foo" end it "object property initialized with function" do detect(<<-EOS)[:name].should == "foo" Foo = { Loading spec/ast_spec.rb +5 −1 Original line number Diff line number Diff line Loading @@ -78,10 +78,14 @@ describe JsDuck::Ast do detect("/** */ var foo = function() {}").should == :method end it "vari initialized with Ext.emptyFn" do it "var initialized with Ext.emptyFn" do detect("/** */ var foo = Ext.emptyFn").should == :method end it "anonymous function" do detect("/** */ (function(){})").should == :method end it "object property initialized with function" do detect(<<-EOS).should == :method Foo = { Loading Loading
lib/jsduck/ast.rb +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ module JsDuck elsif var && var["init"] && function?(var["init"]) make_method(to_s(var["id"]), var["init"]) # (function() {}) elsif exp && function?(exp) make_method(exp["id"] ? to_s(exp["id"]) : "", exp) # foo: function() {} elsif property?(ast) && function?(ast["value"]) make_method(key_value(ast["key"]), ast["value"]) Loading
spec/ast_method_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ describe "JsDuck::Ast detects method with" do detect("/** */ var foo = Ext.emptyFn")[:name].should == "foo" end it "function expression with name" do detect("/** */ (function foo(){})")[:name].should == "foo" end it "object property initialized with function" do detect(<<-EOS)[:name].should == "foo" Foo = { Loading
spec/ast_spec.rb +5 −1 Original line number Diff line number Diff line Loading @@ -78,10 +78,14 @@ describe JsDuck::Ast do detect("/** */ var foo = function() {}").should == :method end it "vari initialized with Ext.emptyFn" do it "var initialized with Ext.emptyFn" do detect("/** */ var foo = Ext.emptyFn").should == :method end it "anonymous function" do detect("/** */ (function(){})").should == :method end it "object property initialized with function" do detect(<<-EOS).should == :method Foo = { Loading