incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r488950 - /incubator/xap/trunk/src/google/xpath.js
Date Wed, 20 Dec 2006 08:18:06 GMT
Author: jmargaris
Date: Wed Dec 20 00:18:05 2006
New Revision: 488950

URL: http://svn.apache.org/viewvc?view=rev&rev=488950
Log:
Fixes for working in the browser dom where ownerDocument
behaves a bit differently (go go unit tests!)

Modified:
    incubator/xap/trunk/src/google/xpath.js

Modified: incubator/xap/trunk/src/google/xpath.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/xpath.js?view=diff&rev=488950&r1=488949&r2=488950
==============================================================================
--- incubator/xap/trunk/src/google/xpath.js (original)
+++ incubator/xap/trunk/src/google/xpath.js Wed Dec 20 00:18:05 2006
@@ -409,7 +409,10 @@
   this.nodelist = nodelist || [ node ];
   this.variables = {};
   this.parent = parent || null;
-  this.root = parent ? parent.root : node.ownerDocument;
+  
+  //in the browser dom a document object itself does not have an ownerDocument
+  //so if we can't get an owner just use the current node, which hopefully is a document
+  this.root = parent ? parent.root : (node.ownerDocument?node.ownerDocument:node);
 }
 
 ExprContext.prototype.clone = function(node, position, nodelist) {
@@ -867,6 +870,12 @@
       ids = e.stringValue().split(/\s+/);
     }
     var d = ctx.node.ownerDocument;
+    
+    //in the browser the document object itself
+    //does not have an ownerDocument
+    if (!d && ctx.node.getElementById){
+    	d = ctx.node;
+    }
     for (var i = 0; i < ids.length; ++i) {
       var n = d.getElementById(ids[i]);
       if (n) {



Mime
View raw message