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
Copy file name to clipboardExpand all lines: 04-frameworks/06-web-components/05-shadow-root/readme.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# Shadow Root
2
2
3
-
An important aspect of custom elements is encapsulation, because a custom element, by definition, is a piece of reusable functionality: it might be dropped into any web page and be expected to work. So it's important that code running in the page should not be able to accidentally break a custom element by modifying its internal implementation. Shadow DOM enables you to attach a DOM tree to an element, and have the internals of this tree hidden from JavaScript and CSS running in the page.
3
+
An important aspect of custom elements is encapsulation, because a custom element, by definition, is a piece of reusable functionality: it might be dropped into any web page and be expected to work. So it's important that code running in the page should not be able to accidentally break a custom element by modifying its internal implementation.
4
+
5
+
`Shadow DOM` enables you to attach a DOM tree to an element, and have the internals of this tree hidden from JavaScript and CSS running in the page.
If we run our code now, we will notice that the error has gone. But the `search-bar` component, is not rendering. Well since we are exteding from `HTMLDivElement` we must refer as a `div` instead a custom element. For this purpose we can use the `is` attribute:
Copy file name to clipboardExpand all lines: 04-frameworks/06-web-components/08-life-cycle/readme.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ The DOM manipulation is something that we will align to `lifecycle callbacks`
6
6
7
7
## connectedCallback
8
8
9
-
The connectedCallback method is run whenever your element gets attached to the document, either by the HTML parser or by any JavaScript that appends it to a parent element. This is where you probably want to put most of your actual setup code, but be aware that `connectedCallback` can be run multiple times if your element is moved around.
9
+
The `connectedCallback` method is run whenever your element gets attached to the document, either by the HTML parser or by any JavaScript that appends it to a parent element. This is where you probably want to put most of your actual setup code, but be aware that `connectedCallback` can be run multiple times if your element is moved around.
10
10
11
11
Set up for HTML template and events.
12
12
13
13
## disconnectedCallback
14
14
15
-
As the name implies, this method gets called when your element is disconnected from the document. It's a good place to put any cleanup code: removing observers or event listeners that might have been added in `connectedCallback()`. Don't assume that this will be called once for each connectedCallback(), either before or after.
15
+
As the name implies, this method gets called when your element is disconnected from the document. It's a good place to put any cleanup code: removing observers or event listeners that might have been added in `connectedCallback()`. Don't assume that this will be called once for each `connectedCallback()`, either before or after.
16
16
17
17
## attributeChangedCallback
18
18
@@ -34,6 +34,20 @@ static get observedAttributes() {
Copy file name to clipboardExpand all lines: 04-frameworks/10-solid/3-LSP.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ Asumamos que nuestra clase base trabaja con una propiedad que es un int. Ahora,
141
141
142
142
- Postconditions can not be weakened in a subclass.
143
143
144
-
Asumamos el mismo escenario, pero en este caso la clase base garantiza que la propiedad sea positiva (no acepta números que no sean positivos en su setter). Y en este caso, la clase base sobreescribe el comportamiento del setter para que permita números negativos. Un código que use un getter de la propiedad asumiendo que siempre va a ser positivo (porque la clase base lo garantizaba) ahora estará roto debido a que se ha debilitado dicha restricción del getter.
144
+
Asumamos el mismo escenario, pero en este caso la clase base garantiza que la propiedad sea positiva (no acepta números que no sean positivos en su setter). Y en este caso, la subclase sobreescribe el comportamiento del setter para que permita números negativos. Un código que use un getter de la propiedad asumiendo que siempre va a ser positivo (porque la clase base lo garantizaba) ahora estará roto debido a que se ha debilitado dicha restricción del getter.
Copy file name to clipboardExpand all lines: 04-frameworks/14-qwik/02-components/readme.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
Components are declared using [component$()](https://qwik.builder.io/docs/components/overview/#component) and at a minimum need to return a JSX Element.
6
6
7
-
The trailing `$` allows the `Optimizer` to break the components into an application tree into a separate chunk so that each chunk can be loaded (or not loaded if it is not needed) independently.**Without the $ the component would be always loaded if the parent component needs to be loaded.**
7
+
The trailing `$` allows the `Optimizer` to break the components into an application tree into a separate chunk so that each chunk can be loaded (or not loaded if it is not needed) independently.**Without the `$` the component would be always loaded if the parent component needs to be loaded.**
Copy file name to clipboardExpand all lines: 04-frameworks/14-qwik/03-events/readme.md
+48-4Lines changed: 48 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ Consider the following simplified HTML of the application below.
91
91
- The `$` is a signal to the optimizer to extract the code for lazy-loading.
92
92
- The `$` is a signal to you that lazy-loading "magic" happens at this point.
93
93
- TypeScript rules ensure you don't skip any places where the `$` should appear.
94
-
2. The optimizer looks for the $ and extracts the function wrapped by $ into a separate [lazy-loadable chunk](https://qwik.builder.io/docs/advanced/optimizer/).
94
+
2. The optimizer looks for the `$` and extracts the function wrapped by `$` into a separate [lazy-loadable chunk](https://qwik.builder.io/docs/advanced/optimizer/).
95
95
3. As the server renders the page, the JSX is executed and notices that there is a click listener. The click listener is serialized into the `<button>` element as `on:click` attribute. Qwik then knows how to hook this event back up on the client.
96
96
4. Qwikloader scripts get inlined into HTML. The Qwikloader script sets up a global listener for all events in the browser. Qwikloader is about 1kb and executes in about 1ms.
97
97
5. When a user clicks on the button, the Qwikloader intercepts the event and looks for an element with `on:click` attribute.
We can see the confirmation dialog and immediately navigates to `GiTHub`. e wish to prevent this and call our callback instead. Add `preventdefault:click` to the `<a href>` to achieve this.
166
+
Let's run the app:
167
+
168
+
```bash
169
+
npm start
170
+
```
171
+
172
+
We can see the confirmation dialog and immediately navigates to `GitHub`. We wish to prevent this and call our callback instead. Add `preventdefault:click` to the `<a href>` to achieve this.
@@ -226,7 +232,45 @@ Qwik warns us what is going on:
226
232
227
233

228
234
229
-
Lets back to previous version just to remove the current warning:
235
+
## `sync$()` Restriction (BETA)
236
+
237
+
Although it stills in BETA, it's the recommended way to handle code synchrounisly. The main issue with `$sync`, **can NOT close over anything**. What are the implications of this?
238
+
239
+
- access any state: The recommended way to get the state into function is to place on element attrbutes.
240
+
- access any non-browser functions: No imports or closing over any variables or functions are allowed.
241
+
- the function should be small as it will get inlined into the resulting HTML.
242
+
243
+
Because above reasons the recomendation is to breaking up event handlers into two parts:
244
+
245
+
1.**`sync$()`** The part which must be synchronous
0 commit comments