You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
For examples of more complex component definitions, take a look at the [example components](https://github.com/pimterry/server-components/blob/master/component-examples.md)
@@ -83,15 +83,15 @@ There aren't many published sharable components to drop in quite yet, as it's st
83
83
84
84
### Top-level API
85
85
86
-
#### `components.newElement()`
86
+
#### `components.HTMLElement`
87
87
88
88
Creates a returns a new custom HTML element prototype, extending the HTMLElement prototype.
89
89
90
90
Note that this does *not* register the element. To do that, call `components.registerElement` with an element name, and options (typically including the prototype returned here as your 'prototype' value).
91
91
92
92
This is broadly equivalent to `Object.create(HTMLElement.prototype)` in browser land, and exactly equivalent here to `Object.create(components.dom.HTMLElement.prototype)`. You can call that yourself instead if you like, but it's a bit of a mouthful.
Registers an element, so that it will be used when the given element name is found during parsing.
97
97
@@ -131,9 +131,9 @@ These methods are methods you can implement on your component prototype (as retu
131
131
132
132
Any methods that are implemented, from this selection or otherwise, will be exposed on your element in the DOM during rendering. I.e. you can call `document.querySelector("my-element").setTitle("New Title")` and to call the `setTitle` method on your object, which can then potentially change how your component is rendered.
Called when an element is attached to the faux DOM.
137
137
138
138
**This is where you put your magic!** Rewrite the elements contents to dynamically generate what your users will actually see client side. Read configuration from attributes or the initial child nodes to create flexible reconfigurable reusable elements. Register for events to create elements that interact with the rest of the application structure. Build your page.
139
139
@@ -143,17 +143,13 @@ If this callback returns a promise, the rendering process will not resolve until
143
143
144
144
These callbacks are called in opening tag order, so a parent's createdCallback is called, then each of its children's, then its next sibling element.
145
145
146
-
#### `yourComponent.attachedCallback(document)`
147
-
148
-
Called when the element is attached to the DOM. This is different to when it's created when your component is being built programmatically, not through HTML parsing. *Not yet implemented*
Called when an attribute of the element is added, changed, or removed. *Not yet implemented*.
152
+
Called when an attribute of the element is added, changed, or removed. *Partially implemented;* runs on component initialization.
157
153
158
154
**So far only the createdCallback is implemented here, as the others are less relevant initially for the key simpler cases. Each of those will be coming in time though! Watch this space.**
0 commit comments