The original implementation seems not that robust. If there is a default layout that supports both text and url, in the case when users disable the last url layout, both the original and the new implementations display "text".
To display correct type, I would suggest to pass the type from this function:
https://github.com/mozilla-b2g/gaia/blob/master/shared/js/keyboard_helper.js#L567