CSS ::first-letter + text-transform: uppercase and empty text fragments and Firefox do not work together #15055
Replies: 2 comments
|
This looks like a Firefox / CSS pseudo-element edge case rather than something So if Firefox only considers the first text-node segment when resolving For app code, I would avoid depending on If you want to pursue it as a browser issue, a minimal DOM-only repro with an empty text node before the real text would probably be the clearest thing to file against Firefox. If the repro only happens with Vue-generated output, then it would be worth turning that into a small Vue reproduction too, but the behavior you described sounds consistent with the browser pseudo-element algorithm interacting badly with empty text nodes. |
|
I tested this behavior, and I think avoiding ::first-letter for dynamic vue-rendered text is the safest approach. Since vue can introduce framework-managed nodes around fragments, relying on the browser to resolve ::first-letter may lead to inconsistent behavior. A more predictable solution is to transform the string before rendering or explicitly wrap the first character in its own element and style that. Thanks for the explanation @wyf027 about the fragment/text-node behavior that helped clarify why this can differ between browsers. |
Uh oh!
There was an error while loading. Please reload this page.
I am writing this mostly for posterity. I wanted to use CSS
::first-letter+text-transform: uppercaseto transform the first letter of rendered text to upper case. It looks like this does not work well in Firefox, because Vue sometimes renders empty text fragments (to anchor its rendering) and Firefox seems to then look only in the first segment for::first-letter. It works well in Chrome. It also works interestingly if Vue then reactively changes that element's DOM content despite still having empty text segments before the main text content.All reactions