port mapbox/mapbox-gl-js#ffd529df107bfec446fa4b4454a583f296c38819