On Mar 1, 2013, at 8:09 PM, Jason Westbrook wrote:

> 
> I'm using OSX Chrome and it does it correctly as does Safari

Really? What version? It didn't work for me in 17.0.963.83. I see that there's 
an update available from there, but I get an error when I try to update -- 
Update server not available. Strange, given that it's Google's server...

> 
> .getStyle() either uses the inline style via the .style property of the DOM 
> object

The issue seems to be that you can't use the fully composed shortcut to set the 
DOM (and according to the W3C, that's the spec). You can only manipulate the 
decomposed attributes. Doesn't explain why Safari lets you do it. It seems to 
coalesce all styles to their more fully composed form internally -- if you try 
my example again and watch the element in the Web Inspector, you will see that 
whether you set two.setStyle('border") with the Copy Border Style link, or loop 
through all of the decomposed parts of that style attribute with Copy Border 
Style With Crazy Long-ass Work-around, the DOM reads border: 10px solid 
rgb(102, 102, 102); 

> 
> if that is not set then it tries to use
> 
> document.defaultView.getComputedStyle(element, null) which is returning 
> nothing for the "border" property
> 
> have you tried to use 
> http://api.prototypejs.org/dom/Element/prototype/getLayout/  ?

Thanks, this would get me the width of the border, but I'm actually trying to 
capture the entire border style. Here's what I ended up with for now:

    $('copy2').observe('click', function(evt){
      var one = $('one'), two = $('two');
      $w('top right bottom left').each(function(side){
        $w('color width style').each(function(mode){
          var key = 'border-' + side + '-' + mode
          var val = one.getStyle(key);
          two.setStyle(key + ':' + val);
        });
      });
    });

I discovered in the process that setting these attributes with their 
camel-cased key names didn't seem to work, while using the hyphenated forms 
worked fine. I could set a single camel-case variable at a time, long-hand, but 
inside my nested loop, I was only able to use the hyphenated form. I still 
haven't figured out why that happened. It appears as though setStyle({key: 
val}) is not equivalent to setStyle('key: val') in some cases.

Thanks for looking at this,

Walter

> 
> Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com
> 
> 
> On Fri, Mar 1, 2013 at 4:42 PM, Walter Lee Davis <wa...@wdstudio.com> wrote:
> Try this example in Safari, Chrome, and Firefox, latest versions. Please let 
> me know what you see.
> 
> http://scripty.walterdavisstudio.com/copy-style-fail.html
> 
> Safari gets it right, Firefox and Chrome do not, and I'm baffled.
> 
> Digging into the issue in Firebug, it appears as though 
> defaultView.getComputedStyle is only populating the fully-decomposed border 
> properties: border-left-color, border-left-width, etc. None of the 
> intermediate shortcut attributes have any value assigned to them at all.
> 
> Any suggestions?
> 
> Thanks,
> 
> Walter
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Prototype & script.aculo.us" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to prototype-scriptaculous+unsubscr...@googlegroups.com.
> To post to this group, send email to prototype-scriptaculous@googlegroups.com.
> Visit this group at 
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Prototype & script.aculo.us" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to prototype-scriptaculous+unsubscr...@googlegroups.com.
> To post to this group, send email to prototype-scriptaculous@googlegroups.com.
> Visit this group at 
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prototype-scriptaculous+unsubscr...@googlegroups.com.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
Visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to