wc-trim-middle
Dominic Myers

Dominic Myers @mouseannoying

About: Front-end developer, Archer, Writer and Educator

Location:
Ely, UK
Joined:
May 6, 2020

wc-trim-middle

Publish Date: Jan 22
0 0

By Marie Vander Meiren via scopio

I've lost track of the number of times I've needed to truncate text online, and I've tried all sorts of mechanisms, so when I came across Christian Heilmann's trimMiddle() function, I was happy as Larry.

So happy that I just had to convert it into a web component. After reading about how problematic people are finding styling web components from outside, I also decided to create it without a shadow DOM, and I'm pleased with the result.

There's a functional demo. However, I found it very frustrating to make it accept dynamic changes to the inner text. Have a play and see if it fits your requirements.

Comments 0 total

    Add comment