On 12/10/05 21:45, Eugene Lazutkin wrote:
Inline.

"Robert Wittams" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

I had a look at dojo before and these were the questions that popped up
in my mind:

Dojo seems to rely on adding its own unnamespaced attributes to normal
elements. Is this compatible with strict use of XHTML?

No. Yes. And no. And Yes. Let me explain.

1) No. Adding your own attributes is not compatible with XHTML.


When talking about the admin views, that is views only accessible to a specific group of authenticated users, I don't realy care if some validator barfs on custom attributes or the like.

2) Yes. You can safely add your own attributes to XHTML code providing your specified your own namespace for them.

3) AFAIK, at present there is no standard-conformant XHTML browser. Translation: you can define your own namespace for attributes but browsers may ignore it and complain about "unknown attributes".

4) Given all that I tend to specify parameters using class names and HTML payload and/or JavaScript. Dojo supports specification of widget type using class name. It makes it possible to define your custom widgets in following manner:

<div class="dojo-mywidget">
    <span class="ident">1</span>
    <span class="name">Sparky</span>
</div>

I believe it is fully compatible with XHTML.


I think using custom attributes, namespaced or not, is a powerfull, flexible and clean way to attach behaviours to elements. It also degrades nicely for older/non-js browsers.

Personally I prefer something like
<div dojoType="Foo" propertyBar="baz" />
to (ab)using classes as in your example.

Using classes it's not clear if it's there to style an element or to pass params to some js widget or whatever. When using custom attrs it's much clearer what's going on.

regards

Reply via email to