@glimmer/component
- Version 1.1.2
- Published
- 222 kB
- 14 dependencies
- MIT license
Install
npm i @glimmer/component
yarn add @glimmer/component
pnpm add @glimmer/component
Overview
Glimmer component library
Index
Classes
class Component
class Component<S = unknown> extends BaseComponent<S> {}
property args
args: Readonly<Args<S>>;
property bounds
bounds: Bounds;
Contains the first and last DOM nodes of a component's rendered template. These nodes can be used to traverse all of the DOM nodes that belong to a particular component.
Note that a component's first and last nodes *can* change over time, if the beginning or ending of the template is dynamic. You should always access
bounds
directly at the time a node is needed to ensure you are acting on up-to-date nodes.### Examples
For components with a single root element,
this.bounds.firstNode
andthis.bounds.lastNode
are the same.<div class="user-profile"><Avatar @user={{user}} /></div>export default class extends Component {didInsertElement() {let { firstNode, lastNode } = this.bounds;console.log(firstNode === lastNode); // trueconsole.log(firstNode.className); // "user-profile"}}For components with multiple root nodes,
this.bounds.firstNode
refers to the first node in the template andthis.bounds.lastNode
refers to the last:Welcome to Glimmer.js!<span>Let's build some components!</span><img src="logo.png">export default class extends Component {didInsertElement() {let { firstNode, lastNode } = this.bounds;// Walk all of the DOM siblings from the// firstNode to the lastNode and push their// nodeName into an array.let node = firstNode;let names = [firstNode.nodeName];do {node = node.nextSibling;names.push(node.nodeName);} while (node !== lastNode);console.log(names);// ["#text", "SPAN", "IMG"]}}The bounds can change if the template has dynamic content at the beginning or the end:
{{#if user.isAdmin}}<span class="warning">Admin</span>{{else}}Normal User{{/if}}In this example, the
firstNode
will change between aspan
element and aTextNode
as theuser.isAdmin
property changes.
property debugName
readonly debugName: string;
Development-mode only name of the component, useful for debugging.
property element
readonly element: HTMLElement;
The element corresponding to the main element of the component's template. The main element is the element in the template that has
...attributes
set on it:<h1>Modal</h1><div class="contents" ...attributes>{{yield}}</div>In this example,
this.element
would be thediv
with the classcontents
.You should not try to access this property until after the component's
didInsertElement()
lifecycle hook is called.
method didInsertElement
didInsertElement: () => void;
Called when the component has been inserted into the DOM. Override this function to do any set up that requires an element in the document body.
method didUpdate
didUpdate: () => void;
Called when the component has updated and rerendered itself. Called only during a rerender, not during an initial render.
Namespaces
namespace @ember/component
module '@ember/component' {}
function capabilities
capabilities: { ( version: string, opts?: { destructor?: boolean; asyncLifecycleCallbacks?: boolean } ): any; ( version: '3.13' | '3.4', capabilities: Partial<CustomComponentCapabilities> ): CustomComponentCapabilities;};
function setComponentManager
setComponentManager: { <T>(managerId: string, baseClass: T): T; <T>(managerFactory: (owner: any) => {}, baseClass: T): T; <T extends object>( factory: (owner: ApplicationInstance) => EmberGlimmerComponentManager, componentClass: T ): T; <T extends object>(name: string, componentClass: T): T;};
Package Files (4)
Dependencies (14)
- @glimmer/di
- @glimmer/env
- @glimmer/util
- broccoli-file-creator
- broccoli-merge-trees
- ember-cli-babel
- ember-cli-get-component-path-option
- ember-cli-is-package-missing
- ember-cli-normalize-entity-name
- ember-cli-path-utils
- ember-cli-string-utils
- ember-cli-typescript
- ember-cli-version-checker
- ember-compatibility-helpers
Dev Dependencies (41)
- @ember/optional-features
- @glimmer/application-test-helpers
- @glimmer/compiler
- @glimmer/interfaces
- @glimmer/resolver
- @glimmer/tracking
- @glimmer/wire-format
- @types/ember
- @types/ember__test-helpers
- @types/ember-qunit
- @types/ember-test-helpers
- @types/ember-testing-helpers
- @types/qunit
- @types/rsvp
- babel-eslint
- broccoli-asset-rev
- broccoli-funnel
- ember-ajax
- ember-cli
- ember-cli-blueprint-test-helpers
- ember-cli-dependency-checker
- ember-cli-htmlbars
- ember-cli-htmlbars-inline-precompile
- ember-cli-inject-live-reload
- ember-cli-sri
- ember-cli-uglify
- ember-decorators-polyfill
- ember-disable-prototype-extensions
- ember-export-application-global
- ember-load-initializers
- ember-maybe-import-regenerator
- ember-qunit
- ember-resolver
- ember-source
- ember-source-channel-url
- ember-try
- eslint-plugin-ember
- eslint-plugin-node
- loader.js
- qunit-dom
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@glimmer/component
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@glimmer/component)
- HTML<a href="https://www.jsdocs.io/package/@glimmer/component"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2837 ms. - Missing or incorrect documentation? Open an issue for this package.