brandonaaron / jquery-cssHooks

Collection of cssHooks that work with jQuery 1.4.3+
Other
478 stars 80 forks source link

Shouldn't the official property name be preferred over the vendor prefix ones? #34

Closed mattyoung closed 12 years ago

mattyoung commented 13 years ago
    support.borderRadius =
        divStyle.MozBorderRadius     === ''? 'MozBorderRadius'    :
        (divStyle.MsBorderRadius     === ''? 'MsBorderRadius'     :
        (divStyle.WebkitBorderRadius === ''? 'WebkitBorderRadius' :
        (divStyle.OBorderRadius      === ''? 'OBorderRadius'      :
        (divStyle.borderRadius       === ''? 'BorderRadius'       :
        false))));

the vender prefix name is calculated before the official non-vender prefixed name.

So for example, in Chrome, both "webkitBorderRadius" and "borderRadius" work. Shouldn't "BorderRadius" be used instead of "WebkitBorderRadius"?

I did some experiment, in chrome, "webkitBorderRadius" and "borderRadius" are interchangable in javascript code. Since we always put the official property name one last in css to let it have precedence, shouldn't we use the official name in js if that's supported? Or maybe not even define the cssHooks and use jQuery default (simply do .css("borderRadius", x) without going through any custom cssHook )?

tomgrohl commented 13 years ago

Hi Matt,

Yes your right there. It seems strange that webkit supports both. Maybe its because Css3 is still in development.

For most of the cssHooks, a hook is not added if the standard property is supported, but it seems the order should be more like:

support.borderRadius =
    divStyle.borderRadius     === ''? 'BorderRadius'    :
    (divStyle.MozBorderRadius       === ''? 'MozBorderRadius'       :
    (divStyle.MsBorderRadius     === ''? 'MsBorderRadius'     :
    (divStyle.WebkitBorderRadius === ''? 'WebkitBorderRadius' :
    (divStyle.OBorderRadius      === ''? 'OBorderRadius'      :
    false))));

So it checks for the standard one first, otherwise in webkits case "WebkitBorderRadius" would be true and an unnecessary cssHook would be added.