Created by: erlendfh
[resubmitted, (hopefully) in accordance with the pull request guidelines]
This is an expansion on twitter/bootstrap#5220
I've added gustavowt's fix and a test case that covers the bug.
See original here: https://github.com/twitter/bootstrap/pull/5288