kennethcachia / background-check

Automatically switch to a darker or a lighter version of an element depending on the brightness of images behind it.
http://kennethcachia.com/background-check/
MIT License
3.27k stars 282 forks source link

Uncaught TypeError: className.replace is not a function #79

Open stevepiron opened 8 years ago

stevepiron commented 8 years ago

I have tried with different target classes and the error keeps occurring. On init I get "Uncaught TypeError: className.replace is not a function". My target class is on a tag and I have tried removing all the classes except the target class but it still doesn't work.

Any idea why? Thanks!

ghost commented 7 years ago

I struggled with this error too, and isolated it to the particular element attached to the target class selector. In my case it would be 'svg'. It would give me this error if I use it on that element. So I just wrapped it in and put the targetClass there. Make sure you put some content in there if svg (like an nbsp for example), so it would think it's not an empty container.

Or you can add it to the wrapping parent element, then just style it accordingly:

parent.targetClass > targetElement background-dark: #000

Hope that helps.