SEARCH
You are in browse mode. You must login to use MEMORY

   Log in to start

Lit / Web Components


🇬🇧
In English
Created:
Lit / Web Components


Public
Created by:
John Pencola


0 / 5  (0 ratings)



» To start learning, click login

1 / 22

[Front]


Name the five custom element lifecycle methods
[Back]


1. constructor 2. connectedCallback 3. disconnectedCallback 4. attributeChangedCallback 5. adoptedCallback

Practice Known Questions

Stay up to date with your due questions

Complete 5 questions to enable practice

Exams

Exam: Test your skills

Exam mode unavailable

Learn New Questions

Dynamic Modes

SmartIntelligent mix of all modes
CustomUse settings to weight dynamic modes

Manual Mode [BETA]

Select your own question and answer types
Specific modes

Learn with flashcards

Lit / Web Components - Leaderboard

The course owner has disabled public visibility of the leaderboard for this course.


Lit / Web Components - Details

Levels:

Questions:

22 questions
🇬🇧🇬🇧
Name the five custom element lifecycle methods
1. constructor 2. connectedCallback 3. disconnectedCallback 4. attributeChangedCallback 5. adoptedCallback
What are the two events which trigger a reactive update cycle?
When a reactive property changes or when the requestUpdate() method is explicitly called
After a Lit component executes an #update, which is called first, #updated or #firstUpdated?
#firstUpdated. Called after the component's DOM has been updated the first time, immediately before #updated is called.
Which Lit update cycle method would you use to determine when an update is complete?
#updateComplete. The updateComplete Promise resolves when the element has finished updating. Use updateComplete to wait for an update.
What are the differences between public reactive properties and internal reactive state?
Opposed to public reactive props, internal reactive state props are not part of the component's public API. These state properties don't have corresponding attributes, and aren't intended to be used from outside the component. Internal reactive state should be set by the component itself.
What three benefits does the shadow DOM provide?
1. DOM Scoping 2. Style scoping 3. Composition
What can a component’s #render method return?
TemplateResult objects, Primitive values, DOM nodes, Arrays or iterables of any supported types.
Which Lit API is used to access nodes in a components' shadow DOM?
RenderRoot Note: renderRoot is only accessible starting with the firstUpdated lifecycle stage.
True or false, the firstUpdated lifecycle callback fires before the browser has had a chance to paint.
True. Note: To ensure that code in firstUpdated is added after the user can see the component, you can await a Promise that resolves after the browser paints.
Since events dispatched inside a shadowRoot are not visible outside that root, what can be done to make an event pass through the shadow DOM boundary?
Set the "composed" property to "true". Note: It's common to pair composed with bubbles so that all nodes in the DOM tree can see the event:
How can multiple slots be used in a single template?
They must be "named", e.g., <slot name="heading">
Which function can be used to customize change detection on a reactive property?
#hasChanged Note: All reactive properties have this function, which is called when a property is set. By default it does a strict equality check
Describe what the "nothing" sentinel value does.
Nothing is a sentinel value that signals a ChildPart to fully clear its content. eg: const button = html`${ user.isAdmin ? html`<button>DELETE</button>` : nothing }`;
Describe a Reactive Controller.
A Reactive Controller is an object that can hook into the update lifecycle of a Lit component, encapsulating state and behavior related to a feature into a separate unit of code. You should think of a Reactive Controller as a "has-a" relationship to the component which uses it.
Describe a Class Mixin.
A Mixin is an abstract subclass; i.e. a subclass definition that may be applied to different superclasses to create a related family of modified classes. You should think of a Mixin as an "is-a" relationship to the component which subclasses it.
But does not bubble
The element that dispatches the event the host element containing the shadow root