Полимер 3, элемент слота в шаблоне не заполнен - PullRequest
0 голосов
/ 27 февраля 2019

Я пытаюсь создать полимерный элемент 3, который обернут вокруг <math-tex> элемента , определенного Яном Мартедалом Расмуссеном.К сожалению, я не могу заполнить элемент нужным содержимым, используя синтаксис <slot></slot> в шаблоне, и я понятия не имею, почему.

Новый элемент определен в файле

tve-inline-уравнение.js

import { PolymerElement, html } from 'https://unpkg.com/@polymer/polymer@3.0.0/polymer-element.js';
// import 'https://unpkg.com/@polymer/iron-flex-layout@3.0.1/iron-flex-layout-classes.js';

class TVEInlineEquation extends PolymerElement {
  static get template() {
    return html`
<math-tex><slot>0</slot></math-tex>
`;
  }
}

customElements.define('tve-inline-equation', TVEInlineEquation);

Элемент протестирован в документе

index.html

<!DOCTYPE html>

<html>
  <head>
    <!-- https://github.com/janmarthedal/math-tex -->
    <script src="math-tex.js"></script>
    <script src="math-tex-controller.js"></script>
    <script type="module" src="tve-inline-equation.js"></script>
  </head>
<body>

<p>Place for an inline equation, using my custom html 
element tve-line-equation.</p>
<tve-inline-equation>c = \sqrt{a^2 + b^2}</tve-inline-equation>
<p>The problem is that the equation is not rendered 
and the "0" from the default slot value is inserted instead.</p>

<p>A new location for an equation, this time directly in
a math-tex element.</p>
<math-tex>c = \sqrt{a^2 + b^2}</math-tex>

</body>
</html>

Онлайн-площадка с кодом доступна по адресу plunker .

Еще одна вещь, которая беспокоит меня, заключается в том, что при импорте компоновки iron-flex-текста текстовое представление уравнения отображается на экране вместо содержимого по умолчанию дляслот. * * 1 021

...