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 🙏

© 2026 – Pkg Stats / Ryan Hefner

templ-maker

v0.0.2

Published

Custom element feature that captures seed DOM fragments as templates and provides cloning/appending

Readme

templ-maker (Template Maker)

One nice feature that the mount-observer polyfill provides is a way to define a custom element declaratively via custom element definition (cede) scripts:

<hello-world>
    <template shadowrootmode=open>
        Hi, there
    </template>
    <script type="cede" data-extends="el-maker"></script>
</hello>

...

<hello-world></hello-world>

This relies on a custom element library (in this case, el-maker) that on-the-fly knows what to do in order to turn the DOM fragment it sits inside into a custom element.

And in order to do that, el-maker needs access to the DOM fragment surrounding it. mount-observer's cede script makes sure it is. It passes the script element to the constructor of the newly minted custom element:

NewCtr.seedRef = new WeakRef(scriptEl);

What this custom element feature does is pull in the HTML DOM Fragment of the parent element -- first checking for a shadow root, and if that isn't there, from a clone of the children not including the seed script element. It takes careful note of which of the two scenarios (ShadowDOM/notShadowDOM). It does this in the onAssigned static method of the feature. It stores the template in the custom element constructor based off of a symbol key

The TemplMaker feature class instance clones the template and by default sets the host element's clone property to the clone.

It also provides an append method, that appends the clone to the shadowRoot, or to the element itself, depending on what scenario was noted for the initial "seed" live DOM fragment.

Replacing the clone

It's convenient for the custom element to be thinking, conceptually, "update the clone". This is in fact what it does as long as the clone property of the custom element really is the clone that templ-maker produced. But, unfortunately, once that clone has been appended to the shadow root or to the light children, continuing to "update the clone" stops working. So to keep the concept of "updating the clone" going, the append method should replace the clone property of the hostElement with either the ShadowRoot, or the hostElement itself, depending on where the clone was appended to.

  1. Install git
  2. Fork/clone this repo
  3. Install node.js
  4. Open command window to folder where you cloned this repo
  5. git submodule add https://github.com/bahrus/types.git types

  6. git submodule update --init --recursive

  7. npm install

  8. npm run serve

  9. Open http://localhost:8000/ in a modern browser