> This article seems to be discussing embedded stylesheets which look
> like this: <style>tab { left: 50px; }</style>
> I have to add support for inline styles like this one: <tab
> style="left: 50px"></tab>

Not going to happen.  In order to accomplish that task you would have
to write an XML Schema that defines what a style attribute is.  Then
you would have to write a user-agent specific API for accessing a CSS
interpreter at each occurrence of the given attribute name.  Then you
would have to apply the interpreted CSS back to the DOM.  You have to
keep in mind that XML is not a language with a vocabulary.  It is a
syntax.

Think about it like this...
Where is the style attribute of your XML document defined?  Is there a
schema that defines this attribute or is a custom created user-agent
that knows exactly what that attribute is?  Is there any supplied
documentation that can point to such a definition.  If there is no
definition then that attribute is merely an anonymous name.

> I would disagree here. In many cases inline styles are more suitable.
> For example in order to implement draggable tabs I have to update CSS
> values for "left" and "top" of the currently active tab every time
> when mousemove event fires:

You don't need inline style to accomplish this.  You can assign the
changed CSS to the style property of the given DOM object without ever
updating the HTML style attribute.

> - With inline styles this is very easy to do:
>
> tabElement.addEventListener('mousemove', function(event) {
>   myTabElement.setAttribute('style', 'left: ' + positionX + '; top:' +
> positionY);
>
> }

That is less easy than:
 tabElement.addEventListener('mousemove', function(event) {
   myTabElement.style.left = positionX;
   myTabElement.style.top = positionY;
 });

I say it is less easy because when you need to read the style
properties you have to decode the attribute value that you are
assigning each and every time.  If the style values are assigned to
the DOM style property then you can read the style values merely by
calling the style property.  Furthermore, your solution is also slower
to execute.

> - It's impossible with static external stylesheets
Changes to the DOM are not concerned with whether the stylesheet is
embedded or external unless you expect to save state of the document
when saving down a local copy.

> - It would be tricky to do with embedded dynamic stylesheet because in
> order to apply a style to specified element I would have to know the
> correct CSS selector.
You will likely need to know the CSS selector anyways if the
interaction becomes more complex, such as tabs moving position if the
focus of the executing event originates from a different element.

> I have many tabs in the same document, targeting
> the correct one would require some additional logic.
Yes, you will need to supply additional logic anyways, because if you
working in XML without a schema definition CSS selectors are all you
have to work with.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to