Skip to content
프로젝트

소개

레거시 저장소입니다. 이 저장소는 레거시 LitElement 라이브러리를 유지 관리하기 위한 것입니다. LitElement 기본 클래스는 현재 Lit 라이브러리의 일부이며, Lit 라이브러리는 lit 모노레포에서 개발됩니다.

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
-1
in 7 days
-1
in 15 days
-4
in 1 month
-6

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

LitElement

LitElement is simple base class for creating fast, lightweight web components with lit-html.

Build Status Published on npm Join our Slack Mentioned in Awesome lit-html

Looking for Lit?

LitElement is now part of the Lit library monorepo. Lit 2 includes lit-html 2.x and LitElement 3.x.

This repo contains the code for LitElement 2.x.

Documentation

For LitElement 2.x documentation, see the legacy documentation site.

For Lit 2, the next version of LitElement and lit-html, see the Lit site.

Overview

LitElement uses lit-html to render into the element's Shadow DOM and adds API to help manage element properties and attributes. LitElement reacts to changes in properties and renders declaratively using lit-html. See the lit-html guide for additional information on how to create templates for lit-element.

import {LitElement, html, css, customElement, property} from 'lit-element';

// This decorator defines the element.
@customElement('my-element')
export class MyElement extends LitElement {

  // This decorator creates a property accessor that triggers rendering and
  // an observed attribute.
  @property()
  mood = 'great';

  static styles = css`
    span {
      color: green;
    }`;

  // Render element DOM by returning a `lit-html` template.
  render() {
    return html`Web Components are <span>${this.mood}</span>!`;
  }

}
<my-element mood="awesome"></my-element>

Note, this example uses decorators to create properties. Decorators are a proposed standard currently available in TypeScript or Babel. LitElement also supports a vanilla JavaScript method of declaring reactive properties.

Examples

Installation

From inside your project folder, run:

$ npm install lit-element

To install the web components polyfills needed for older browsers:

$ npm i -D @webcomponents/webcomponentsjs

Supported Browsers

The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition, Internet Explorer 11 is also supported.

Edge and Internet Explorer 11 require the web components polyfills.

Forward Compatibility With Lit 2

Lit 2 (LitElement 3.0) has a few breaking changes and deprecations that have been back-ported to LitElement 2.5 in order to ease upgrading.

To prepare for Lit 2, update these APIs:

LitElement 2.4 LitElement 2.5/Lit 2
Decorator imports:
import {customElement} from 'lit-element';
import {customElement} from 'lit-element/decorators.js';
@internalProperty() foo; @state() foo;
Override _getUpdateComplete() Override getUpdateComplete()
Shadow root options:
Override createRenderRoot().
Add static shadowRootOptions.
import {UpdatingElement} from 'lit-element'; import {ReactiveElement} from 'lit-element';

Contributing

Please see CONTRIBUTING.md.

관련 프로젝트 살펴보기

불러오는 중…