Skip to content
Browse files

Cleanup dom module for jsc/browser

  • Loading branch information...
1 parent 96441fd commit da4e5cd2205490a7bc7c77c50d22fff3d18bf8ea Tom Robinson committed Oct 1, 2009
Showing with 10 additions and 19 deletions.
  1. +10 −19 engines/jsc/lib/browser/dom.js
View
29 engines/jsc/lib/browser/dom.js
@@ -1,27 +1,18 @@
+exports.Node = global.Node;
+exports.Element = global.Element;
+exports.Document = global.Document;
-exports.createDocument = function(/*String*/ namespaceURI, /*String*/ qualifiedName, /*DocumentType*/ doctype) {
- return global.document.implementation.createDocument(namespaceURI, qualifiedName, doctype || null);
-}
-
-exports.XMLSerializer = global.XMLSerializer;
+exports.NodeList = global.NodeList;
-// DOMParser
exports.DOMParser = global.DOMParser;
+exports.XMLSerializer = global.XMLSerializer;
+exports.XPathResult = global.XPathResult;
-var validContentTypes = { "text/xml" : true, "application/xml" : true, "application/xhtml+xml" : true };
-
-// FIXME: wrap Document so we can add these:
-
-exports.createExpression = function(/*String*/ xpathText, /*Function*/ namespaceURLMapper) {
- return (new XPathEvaluator).createExpression(xpathText, namespaceURLMapper).
+exports.createDocument = function(/*String*/ namespaceURI, /*String*/ qualifiedName, /*DocumentType*/ doctype) {
+ return global.document.implementation.createDocument(namespaceURI, qualifiedName, doctype || null);
}
exports.evaluate = function(/*String*/ xpathText, /*Node*/ contextNode, /*Function*/ namespaceURLMapper, /*short*/ resultType, /*XPathResult*/ result) {
- return exports.createExpression(xpathText, namespaceURLMapper).evaluate(contextNode, resultType, result);
+ var doc = contextNode instanceof exports.Document ? contextNode : contextNode.ownerDocument;
+ return doc.evaluate(xpathText, contextNode, namespaceURLMapper, resultType, result || null);
}
-
-exports.Node = global.Node;
-exports.Node = global.Document;
-exports.Element = global.Element;
-exports.NodeList = global.NodeList;
-exports.Document = global.Document;

0 comments on commit da4e5cd

Please sign in to comment.
Something went wrong with that request. Please try again.