OSDN Git Service

Add an isCSS property to the object
authordhrname <dhrname@users.sourceforge.jp>
Wed, 13 Apr 2016 12:34:37 +0000 (21:34 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Wed, 13 Apr 2016 12:34:37 +0000 (21:34 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 3ffd06e..040685e 100644 (file)
@@ -814,19 +814,21 @@ base("$calcMode").up("$attribute").mix( {
   \r
   /*アニメーションするために、対象の属性やプロパティを変化させるメソッド*/\r
   setAttribute: function (value) {\r
-    if (!this.attrName) {\r
+    var attrName = this.attrName;\r
+    if (!attrName) {\r
       return;\r
     }\r
     var ele = this.element;\r
-    ele.setAttributeNS(this.attrNameSpace, this.attrName, value);\r
+    ele.setAttributeNS(this.attrNameSpace, attrName, value);\r
     /*スタイルシートのプロパティも上書きしておく*/\r
-    ele.style.setProperty(this.attrName, value, "");\r
+    this.isCSS && ele.style.setProperty(attrName, value, "");\r
     value = ele = void 0;\r
   },\r
   \r
   /*setAttributeメソッドとは逆の効果で、無効化させるメソッド*/\r
   removeAttribute: function () {\r
-    if (!this.attrName) {\r
+    var attrName = this.attrName;\r
+    if (!attrName) {\r
       return;\r
     }\r
     var ele = this.element;\r
@@ -835,9 +837,9 @@ base("$calcMode").up("$attribute").mix( {
     } else {\r
       /*初期段階でターゲットの要素に属性が指定されていない場合は、\r
        * 現在の属性値を削除するだけでよい*/\r
-      ele.removeAttributeNS(this.attrNameSpace, this.attrName);\r
+      ele.removeAttributeNS(this.attrNameSpace, attrName);\r
       /*スタイルシートのプロパティも削除しておく。removePropertyでないことに注意*/\r
-      this.isCSS && ele.style.setProperty(this.attrName, this.defaultValue, "");\r
+      this.isCSS && ele.style.setProperty(attrName, this.defaultValue, "");\r
     }\r
     value = ele = void 0;\r
   },\r
@@ -868,6 +870,10 @@ base("$calcMode").up("$attribute").mix( {
       */\r
       return null;\r
     }\r
+    \r
+    /*属性値の設定*/\r
+    this.attrName = this.getAttr("attributeName", "");\r
+    \r
     /*属性タイプの設定*/\r
     var attrType = this.getAttr("attributeType", "auto");\r
     var computedStyle = this.element && this.element.ownerDocument.defaultView.getComputedStyle(this.element, "");\r
@@ -875,11 +881,11 @@ base("$calcMode").up("$attribute").mix( {
       this.isCSS = true;\r
     } else if ((attrType === "auto") && this.element) {\r
       if ( computedStyle.getPropertyValue(this.attrName) ) {\r
-                 this.isCSS = true;\r
+        this.isCSS = true;\r
       }\r
     }\r
-    /*属性値の設定*/\r
-    this.attrName = this.getAttr("attributeName", "");\r
+    \r
+    /*xlink関連の属性のときは名前空間を変更しておく*/\r
     if (this.attrName.indexOf("xlink") > -1) {\r
       this.attrNameSpace = "http://www.w3.org/1999/xlink";\r
     }\r
index d101d80..ace16db 100644 (file)
@@ -1718,10 +1718,13 @@ describe("SMIL Animation Spec", function() {
         expect(attr.setAttribute()).toBeUndefined();\r
         expect(attr.setAttribute("block")).toBeUndefined();\r
         expect(p4.hasAttributeNS(null, "display")).toBeFalsy();\r
+        expect(attr.isCSS).toBeFalsy();\r
+        \r
         s.setAttributeNS(null, "attributeName", "display");\r
         attr.push(s);\r
         expect(attr.setAttribute("block")).toBeUndefined();\r
         expect(p4.hasAttributeNS(null, "display")).toBeTruthy();\r
+        expect(attr.isCSS).toBeTruthy();\r
         expect(p4.style.getPropertyValue("display")).toBe("block");\r
         \r
         p4 = document.createElementNS("http://www.w3.org/2000/svg", "g");\r