From 1a50da5339944adaa81898ab789eadaf29b301f4 Mon Sep 17 00:00:00 2001 From: dhrname Date: Thu, 14 May 2015 22:20:27 +0900 Subject: [PATCH] Modify the init method --- org/w3c/dom/smil.js | 4 ++-- tool/Spec/spec/SvgDomSpec.js | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 50d5824..c6edb23 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -692,7 +692,7 @@ base("$calcMode").up("$attribute").mix( { /*引数で指定した要素 ele の属性を解析して、フレームに追加する*/ push: function(/*Element Node*/ ele) { - if (!ele) { + if (!ele || !ele.hasAttribute) { return null; } this.element = ele.parentNode || null; @@ -834,7 +834,7 @@ base("$calcMode").up("$attribute").mix( { init: function(ele) { this.push(ele); - if (ele) { + if (ele && ele.getAttributeNS) { this.to = ele.getAttributeNS(null, "to") || ""; this.attrName = ele.getAttributeNS(null, "attributeName") || ""; } diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index da09d37..f1f7766 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -3432,6 +3432,7 @@ describe("SMIL Animation Spec", function() { s.setAttributeNS(null, "from", "1"); attr.push(s); expect(timelines.length).toEqual(0); + expect(attr.push(12)).toBeNull(); } ); } ); describe("A setValues method", function() { @@ -3609,10 +3610,23 @@ describe("SMIL Animation Spec", function() { ele.parentNode.setAttributeNS(null, "tt1", "undef"); $set.init(ele); expect($set.defaultValue).toBe("undef"); + + ele.setAttributeNS(null, "attributeName", "font-size"); + ele.parentNode.style.setProperty("font-size", "12px"); + $set.init(ele); + expect($set.defaultValue).toBe("12px"); } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion on a spline mode )", function() { - } ); + $set.init(null); + expect($set.to).toBe(""); + expect($set.attrName).toBe(""); + expect($set.defaultValue).toBe(""); + + $set.init(12); + expect($set.to).toBe(""); + expect($set.attrName).toBe(""); + expect($set.defaultValue).toBe(""); } ); } ); } ); } ); -- 2.11.0