Re: Decoded Personalized Google code - function SetClassStyle( clazz, style, value)
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Decoded Personalized Google code - function SetClassStyle( clazz, style, value)

From: Aaron Gray <ang.usenet@gmail.com>
Date: Thu Nov 17 2005 - 18:23:31 CET

"Matt Kruse" <newsgroups@mattkruse.com> wrote in message
news:dlibv802bcg@news2.newsguy.com...
> Aaron Gray wrote:
>> First up 'SetClassStyle()' :-
>
> This doesn't seem to be very generalized. What are you hoping to gain by
> posting it?
>
>> clazz = "." + clazz;

Ah. Its not really a general routine then :(

The leading period can go.

> Only sets the style for rules of the form
>
> .class
>
> but not for
>
> tagname.class
> or
> tag .class
>
>> if (!rules) return; // err ???
>
> Should it not then default to the "No stylesheet" approach?

Right, that is probably or possibility the right solution.

>> var all = getElementByTagName("*");
>
> Error prone in some versions of IE, no?
>
>> if ( all[element].className == clazz)
>
> Not a good general practice, since an element may have style="class1
> class2" and this case would be skipped over.

Ah. I was not aware of that. But again this is not really a general routine
but one to be used as part of a UI library.
Which is a limited case. But I will bear that in mind if I can get my head
round it ??

Trying to produce a proper general case would be good but it may be too much
work or be inefficient for the cases it is being used in.

Aaron
Received on Mon Nov 21 03:32:44 2005