如何创建没有阴影的 LitElement DOM?

How to create LitElement without Shadow DOM?

我正在使用 LitElement 创建 Web 组件。这是来自https://lit-element.polymer-project.org/guide/start

// Import the LitElement base class and html helper function
import { LitElement, html } from 'lit-element';

// Extend the LitElement base class
class MyElement extends LitElement {

  /**
   * Implement `render` to define a template for your element.
   *
   * You must provide an implementation of `render` for any element
   * that uses LitElement as a base class.
   */
  render(){
    /**
     * `render` must return a lit-html `TemplateResult`.
     *
     * To create a `TemplateResult`, tag a JavaScript template literal
     * with the `html` helper function:
     */
    return html`
      <!-- template content -->
      <p>A paragraph</p>
    `;
  }
}
// Register the new element with the browser.
customElements.define('my-element', MyElement);

如何创建没有阴影的 LitElement DOM?

我想在没有#shadow-root 的情况下创建它:

只是为了确保此问题显示为已回答:

createRenderRoot 允许您覆盖创建影子根的操作。它通常用于渲染到光照 dom:

createRenderRoot() {
  return this;
}

尽管它可以完全用于渲染其他地方。

我真的推荐使用阴影 DOM。如果一个元素覆盖了它自己的光,合成就很困难 DOM。