Skip to content

Commit 35f4aaf

Browse files
authored
Mention that custom elements constructors can't be directly called (#41069)
* Mention that custom elements constructors can't be directly called * Rewrite
1 parent 4b9ef80 commit 35f4aaf

File tree

1 file changed

+7
-1
lines changed
  • files/en-us/web/api/web_components/using_custom_elements

1 file changed

+7
-1
lines changed

files/en-us/web/api/web_components/using_custom_elements/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ There are two types of custom element:
2121
> [!NOTE]
2222
> Safari does not plan to support customized built-in elements. See the [`is` attribute](/en-US/docs/Web/HTML/Reference/Global_attributes/is) for more information.
2323
24+
For both kinds of custom element, the basic steps to create and use them are the same:
25+
26+
- You first [implement its behavior](#implementing_a_custom_element) by defining a JavaScript class.
27+
- You then [register the custom element](#registering_a_custom_element) to the current page.
28+
- Finally, you can [use the custom element](#using_a_custom_element) in your HTML or JavaScript code.
29+
2430
## Implementing a custom element
2531

26-
A custom element is implemented as a [class](/en-US/docs/Web/JavaScript/Reference/Classes) which extends {{domxref("HTMLElement")}} (in the case of autonomous elements) or the interface you want to customize (in the case of customized built-in elements).
32+
A custom element is implemented as a [class](/en-US/docs/Web/JavaScript/Reference/Classes) which extends {{domxref("HTMLElement")}} (in the case of autonomous elements) or the interface you want to customize (in the case of customized built-in elements). This class will not be called by you, but will be called by the browser. Immediately after defining the class, you should [register](#registering_a_custom_element) the custom element, so you can create instances of it using standard DOM practices, such as writing the element in HTML markup, calling {{domxref("document.createElement()")}}, etc.
2733

2834
Here's the implementation of a minimal custom element that customizes the {{HTMLElement("p")}} element:
2935

0 commit comments

Comments
 (0)