louisremi / background-size-polyfill

Adds support for background-size "cover" and "contain" to IE8
http://louisremi.github.com/background-size-polyfill/
MIT License
1.26k stars 359 forks source link

backgroundPositionX/Y don't accept keywords? #14

Closed rask closed 11 years ago

rask commented 11 years ago

I had to convert my background-position css from left top to 0 0, although the documentation said it would work.

There is a comment around line 50-55 regarding the background positioning values:

    // Only keywords or percentage values are supported
    backgroundPositionX: positions[ pos[0] ] || parseFloat( pos[0] ) / 100,
    backgroundPositionY: positions[ pos[1] ] || parseFloat( pos[1] ) / 100

Does "Only keywords ..." mean "left", "center", etc. or is there something I missed? The documentation (here at Github) states:

lengths (px, em, etc.) in background-position (only percentages and keywords such as > center work)

as criteria for the background-position value.

If I use left top instead of 0 0 the script errors out, declaring the value of backgroundPositionX/Y as NaN (leaving me with no image at all). After I switched in 0 0 the script worked just fine.

Is this a mistake or is the documentation outdated/incorrect?

(I didn't try out the minified version, could be that this works fine in that version.)