Changeset 21068
- Timestamp:
- 10/10/08 08:36:03 (3 months ago)
- Location:
- lang/cplusplus/llv8call/trunk
- Files:
-
- 3 modified
-
ext/libxml/document.cc (modified) (2 diffs)
-
t/070_libxml/02_dom.js (modified) (2 diffs)
-
t/070_libxml/03_parser.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/llv8call/trunk/ext/libxml/document.cc
r21003 r21068 175 175 xmlFree(result); 176 176 return str; 177 END 178 179 FUNCTION(getElementById) 180 ARG_COUNT(1); 181 ARG_str(id, 0); 182 EXTERNAL_DOC(); 183 xmlAttrPtr attr = xmlGetID(doc, (const xmlChar*)*id); 184 if (!attr) { 185 return Undefined(); 186 } else if (attr->type == XML_ATTRIBUTE_NODE) { 187 return CREATE_ATTR(doc, attr->parent); 188 } else if (attr->type == XML_ELEMENT_NODE) { 189 return createObject("Element", doc, (xmlNodePtr)attr); 190 } else { 191 return Undefined(); 192 } 177 193 END 178 194 … … 199 215 BIND_IM("createComment", createComment); 200 216 BIND_IM("toString", toString); 217 BIND_IM("getElementById", getElementById); 201 218 BIND_IM("close", _close); 202 219 INTERNALCOUNT(2); -
lang/cplusplus/llv8call/trunk/t/070_libxml/02_dom.js
r21023 r21068 1 1 require('t/util.js'); 2 2 3 plan({tests:4 4});3 plan({tests:47}); 4 4 5 5 check_lib("org.coderepos.libxml"); 6 6 var libxml = org.coderepos.libxml; 7 var parser = new libxml.Parser(); 7 8 8 9 var doc; … … 168 169 }); 169 170 171 test(function () { 172 var doc = parser.parse_string( 173 "<!DOCTYPE foo [\n" + 174 " <!ELEMENT foo ANY> \n" + 175 " <!ELEMENT bar ANY> \n" + 176 " <!ATTLIST bar id ID #REQUIRED>\n" + 177 "]>\n" + 178 "<foo>\n" + 179 " <bar id='baz'/>\n" + 180 "</foo>\n" 181 ); 182 var m = doc.getElementById("baz"); 183 ok( m ); 184 is(m.nodeName(), "bar", "document.getElementById"); 185 is(doc.getElementById("noo"), undefined, 'getElementById'); 186 }); 187 170 188 doc.close(); 171 189 -
lang/cplusplus/llv8call/trunk/t/070_libxml/03_parser.js
r21067 r21068 1 1 require('t/util.js'); 2 2 3 plan({tests: 1});3 plan({tests:2}); 4 4 5 5 check_lib("org.coderepos.libxml");
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)