You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/03/26 21:02:16 UTC
svn commit: r522624 - in /incubator/xap/trunk/codebase/src/dojo/src: dom.js
html/style.js
Author: jmargaris
Date: Mon Mar 26 14:02:15 2007
New Revision: 522624
URL: http://svn.apache.org/viewvc?view=rev&rev=522624
Log:
https://issues.apache.org/jira/browse/XAP-347
Optimizations in dojo code
Modified:
incubator/xap/trunk/codebase/src/dojo/src/dom.js
incubator/xap/trunk/codebase/src/dojo/src/html/style.js
Modified: incubator/xap/trunk/codebase/src/dojo/src/dom.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dom.js?view=diff&rev=522624&r1=522623&r2=522624
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dom.js (original)
+++ incubator/xap/trunk/codebase/src/dojo/src/dom.js Mon Mar 26 14:02:15 2007
@@ -284,15 +284,29 @@
dojo.dom.isDescendantOf = function(/* Node */node, /* Node */ancestor, /* boolean? */guaranteeDescendant){
// summary
// Returns boolean if node is a descendant of ancestor
- // guaranteeDescendant allows us to be a "true" isDescendantOf function
- if(guaranteeDescendant && node) { node = node.parentNode; }
- while(node) {
- if(node == ancestor){
+
+ // check if node is defined
+ if(!node) { return false; }
+
+ //we'll save an ancestor field on the node
+ //so that when we call this multiple times with the same ancestory
+ //we only have to walk up the tree once.
+ //Note this can fail if they call this once, then
+ //remove the node from a document then call this again, but we don't really
+ //care about that case, it should never really happen hopefully.
+ if(node.ancestor == ancestor) { return true; }
+
+ // guaranteeDescendant allows us to be a "true" isDescendantOf function
+ var currentNode = guaranteeDescendant ? node.parentNode : node;
+
+ while(currentNode) {
+ if(currentNode == ancestor) {
+ node.ancestor = ancestor;
return true; // boolean
}
- node = node.parentNode;
+ currentNode = currentNode.parentNode;
}
- return false; // boolean
+ return false; // boolean
}
dojo.dom.innerXML = function(/*Node*/node){
Modified: incubator/xap/trunk/codebase/src/dojo/src/html/style.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/html/style.js?view=diff&rev=522624&r1=522623&r2=522624
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/html/style.js (original)
+++ incubator/xap/trunk/codebase/src/dojo/src/html/style.js Mon Mar 26 14:02:15 2007
@@ -217,9 +217,12 @@
}
dojo.html.toSelectorCase = function(/* string */selector){
+ if(!dojo.html.toSelectorCase.re) {
+ dojo.html.toSelectorCase.re = /([A-Z])/g;
+ }
// summary
// Translates a camel cased string to a selector cased one.
- return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase(); // string
+ return selector.replace(dojo.html.toSelectorCase.re, "-$1" ).toLowerCase(); // string
}
dojo.html.getComputedStyle = function(/* HTMLElement */node, /* string */cssSelector, /* integer? */inValue){