ブラウザでSVGを表示するSIEの開発 (SIE - to display SVG on legacy browsers)
| リビジョン | e3475e3588b1caf7cdcae1de1f729ac158a6382a (tree) |
|---|---|
| 日時 | 2015-11-03 23:01:40 |
| 作者 | dhrname <dhrname@user...> |
| コミッター | dhrname |
Support the inherit and the currentColor keyword
| @@ -785,17 +785,26 @@ base("$calcMode").up("$attribute").mix( { | ||
| 785 | 785 | /*$fromオブジェクトを作るためのひな形となるオブジェクト*/ |
| 786 | 786 | $from: base("$from").up(), |
| 787 | 787 | |
| 788 | + /*attributeName属性の値*/ | |
| 789 | + attrName: "", | |
| 790 | + | |
| 788 | 791 | /*指定した要素の属性値を取得するメソッド*/ |
| 789 | 792 | _getAttr: function(/*string*/ name, def) { |
| 790 | 793 | var nameSpace = null; |
| 791 | 794 | if (name.indexOf("xlink:") > -1) { |
| 792 | 795 | nameSpace = "http://www.w3.org/1999/xlink"; |
| 793 | 796 | } |
| 797 | + var s = this._ele.getAttributeNS(nameSpace, name); | |
| 798 | + if (this.element && (s === "inherit")) { | |
| 799 | + return this.element.ownerDocument.defaultView.getComputedStyle(this.element.parentNode, "").getPropertyValue(this.attrName); | |
| 800 | + } else if (this.element && (s === "currentColor")) { | |
| 801 | + return this.element.ownerDocument.defaultView.getComputedStyle(this._ele, "").getPropertyValue("color"); | |
| 802 | + } | |
| 794 | 803 | /*DOM Level2やIE11では、getAttributeNSメソッドは空文字を返す。他のブラウザではnullを返すことが多い |
| 795 | 804 | * |
| 796 | 805 | * >the empty string if that attribute does not have a specified or default value |
| 797 | 806 | * http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-ElGetAttrNS*/ |
| 798 | - return (this._ele.getAttributeNS(nameSpace, name) || def); | |
| 807 | + return (s || def); | |
| 799 | 808 | }, |
| 800 | 809 | |
| 801 | 810 | _ele: document.documentElement, |
| @@ -827,6 +836,7 @@ base("$calcMode").up("$attribute").mix( { | ||
| 827 | 836 | } |
| 828 | 837 | /*_getAttrメソッドで必要*/ |
| 829 | 838 | this._ele = ele; |
| 839 | + this.attrName = this._getAttr("attributeName", ""); | |
| 830 | 840 | /*eleの属性の値を、それぞれオブジェクトに割り当て*/ |
| 831 | 841 | var $frame = base("$frame"), |
| 832 | 842 | begin = $frame.$begin, |
| @@ -1019,9 +1029,6 @@ base("$calcMode").up("$attribute").mix( { | ||
| 1019 | 1029 | /*to属性の値、文字列*/ |
| 1020 | 1030 | to: "", |
| 1021 | 1031 | |
| 1022 | - /*attributeName属性の値*/ | |
| 1023 | - attrName: "", | |
| 1024 | - | |
| 1025 | 1032 | /*指定された属性の規定値*/ |
| 1026 | 1033 | defaultValue: "", |
| 1027 | 1034 |
| @@ -1072,7 +1079,6 @@ base("$calcMode").up("$attribute").mix( { | ||
| 1072 | 1079 | if (ele && ele.getAttributeNS) { |
| 1073 | 1080 | this._ele = ele; |
| 1074 | 1081 | this.to = this._getAttr("to", ""); |
| 1075 | - this.attrName = this._getAttr("attributeName", ""); | |
| 1076 | 1082 | this.fill = this._getAttr("fill", "remove"); |
| 1077 | 1083 | } |
| 1078 | 1084 | var thisele = this.element; |