From 21440a46edd4c5d91e75e7dddbd2cba5b271bde3 Mon Sep 17 00:00:00 2001 From: dhrname Date: Sat, 24 Sep 2016 22:43:50 +0900 Subject: [PATCH] Add the initTargetElement method to the --- org/w3c/dom/smil.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 863debf..3ea62d2 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -837,6 +837,23 @@ base("$calcMode").up("$attribute").mix( { this.__cacheAttr = ""; value = attrName = ele = void 0; }, + + /*アニメーションの対象となる要素を値として返すメソッド + * もっぱら、pushメソッドで使われる*/ + initTargetElement: function(ele) { + var s = ele.parentNode || null; + console.log(s, ele.parentNode); + var id = ele.getAttributeNS(null, "targetElement"); + if (id) { + return ele.ownerDocument.getElementById(id); + } + /*getAttributeNSメソッドでうまくいかなかったため、NSなしで代用*/ + if ( id = ele.getAttribute("xlink:href") ) { + return ele.ownerDocument.getElementById(id.slice(1)); + } + ele = id = void 0; + return s; + }, /*引数で指定した要素 ele の属性を解析して、フレームに追加する*/ push: function(/*Element Node*/ ele) { @@ -845,17 +862,8 @@ base("$calcMode").up("$attribute").mix( { } /*キャッシュを初期化しておく*/ this.__cacheAttr = ""; - this.element = ele.parentNode || null; - var id; - if ( id = ele.getAttributeNS(null, "targetElement") ) { - this.element = ele.ownerDocument.getElementById(id); - } - /*getAttributeNSメソッドでうまくいかなかったため、NSなしで代用*/ - if ( id = ele.getAttribute("xlink:href") ) { - this.element = ele.ownerDocument.getElementById(id.slice(1)); - } /*getAttrメソッドとhasAttrValuesメソッドで必要*/ - this._ele = ele; + this.ele = ele; if (!this.hasAttrValues()) { /*from属性、to、by、values属性が指定されていない場合、アニメーションの効果が出ないように調整する *SMILアニメーションの仕様を参照 @@ -867,6 +875,9 @@ base("$calcMode").up("$attribute").mix( { return null; } + /*initTargetElementメソッドを使って、elementプロパティの初期化*/ + this.element = this.initTargetElement(ele); + /*属性値の設定*/ this.attrName = this.getAttr("attributeName", ""); var attrName = this.attrName; @@ -945,7 +956,7 @@ base("$calcMode").up("$attribute").mix( { } /*setFrameメソッドを使ったときの、再帰スタックの使いすぎを防ぐため*/ frame.timelines = []; - begin = ele = id = void 0; + begin = ele = void 0; return frame; }, @@ -1768,7 +1779,6 @@ base("$calcMode").up("$attribute").mix( { this.rotate = this.getAttr("rotate", "0"); this.path = this.path.cloneNode(true); var mpath = ele.getElementsByTagNameNS(this.path.namespaceURI, "mpath"); - var list = this.element.__transformList; /*$animateは後で、プロパティを書き換えるために使う。tocallメソッドも参照*/ var $animate = this.$animateElement; if (mpath.length) { -- 2.11.0