OSDN Git Service

base.jsのupメソッドの仕様に関して、引数がなくても例外とならないように修正
authordhrname <sie-developers@lists.sourceforge.jp>
Fri, 24 Oct 2014 13:37:17 +0000 (22:37 +0900)
committerdhrname <sie-developers@lists.sourceforge.jp>
Fri, 24 Oct 2014 13:37:17 +0000 (22:37 +0900)
ChangeLog.txt
tool/Spec/spec/BaseJSSpec.js
tool/funcproto/base.js

index 74a82d7..0a33273 100644 (file)
@@ -1,4 +1,4 @@
-2014-10-21 version 17\r
+2014-10-21 version 17\r
 1, stylesheetモジュールとcssモジュールに、base.jsを適用\r
 2, onメソッドの例外処理を修正\r
 3,  base.jsについて、変数を整理して軽量化\r
index c4993df..0947947 100644 (file)
@@ -164,6 +164,9 @@ describe("base.js", function() {
       base("$c").up("$dd");\r
     }\r
     expect(base("$c").$dd.hoge).toEqual(12);\r
+    \r
+    /*引数を省略した場合、引数に文字列"$1"を入れたのと同じ効果が得られる*/\r
+    expect(base("$c").up()).toBe(base("$c").$1);\r
   });\r
 \r
   it("a mix method function", function() {\r
@@ -320,9 +323,6 @@ describe("base.js", function() {
       base();\r
     }).toThrow(message);\r
     expect(function(){\r
-      base("$error").up();\r
-    }).toThrow(message);\r
-    expect(function(){\r
       base("$error").mix();\r
     }).toThrow(message);\r
     expect(function(){\r
index 9bf9f8f..8532203 100644 (file)
@@ -17,14 +17,15 @@ var _base = {
        * 自身をプロトタイプとして、新たにオブジェクトを生成する\r
        */\r
       up: function(name) {\r
-        if (!name) {\r
-          throw new Error("No arguments error");\r
-        }\r
         var F = _base.F,\r
              s;\r
         F.prototype = this;\r
         s = new F();\r
-        this[name] = s;\r
+        if (name) {\r
+          this[name] = s;\r
+        } else {\r
+          this.$1 = s;\r
+        }\r
         F = void 0;\r
         return s;\r
       },\r