|
6 | 6 | # Component |
7 | 7 |
|
8 | 8 | > **Low-level interface** - Component developers will typically |
9 | | -only need to use the `name="..."` attribute on *Component*, |
10 | | -and sometimes `mode="vanish-into-document"` for page-level |
11 | | -components. Similarly, none of the `renderObj.component` properties |
12 | | -are typically useful for component developers. Instead, they are used |
13 | | -internally by CParts (notably *Template*) in order to move along the |
14 | | -rendering cycle. |
| 9 | +only need to use the `name="..."` attribute on *Component*. Similarly, none of |
| 10 | +the `renderObj.component` properties are typically useful for component |
| 11 | +developers. Instead, they are used internally by CParts (notably *Template*) in |
| 12 | +order to move along the rendering cycle. |
15 | 13 |
|
16 | 14 | The *Component* definition is the most central to Modulo. It's how we register |
17 | 15 | components to be mounted on the page, and define the CParts that go inside |
@@ -138,12 +136,13 @@ <h3>To Do example:</h3> |
138 | 136 | render mode of this component. This changes what is considered to be the root |
139 | 137 | of the element, and thus where the content of the Template goes during |
140 | 138 | reconciliation. In "regular" and "vanish", it's the custom component itself |
141 | | -(which will be removed after rendering with "vanish"), in "shadow", it uses an |
142 | | -attached shadow DOM as the root, and with "vanish-into-document" it replaces |
143 | | -the entire page. This allows you to isolate outside CSS from your component |
144 | | -using "shadow", do one-time renders only with "vanish", or make your component |
145 | | -replace the entire document with "vanish-into-document". A detailed discussion |
146 | | -of valid options are below: |
| 139 | +(which will be removed after rendering with "vanish"), and in "shadow", it uses an |
| 140 | +attached shadow DOM as the root. This allows you to isolate outside CSS from |
| 141 | +your component using "shadow" or do one-time renders only with "vanish". |
| 142 | + |
| 143 | + |
| 144 | +A detailed discussion of valid options are below: |
| 145 | + |
147 | 146 | * `mode="regular"` - The default behavior, where the content generated by this |
148 | 147 | the element will be attached to the regular DOM, as the element itself. This |
149 | 148 | means that CSS stylesheets attached the normal way (e.g. with a "link" tag) |
@@ -181,21 +180,6 @@ <h3>To Do example:</h3> |
181 | 180 | generators, when you just want to generate plain HTML, with no Modulo JS or |
182 | 181 | behavior in the end. |
183 | 182 |
|
184 | | -* `mode="vanish-into-document"` - This setting is useful in one situation: When |
185 | | - you want to create a "page" level component that changes tags that belong in |
186 | | - the document head, such as `<title>`. Like with `mode="vanish"` |
187 | | - described above, setting this will cause the component to remove itself after |
188 | | - the first time it renders. However, with vanish-into-document, it will |
189 | | - instead replace the entire page. It will also attempt to correctly insert |
190 | | - all tags that belong in the document head (meta, title, link, script to be |
191 | | - specific), causing link and script tags alike (e.g. `<script |
192 | | - src=".."></script>`) to load. Finally, the document will be wiped, |
193 | | - and anything else it finds will be put directly into the document's body, for |
194 | | - a clean DOM structure that removes itself entirely during this "one-time |
195 | | - render". |
196 | | - * *DEPRECATION NOTICE* - `vanish-into-document` may be removed, and |
197 | | - simply `vanish` will also support insertion to head |
198 | | - |
199 | 183 | * `mode="custom-root"` - This is rarely useful, but allows for setting some |
200 | 184 | other DOM element as the new root element for the component to target for |
201 | 185 | rendering it's content. This is done by assigning a value to |
@@ -225,12 +209,10 @@ <h3>To Do example:</h3> |
225 | 209 | `{this.props.children}`.) For more on the slot interface, see Mozilla's |
226 | 210 | [The Web Component Slot element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot) |
227 | 211 |
|
228 | | -Note that Modulo uses this interface for both `mode="shadow"` (e.g. using |
229 | | -`shadowRoot` as the root element for reconciliation) and all the other DOM |
230 | | -rendering modes (e.g. `mode="regular"`, `mode="vanish-into-document"`). For |
231 | | -Shadow DOM, it will fall-back on Browser behavior. For everything else, it will |
232 | | -detach any nodes it finds and reattach the nodes just before the beginning of |
233 | | -the reconciliation process (it's DOM load-directive). |
| 212 | +Note that Modulo components can even use this without using shadow rendering |
| 213 | +(e.g. `mode="shadow"`). Modulo will attempt to simulate the Shadow DOM |
| 214 | +Behavior: it will detach any nodes it finds and reattach the nodes just before |
| 215 | +the beginning of the reconciliation process (it's DOM load-directive). |
234 | 216 |
|
235 | 217 | ### Defaults |
236 | 218 |
|
@@ -298,3 +280,20 @@ <h1><slot name="topTitle">Picture</slot></h1> |
298 | 280 | </x-PhotoFrame> |
299 | 281 | ``` |
300 | 282 |
|
| 283 | +### Deprecated features |
| 284 | + |
| 285 | + |
| 286 | +* *Alpha 73 - Deprecated, do not use in new projects:* |
| 287 | + `mode="vanish-into-document"` - This setting is useful in one situation: When |
| 288 | + you want to create a "page" level component that changes tags that belong in |
| 289 | + the document head, such as `<title>`. Like with `mode="vanish"` |
| 290 | + described above, setting this will cause the component to remove itself after |
| 291 | + the first time it renders. However, with vanish-into-document, it will |
| 292 | + instead replace the entire page. It will also attempt to correctly insert |
| 293 | + all tags that belong in the document head (meta, title, link, script to be |
| 294 | + specific), causing link and script tags alike (e.g. `<script |
| 295 | + src=".."></script>`) to load. Finally, the document will be wiped, |
| 296 | + and anything else it finds will be put directly into the document's body, for |
| 297 | + a clean DOM structure that removes itself entirely during this "one-time |
| 298 | + render". |
| 299 | + |
0 commit comments