On Apr 30, 10:13 am, bazikch <bazik...@gmail.com> wrote:
> Hello,
>
> I'm trying to do the following:
> $(el).writeAttribute('style', $(elParent).readAttribute('style'));

It would be helpful if you explained what it is exactly that are you
trying to accomplish.

The line above actually ends up jumping through dozens of hoops,
working around IE's broken attribute model (and defective (get|set)
Attribute). In its core, `readAttribute` relies on `getAttribute`;
`getAttribute('style')`, in its turn, returns a value of *an actual
"style" attribute*. If an element you're querying it from does not
have `style` attribute, getAttribute/readAttribute will return `null`.
Otherwise, it will return a string with a value of that attribute. IE,
of course, returns an actual style object (not the string value) as it
does not differentiate between element attributes and properties.

To get an actual representation of style attribute you would need to
access `style` property of an element, which returns
CSSStyleDeclaration object. It's good to remember that this
representation only contains values that are explicitly set in
element's `style` attribute. It does not return computed style values
(which browser calculates based on cascading rules and resolution of
relative values).

If what you really want to do is copy styles of one element to another
one, then you can always iterate over certain set of properties (that
you're interested in) of a `style` object and assign their values to
same-named properties of another element's `style` object:

var props = ['top', 'left', 'width', 'height'],
      i = props.length;
while (i--) {
  el.style[props[i]] = parentEl.style[props[i]];
}

Note that this will only work with values set explicitly in a `style`
attribute (and not those declared in, say, inline or linked
stylesheets).

[...]

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to