Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cherry-on-lit

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cherry-on-lit

Extension that adds a $ to LitElement

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cherry-on-lit

This package offers a mixin (CherryOnLit) you can use to aggregate elements with an id attribute in your LitElement template.

Usage

import { LitElement, html } from 'lit-element';
import { CherryOnLit } from 'cherry-on-lit';

class MyApp extends CherryOnLit(LitElement) {
  render () {
    return html`
    <div id="myElement">loading</div>
    `
  }

  firstUpdate() {
    this.$.myElement.innerText = 'hello anonymous';
  }
}

(it also works with typescript)

Installation

npm install cherry-on-lit

Notes

Pros:

  • It's easy to install
  • You don't need to write all the query functions.

Cons:

  • Everytime you request $ it scan the dom, it may affect the performance of your code if your template is massive and you overuse it.
  • Your IDE will lose track of the typings because the $ aggregator is naively querying the elements in the dom without any cast. For this reason I recommand using typescript and casting the elements as you request them:
const i = this.$.importantInput as HTMLInputElement;
i.value = 'new value';

FAQs

Package last updated on 11 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc