0.0.11 • Published 2 years ago

be-adopted v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.

0.0.10

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.1

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.0

2 years ago