Getting Started
Install
To begin, install the library.
The library can be installed using a script tag:
The library can also be installed using a package manager:
npm
consolebun
consolepnpm
consoledeno
consoleyarn
consoleImport
Next, import a function from the library into your custom element:
Import es
module
javascript
If you prefer to use umd
modules, import from the ce-part-utils.umd.js
file:
Import umd
module
javascript
Both the default es
module and the umd
module also have minified variants that can be imported with the .min.js
extension:
Import minified modules
javascriptProvide a shadow root
This library works on child elements of a shadow root, which is a tightly-scoped document within custom HTML elements that, among other things, does not inherit styles.
To use the library, create a custom element and attach its shadow root:
Create a custom element
javascriptOnce a custom element is added to the document, the library functions can be called on it by passing in its shadowRoot
property:
Call a function
javascriptMapping configuration objects can be used by the functions to translate from element tag, input type, or part (for exportparts translation) to any arbitrary string:
Use config objects
javascriptTroubleshooting
Custom elements must be established within the javascript scope in order to have their shadow roots queried.
When using this library outside of a custom element's own connectedCallback
method, await
the whenDefined()
promise for that custom element before using any of the library functions: