svnno****@sourc*****
svnno****@sourc*****
2009年 9月 16日 (水) 18:04:37 JST
Revision: 1253 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1253 Author: dhrname Date: 2009-09-16 18:04:37 +0900 (Wed, 16 Sep 2009) Log Message: ----------- setAttributeNSをcoreエンジンへ実装 Modified Paths: -------------- branches/DOM/org/w3c/core.js Modified: branches/DOM/org/w3c/core.js =================================================================== --- branches/DOM/org/w3c/core.js 2009-09-16 08:55:35 UTC (rev 1252) +++ branches/DOM/org/w3c/core.js 2009-09-16 09:04:37 UTC (rev 1253) @@ -592,25 +592,62 @@ localName = qualifiedName; } - var n = this.getAttributeNodeNS(namespaceURI, localName); //属性ノードを取得する - if (n) { //該当する属性ノードがあれば、 + var n = this.getAttributeNodeNS(namespaceURI, localName); //属性ノードを取得する + if (n) { //該当する属性ノードがあれば、 n.nodeValue = value; n.value = value; /*注意 *ここで接頭語(属性ノードのprefix)も、qualifiedNameの接頭語にあわせて書き換えられるべきであるが、軽量化のため、省略する */ } else { - var atn = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); //属性ノードを作る + var atn = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); atn.nodeValue = value; atn.value = value; this.setAttributeNodeNS(atn); atn.ownerElement = this; - if (qualifiedName == "id" && !namespaceURI) { //id属性であったならば - this.ownerDocument._id[value] = this; //ドキュメントに登録しておく + if (qualifiedName === "id" && !namespaceURI) { //id属性であったならば + this.ownerDocument._id[value] = this; //ドキュメントに登録しておく } this.ownerDocument._arr[this.ownerDocument._arr.length] = this; } localName = null; + try{ //以下でfill,storke要素のリセットが必要 + if (this instanceof STGroupElement) { //g要素ならば + this.paint = NAIBU.PaintColor.prototype.cache[this.tar.uniqueID]; + name = name.replace(/fill-/, "fill").replace(/stroke-/, "stroke"); + if (this.paint.defaults[name] !== void 0) { //スタイルで定義されていれば + this.paint[name] = value; + } + } else { + var tgebtfill = this.tar.getElementsByTagName("fill"), tgebtstroke = this.tar.getElementsByTagName("stroke"); + if (tgebtfill.length > 0) { + this.tar.removeChild(tgebtfill[0]); + } + if (tgebtstroke.length > 0) { + this.tar.removeChild(tgebtstroke[0]); + } + name = name.replace(/fill-/, "fill").replace(/stroke-/, "stroke"); + if (this.paint.defaults[name] !== void 0) { + this.paint[name] = value; + this.paint.set(this.w, this.h, this.transformable); + } + } + if (name === "transform") { + var tar = {getAttribute : (function(n){return value})}; + this.transformable = NAIBU.transformToCTM(tar, this.partransformable); + tar = null; + this.set(this.w, this.h); + } + var tn = this[name]; + if (tn !== void 0) { //属性が定義されていれば + if (typeof tn === "string"){//文字列の場合 + this[tn] = value; + } else if (tn instanceof STLength) { //長さの場合 + this[tn].newValueSpecifiedUnits(this[tn].uniType, parseFloat(value)); + } + this.set(this.w, this.h); + } + }catch(e){} }; /*void*/ Element.prototype.removeAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) { };