npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

basic-element-base

v0.8.0

Published

A sample general-purpose base class for defining custom elements that mixes in some common features: template stamping into a shadow root, automatic node finding, and marshalling between attributes and properties.

Downloads

18

Readme

API Documentation

ElementBase

A sample general-purpose base class for defining custom elements that mixes in some common features: template stamping into a shadow root, shadow element references, marshalling attributes to properties, and retrieving the children distributed to a component.

This base class is not special in any way, and is defined only as a convenient shorthand for applying the mixins listed above. You can use this class as a base class for your own elements, or easily create your own base class by applying the same set of mixins.

The ElementBase base class does not register itself as a custom element with the browser, and hence cannot be independently instantiated.

Kind: global class Mixes: AttributeMarshalling , Composable , DistributedChildren , ShadowElementReferences , ShadowTemplate

ElementBase.compose(...mixins)

Apply a set of mixin functions or mixin objects to the present class and return the new class.

Instead of writing:

let MyClass = Mixin1(Mixin2(Mixin3(Mixin4(Mixin5(BaseClass)))));

You can write:

let MyClass = Composable(BaseClass).compose(
  Mixin1,
  Mixin2,
  Mixin3,
  Mixin4,
  Mixin5
);

This function can also take mixin objects. A mixin object is just a shorthand for a mixin function that creates a new subclass with the given members. The mixin object's members are not copied directly onto the prototype of the base class, as with traditional mixins.

In addition to providing syntactic sugar, this mixin can be used to define a class in ES5, which lacks ES6's class keyword.

Kind: static method of ElementBase. Defined by Composable mixin.

| Param | Type | Description | | --- | --- | --- | | ...mixins | mixins | A set of mixin functions or objects to apply. |

elementBase.distributedChildNodes : Array.<Node>

An in-order collection of child nodes, expanding any slot elements. Like the standard childNodes property, this includes text nodes.

Kind: instance property of ElementBase. Defined by DistributedChildren mixin.

elementBase.distributedChildren : Array.<HTMLElement>

An in-order collection of children, expanding any slot elements. Like the standard children property, this skips text nodes.

Kind: instance property of ElementBase. Defined by DistributedChildren mixin.

elementBase.distributedTextContent : string

The concatenated text content of all child nodes, expanding any slot elements.

Kind: instance property of ElementBase. Defined by DistributedChildren mixin.

$ : object

The collection of references to the elements with IDs in a component's Shadow DOM subtree.

Kind: global variable