February 18, 2008

Safari is stupid: Part 1

Part 1 because I’m sure I’ll find more of these.

I’ve been debugging some JavaScript this morning trying to get it to work in Safari. Here are some examples of why that took TWO HOURS:

  • You can’t get element.style.border, but you can set it.
  • For a transparent element element.style.backgroundColor = 'transparent', but getComputedStyle(element,null).getPropertyValue('background-color') = 'rgba(0,0,0,0)'; i.e. black, but wholly transparent.

In a not-Safari’s-fault tangent, if you want individual channels from an RGB value split(", ") is BAD CODE.


- 3 comments by 2 or more people Not publicly viewable

  1. Andrew Ingram

    Surely the second one makes sense? If you set a colour it needs to be set to a common format, namely rgb(a). Do you expect to get ‘red’ out if the colour is set to ‘red’, or do you expect to get 255,0,0,0?

    I would expect 255,0,0,0 because that’s the native format. The names are just a shortcut.

    18 Feb 2008, 12:36

  2. Matthew Jones

    I would expect them to be the same. Either both red or neither red.

    18 Feb 2008, 13:37

  3. Mathew Mannion

    @getComputedStyle@ is getting the style as the browser sees it, so 255,0,0,0 is what I’d expect, in the same way as you’d expect margin-top to be 2px if you do margin: 2px;

    18 Feb 2008, 14:11


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.