Emotion: "v-text-anchor" property is broken

Created on 12 Jun 2018  路  8Comments  路  Source: emotion-js/emotion

  • emotion version: 9.2.3
  • react version: 16.3.2

Minimal Example:

import { css } from 'emotion'

const app = document.getElementById('root')
const myStyle = css`
  color: rebeccapurple;
  v-text-anchor: middle;
`

app.classList.add(myStyle)

The injected stylesheet looks like this:

<style data-emotion>
  v-text-anchor:middle;.css-1e4y5fg{color:rebeccapurple;}
</style>

Without color (just v-text-anchor) the injected stylesheet looks like this:

<style data-emotion>
  v-text-anchor:middle;}
</style>

I would expect the injected stylesheet to look like this instead:

<style data-emotion>
  .css-1e4y5fg{v-text-anchor:middle;}
</style>

Other properties that match /^[a-z]{1}-/ also seem to break.

Edit 1o9op8moyq


Real-World Example (spoiler):
There's a few intermediate build steps, but this generates VML for displaying rounded buttons in older versions of Outlook.

return (
  <center>
    <if condition="mso">
      <v$roundrect
        xmlns$v="urn:schemas-microsoft-com:vml"
        xmlns$w="urn:schemas-microsoft-com:office:word"
        href={link}
        className="emailButton"
        css={`
          width: ${width};
          height: ${height};
          v-text-anchor: middle;
        `}
        fillcolor={background}
        arcsize={arcsize}
        stroke="f"
      >
        <w$anchorlock />
        <center
          css={`
            color: ${color};
            font-size: ${fontSize};
          `}
        >
          {children}
        </center>
      </v$roundrect>
    </if>
    <else condition="mso">
      <a
        href={link}
        className="emailButton"
        css={`
          display: block;
          width: ${width}px;
          line-height: ${height}px;
          -webkit-text-size-adjust: none;
          background-color: ${background};
          border-radius: ${borderRadius}px;
          font-size: ${fontSize}px;
          color: ${color};
        `}
      >
        {children}
      </a>
    </else>
  </center>
)

bug

Most helpful comment

All 8 comments

VML is predating Internet Explorer 10. In general we do not want to support such old environments. Could u use inline styles for this property?

Strange that with would happen only for x- variants, testing this on stylis.js.org reveals that it is a bug with stylis.

@Andarist yeah, but then I can't tell my colleagues migrating styles from older email templates to react is simple as copy/pasting. welcome to the wonderful world of email clients btw.

@thysultan thanks for finding! going to report upstream & create a PR to upgrade our Stylis version later. turns out only /^v-/ breaks, other letters are fine

@Andarist yeah, but then I can't tell my colleagues migrating styles from older email templates to react is simple as copy/pasting. welcome to the wonderful world of email clients btw.

Yeah, that's certainly a bummer. Hope the issue will get resolved.

@thysultan thanks for finding! going to report upstream & create a PR to upgrade our Stylis version later.

You won't quite be able to upgrade stylis, because emotion has its own copy of it (it's not regular dependency). When the new version gets released you should create a stylis version bump request here.

@ashtonsix Here is the stylis of emotion
https://github.com/emotion-js/next/tree/master/packages/stylis

@Andarist Hey, stylis 3.5.1 was just released! Can we upgrade?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Enalmada picture Enalmada  路  27Comments

DarkoKukovec picture DarkoKukovec  路  28Comments

Metroninja picture Metroninja  路  24Comments

RoystonS picture RoystonS  路  50Comments

yonatanmn picture yonatanmn  路  29Comments