[dojo-contributors] src/html.js of revision 4507

Bryan Forbes bryan at reigndropsfall.net
Wed Jun 28 15:14:04 EDT 2006


Also, why not change the trim to a regexp?  Here's what we did in the
html-refactor branch to remove the dependency on dojo.string:

dojo.html.getClass = function(node){
	node = dojo.byId(node);
	if(!node){ return ""; }
	var cs = "";
	if(node.className){
		cs = node.className;
	}else if(dojo.html.hasAttribute(node, "class")){
		cs = dojo.html.getAttribute(node, "class");
	}
	return cs.replace(/^\s+|\s+$/g, "");
}

and for addClass:

dojo.html.addClass = function(node, classStr){
	if (dojo.html.hasClass(node, classStr)) {
	  return false;
	}
	classStr = (dojo.html.getClass(node) + " " + classStr).replace(/^\s+|\s
+$/g,"");
	return dojo.html.setClass(node, classStr);
}

and that removes that dependency.

On Wed, 2006-06-28 at 14:05 -0500, Bryan Forbes wrote:
> 	The only problem with not having trim at the end of getClass is that on
> some browsers (not sure which off the top of my head) go haywire if you
> have trailing whitespace at the end of a class attribute.
> 
> On Tue, 2006-06-27 at 00:43 +0400, Ilia Kantor wrote:
> > To put things short, that's for speedup.
> > 
> > I changed class-handling functions to use regular expressions instead of
> > explode/join, because profiling showed that Tree creation was very slow
> > because of them.
> > 
> > dojo.html.getClass is still widely used, but dojo.html.getClasses is not any
> > more. I removed trim from dojo.html.getClass because it is not needed there.
> > 
> > Although getClasses should return array w/o empty elements, so trim is used
> > there now.
> > 
> > Hope that explains..
> > 
> > -----Original Message-----
> > From: dojo-contributors-bounces at dojotoolkit.org
> > [mailto:dojo-contributors-bounces at dojotoolkit.org] On Behalf Of Bryan Forbes
> > Sent: Monday, June 26, 2006 9:15 PM
> > To: dojo dev.
> > Subject: [dojo-contributors] src/html.js of revision 4507
> > 
> > 	With this check-in, dojo.html.getClass has had dojo.string.trim
> > removed
> > from the return statement and moved to dojo.html.getClasses.  I don't
> > understand why this happened.  I understand the rest of the code changes
> > in html.js for speed-ups, but was the trim removed for a speed-up?  Does
> > this break existing code?
> > 
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors
-- 
======================================================================
Bryan Forbes
bryan at reigndropsfall.net
http://www.reigndropsfall.net

"It does not take a majority to prevail, but rather an irate, tireless
minority keen to set brush fires in people's minds."
        - Samuel Adams, an architect of the Constitution

Key fingerprint = 3D7D B728 713A BB7B B8B1  5B61 3888 17E0 70CA 0F3D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20060628/47574b5c/attachment.sig 


More information about the dojo-contributors mailing list