function addCaret(element) {
            var elementAlreadyHasCaret = element[0].querySelector('.dirTerminalType-caret') !== null;

            if (!elementAlreadyHasCaret) {
                var height = parseInt($window.getComputedStyle(element[0])['font-size']);
                height -= 2; // make it a bit smaller to prevent it interfering with document flow.
                var backgroundColor = $window.getComputedStyle(element[0])['color'];
                var width = Math.ceil(height * 0.05);
                var marginBottom = Math.ceil(height * -0.1);
                var caret = $document[0].createElement('span');
                caret.classList.add('dirTerminalType-caret');
                caret.style.height = height + 'px';
                caret.style.width = width + 'px';
                caret.style.backgroundColor = backgroundColor;
                caret.style.marginBottom = marginBottom + 'px';
                element.append(caret);
            }
        }
Add the caret to the end of the element, and style it to fit the text.
First line checks if a caret already exists, in which case do nothing.

@param element