ExamGecko
Question list
Search
Search

Question 217 - Certified B2B Commerce Developer discussion

Report
Export

A developer used slots to pass content from one Lightning Web Component to another. How can they access the.

DOM for what was passed to those slots?

A.
Call this.template.querySelector() and this.template.querySelectorAll()
Answers
A.
Call this.template.querySelector() and this.template.querySelectorAll()
B.
Call this.querySelector() passing an id
Answers
B.
Call this.querySelector() passing an id
C.
Call this.querySelector() and this.querySelectorAll()
Answers
C.
Call this.querySelector() and this.querySelectorAll()
D.
Call this.template.querySelector() passing an id
Answers
D.
Call this.template.querySelector() passing an id
Suggested answer: A

Explanation:

In Lightning Web Components, to access the DOM elements within the component's template, including those passed into slots, developers use this.template.querySelector() and this.template.querySelectorAll(). These methods allow for querying the component's local DOM. Direct DOM manipulation or querying outside the component's template is discouraged to maintain component encapsulation and security. For more information, see the Salesforce LWC documentation on accessing the DOM: Salesforce LWC DOM Access Documentation.

asked 23/09/2024
Jesserey Joseph
44 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first