svnno****@sourc*****
svnno****@sourc*****
2010年 3月 2日 (火) 20:15:34 JST
Revision: 1689 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1689 Author: dhrname Date: 2010-03-02 20:15:33 +0900 (Tue, 02 Mar 2010) Log Message: ----------- nodeTypeの定数を設定 Modified Paths: -------------- branches/ufltima/core.js Modified: branches/ufltima/core.js =================================================================== --- branches/ufltima/core.js 2010-02-28 14:27:42 UTC (rev 1688) +++ branches/ufltima/core.js 2010-03-02 11:15:33 UTC (rev 1689) @@ -76,31 +76,6 @@ interface NodeList; interface NamedNodeMap; interface Element; - - exception DOMException { - unsigned short code; - }; - // ExceptionCode - const unsigned short INDEX_SIZE_ERR = 1; - const unsigned short DOMSTRING_SIZE_ERR = 2; - const unsigned short HIERARCHY_REQUEST_ERR = 3; - const unsigned short WRONG_DOCUMENT_ERR = 4; - const unsigned short INVALID_CHARACTER_ERR = 5; - const unsigned short NO_DATA_ALLOWED_ERR = 6; - const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; - const unsigned short NOT_FOUND_ERR = 8; - const unsigned short NOT_SUPPORTED_ERR = 9; - const unsigned short INUSE_ATTRIBUTE_ERR = 10; - // Introduced in DOM Level 2: - const unsigned short INVALID_STATE_ERR = 11; - // Introduced in DOM Level 2: - const unsigned short SYNTAX_ERR = 12; - // Introduced in DOM Level 2: - const unsigned short INVALID_MODIFICATION_ERR = 13; - // Introduced in DOM Level 2: - const unsigned short NAMESPACE_ERR = 14; - // Introduced in DOM Level 2: - const unsigned short INVALID_ACCESS_ERR = 15; */ function DOMException(n){ Error.apply(this, arguments); @@ -211,26 +186,26 @@ /* Node *ノード(節)はすべての雛形となる重要なものである。削除不可。 - * - // NodeType - const unsigned short ELEMENT_NODE = 1; - const unsigned short ATTRIBUTE_NODE = 2; - const unsigned short TEXT_NODE = 3; - const unsigned short CDATA_SECTION_NODE = 4; - const unsigned short ENTITY_REFERENCE_NODE = 5; - const unsigned short ENTITY_NODE = 6; - const unsigned short PROCESSING_INSTRUCTION_NODE = 7; - const unsigned short COMMENT_NODE = 8; - const unsigned short DOCUMENT_NODE = 9; - const unsigned short DOCUMENT_TYPE_NODE = 10; - const unsigned short DOCUMENT_FRAGMENT_NODE = 11; - const unsigned short NOTATION_NODE = 12; -*/ + */ + function Node(){ this.childNodes = []; this._capter = []; //eventで利用 return this; } +// NodeType +/*const unsigned short*/ Node.ELEMENT_NODE = 1; +/*const unsigned short*/ Node.ATTRIBUTE_NODE = 2; +/*const unsigned short*/ Node.TEXT_NODE = 3; +/*const unsigned short*/ Node.CDATA_SECTION_NODE = 4; +/*const unsigned short*/ Node.ENTITY_REFERENCE_NODE = 5; +/*const unsigned short*/ Node.ENTITY_NODE = 6; +/*const unsigned short*/ Node.PROCESSING_INSTRUCTION_NODE = 7; +/*const unsigned short*/ Node.COMMENT_NODE = 8; +/*const unsigned short*/ Node.DOCUMENT_NODE = 9; +/*const unsigned short*/ Node.DOCUMENT_TYPE_NODE = 10; +/*const unsigned short*/ Node.DOCUMENT_FRAGMENT_NODE = 11; +/*const unsigned short*/ Node.NOTATION_NODE = 12; Node.prototype = { //以下は初期値として設定 tar : null, @@ -327,12 +302,12 @@ /*Node*/ cloneNode : function( /*boolean*/ deep) { var s; switch (this.nodeType) { - case 1: + case Node.ELEMENT_NODE: s = new Element(); s.tagName = this.tagName; s.attributes._copyNode(this.attributes,false); //NamedNodeMapのコピーを行う break; - case 9: + case Node.DOCUMENT_NODE: s = new Document(); break; default: @@ -355,7 +330,7 @@ for (var i=tcn.length-1;i<0;--i) { var tcni = tcn[i], tcnip = tcni.nextSibling; if (tcnip) { //次ノードがnullではなく、かつ、 - if (tcni.nodeType === 3 && tcnip.nodeType === 3) { //現ノードがテキストノード、かつ、次ノードもテキストノードならば + if (tcni.nodeType === Node.TEXT_NODE && tcnip.nodeType === Node.TEXT_NODE) { //現ノードがテキストノード、かつ、次ノードもテキストノードならば tcni.appendData(tcnip.data); //次ノードの文字列データを、現ノード文字列の前に付け加える tcni.legnth = tcni.data.length; this.removeChild(tcnip); //次ノードを排除 @@ -529,7 +504,7 @@ */ function Attr() { Node.apply(this, arguments); - this.nodeType = 2; + this.nodeType = Node.ATTRIBUTE_NODE; return this; }; Attr.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -540,7 +515,7 @@ */ function Element() { Node.apply(this, arguments); - this.nodeType = 1; + this.nodeType = Node.ELEMENT_NODE; this.nodeValue = null; this.attributes = new NamedNodeMap(); //属性を収納 return this; @@ -653,7 +628,7 @@ */ function Text() { CharacterData.apply(this, arguments); - this.nodeType = 3; + this.nodeType = Node.TEXT_NODE; this.nodeName = "#text"; return this; }; @@ -678,7 +653,7 @@ *コメントノード。<!-- --!>で表現される。削除不可。 */ function Comment() { - this.nodeType = 8; + this.nodeType = Node.COMMENT_NODE; this.nodeName = "#comment"; return this; }; @@ -689,7 +664,7 @@ *CDATA領域を示すノード。<![CDATA[ ]]!>で表現される。削除不可。 */ function CDATASection() { - this.nodeType = 4; + this.nodeType = Node.CDATA_SECTION_NODE; this.nodeName = "#cdata-section"; return this; }; @@ -708,7 +683,7 @@ this.systemId = ""; //上同のシステム識別子 this.internalSubset = ""; //内部サブセットの内容(文字列) this.nodeValue = null; - this.nodeType = 10; + this.nodeType = Node.DOCUMENT_TYPE_NODE; return this; }; DocumentType.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -721,7 +696,7 @@ this.publicId = null; this.systemId = null; this.nodeValue = null; - this.nodeType = 12; + this.nodeType = Node.NOTATION_NODE; return this; }; Notation.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -738,7 +713,7 @@ this.systemId = null; this.notationName = null; //解析対象外実体のための記法名。解析対象実体ではnull this.nodeValue = null; - this.nodeType = 6; + this.nodeType = Node.ENTITY_NODE; return this; }; Entity.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -749,7 +724,7 @@ */ function EntityReference() { this.nodeValue = null; - this.nodeType = 5; + this.nodeType = Node.ENTITY_REFERENCE_NODE ; return this; }; EntityReference.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -759,7 +734,7 @@ *処理命令ノード。スタイルシート処理命令で使うので、削除不可 */ function ProcessingInstruction() { - this.nodeType = 7; + this.nodeType = Node.PROCESSING_INSTRUCTION_NODE; return this; }; ProcessingInstruction.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -771,7 +746,7 @@ function DocumentFragment() { this.nodeName = "#document-fragment"; this.nodeValue = null; - this.nodeType = 11; + this.nodeType = Node.DOCUMENT_FRAGMENT_NODE; return this; }; DocumentFragment.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承 @@ -783,7 +758,7 @@ function Document() { this.nodeName = "#document"; this.nodeValue = null; - this.nodeType = 9; + this.nodeType = Node.DOCUMENT_NODE; this._id = {}; //getElementByIdで使う return this; }; @@ -862,7 +837,7 @@ /*Node*/ Document.prototype.importNode = function( /*Node*/ importedNode, /*boolean*/ deep) { var s; switch (importedNode.nodeType) { - case 1: + case Node.ELEMENT_NODE: s = this.createElementNS(importedNode.namespaceURI, importedNode.nodeName); var attr = importedNode.attributes, att; for (var i=0,atli=attr.length;i<atli;i++) { //NamedNodeMapを検索する @@ -877,16 +852,16 @@ } } break; - case 2: //attribute_node + case Node.ATTRIBUTE_NODE: s = this.createAttributeNS(importedNode.namespaceURI, importedNode.nodeName); s.nodeValue = importedNode.nodeValue; break; - case 3: //text_node - case 8: //comment_node + case Node.TEXT_NODE: + case Node.COMMENT_NODE: s = importedNode.cloneNode(false); s.ownerDocument = this; break; - case 11: //document_fragment_node + case Node.DOCUMENT_FRAGMENT_NODE: //document_fragment_node break; default: throw (new DOMException(DOMException.NOT_SUPPORTED_ERR)); @@ -912,10 +887,8 @@ } if (namespaceURI) { var ti = this.implementation; - if (!!ti[namespaceURI]) { - if (!!ti[namespaceURI][localName]) { //もし、名前空間とローカル名によって、オブジェクトがあった場合 + if (!!ti[namespaceURI] && !!ti[namespaceURI][localName]) { //もし、名前空間とローカル名によって、オブジェクトがあった場合 ele = new (ti[namespaceURI][localName]); - } } else { ele = new Element(); }