t2ym / i18n-element

I18N Base Element for Lit and Polymer
Other
9 stars 1 forks source link

[lit-html][SVG] Unexpected application of i18n-format to SVG elements in HTML #69

Open t2ym opened 5 years ago

t2ym commented 5 years ago

[lit-html][SVG] Unexpected application of i18n-format to SVG elements in HTML

Root Cause

Expected

Actual

Reproducible Code

    html`${bind(this, 'lit-clock')}
      <div class='square'> <!-- so the SVG keeps its aspect ratio -->
        <svg viewBox='0 0 100 100'>
          <!-- first create a group and move it to 50,50 so
              all co-ords are relative to the center -->
          <g transform='translate(50,50)'>
            <circle class='clock-face' r='48'/>
            ${minuteTicks}
            ${hourTicks}
            <!-- hour hand -->
            <line class='hour' y1='2' y2='-20'
              transform='rotate(${ 30 * this.date.getHours() + this.date.getMinutes() / 2 })'/>
            <!-- minute hand -->
            <line class='minute' y1='4' y2='-30'
              transform='rotate(${ 6 * this.date.getMinutes() + this.date.getSeconds() / 10 })'/>
            <!-- second hand -->
            <g transform='rotate(${ 6 * this.date.getSeconds() })'>
              <line class='second' y1='10' y2='-38'/>
              <line class='second-counterweight' y1='10' y2='2'/>
            </g>
          </g>
        </svg>
      </div>
    `;

Workaround # 1

Workaround # 2