colazo / enhancejs

Automatically exported from code.google.com/p/enhancejs
Other
0 stars 0 forks source link

add a test for className support on documentElement #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
regarding the "enhanced" class applied to the HTML element, it may be a 
good idea to add a small test that adds and removes a class to 
documentElement to make sure it works properly, since it technically is not 
supposed to have a class attribute.

In the process, this test could ensure the existence of the className 
property in general, which is currently used without prior testing in 
EnhanceJS

Noted by Kangax:
"Technically 
(as per HTML 4.01 or even XHTML 1.0), HTML element can not have class 
attribute (http://www.w3.org/TR/REC-html40/struct/global.html#edef- 
HTML), so given that you're setting className which as per DOM L2 HTML 
corresponds directly to "class" attribute (http://www.w3.org/TR/DOM- 
Level-2-HTML/html.html#ID-95362176), this might very well not work in 
some environments (mobile devices, older desktop browsers, etc.)... 
that is if you want to play safe and script defensively :) On the 
other hand, assigning className to document.documentElement could 
well 
be a de-facto standard and work more or less reliably. Its just that 
in my experience, playing "by the rules" is usually the safest way to 
go, and if you have another—safer—option (say, adding class to body), 
it'd go with that. "

Original issue reported on code.google.com by scottj...@gmail.com on 2 Apr 2010 at 3:29

GoogleCodeExporter commented 8 years ago
this has become fairly standard practice, and the class is added through dom 
scripting, rather than in the raw source. I think it's okay to keep as-is.

Original comment by scottj...@gmail.com on 2 Sep 2010 at 1:45