From b9fd524566d1479f6ab22f4dc1844737a405baa5 Mon Sep 17 00:00:00 2001 From: dhrname Date: Sat, 24 Sep 2016 23:24:00 +0900 Subject: [PATCH] Modify the initTargetElement method --- org/w3c/dom/smil.js | 21 ++++++++++++--------- tool/Spec/spec/SvgDomSpec.js | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index a6fd106..188f4a9 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -783,7 +783,7 @@ base("$calcMode").up("$attribute").mix( { /*指定された要素にvalues属性が付いているかどうかのチェックできるメソッド*/ hasAttrValues: function () { - var ele = this._ele; + var ele = this.ele; if (!ele) { return false; } else { @@ -802,11 +802,11 @@ base("$calcMode").up("$attribute").mix( { if (!attrName) { return; } - if (this.__cacheAttr === value) { + if (this.cacheAttr === value) { /*同じ値であれば、再設定しない*/ return; } else { - this.__cacheAttr = value; + this.cacheAttr = value; } var ele = this.element; if (this.isCSS) { @@ -840,7 +840,8 @@ base("$calcMode").up("$attribute").mix( { /*アニメーションの対象となる要素を値として返すメソッド * もっぱら、pushメソッドで使われる*/ - initTargetElement: function(ele) { + initTargetElement: function() { + var ele = this.ele; var s = ele.parentNode || null; var id = ele.getAttribute("xlink:href"); /*getAttributeNSメソッドでうまくいかなかったため、NSなしで代用*/ @@ -850,7 +851,7 @@ base("$calcMode").up("$attribute").mix( { if ( id = ele.getAttributeNS(null, "targetElement") ) { return ele.ownerDocument.getElementById(id); } - ele = id = void 0; + id = void 0; return s; }, @@ -862,11 +863,13 @@ base("$calcMode").up("$attribute").mix( { /*キャッシュを初期化しておく*/ this.cacheAttr = ""; - /*initTargetElementメソッドを使って、elementプロパティの初期化*/ - this.element = this.initTargetElement(ele); - + /*getAttrメソッドとhasAttrValuesメソッドで必要*/ this.ele = ele; + + /*initTargetElementメソッドを使って、elementプロパティの初期化*/ + this.element = this.initTargetElement(); + if (!this.hasAttrValues()) { /*from属性、to、by、values属性が指定されていない場合、アニメーションの効果が出ないように調整する *SMILアニメーションの仕様を参照 @@ -902,7 +905,7 @@ base("$calcMode").up("$attribute").mix( { var thisele = this.element; if (thisele) { /*規定値を設定しておく。属性を初期化するときに使われる*/ - this._ele = thisele; + this.ele = thisele; this.isDefault = thisele.hasAttributeNS(this.attrNameSpace, attrName); this.defaultValue = this.getAttr(attrName, computedStyle.getPropertyValue(attrName) ); diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index 7347d87..ed13e64 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -1731,7 +1731,7 @@ describe("SMIL Animation Spec", function() { attr.push(s); var timelines = base("$frame").timelines; expect(timelines.length).toBe(0); - s.setAttributeNS(null, "from", "1"); + s.setAttributeNS(null, "from", "0"); attr.push(s); expect(timelines.length).toBe(1); expect(attr.push(12)).toBeNull(); -- 2.11.0