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

be-adopted

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

be-adopted

  • 0.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

be-adopted

How big is this package in your project?

be-adopted is an HTML style tag decorator / behavior based on the be-decorated approach to progressively enhancing elements.

Playwright Tests

<html>
    <head>
        ...
        <link be-preemptive rel=preload id=@my-package/my-web-component/my-styles.css integrity=...>
    </head>
    <body>
        ...
        <my-web-component>
            <style be-adopted=@my-package/my-web-component/my-styles.css></style>
        </my-web-component>
    </body>
</html>

be-adopted plays by the same rule-book as be-loaded. The difference is be-loaded adds style to the shadow DOM realm it belongs to.

be-adopted, instead, does the following:

  1. It adds itself to the shadowRoot of the parent element.
  2. It changes its attribute from be-adopted to be-loaded.

So if my-web-component's internal shadowDOM opts in to incorporate be-loaded, it will "adopt" the styles.

Why?

The strong case: Sometimes a web component is specifically designed to allow the consumer to provide templates that are used within its shadow DOM. This component provides a common usage pattern for specifying styles as well.

The weak case: Sometimes a web component doesn't provide enough flexibility as far as styling. This component can help in a pinch.

Really opting in

There's one more step that may be necessary for the component being targeted to opt in -- if the light children are not slotted somewhere, and if my-web-component is likely to be upgraded prior to be-adopted getting upgraded, then the style tag might not be "visible", which is a requirement for be-decorated based decorators / behaviors to be initialized.

So to be safe, the targeted component should also provide one slot for be-adopted to use in order to work.

Keywords

FAQs

Package last updated on 30 Oct 2022

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