-
Notifications
You must be signed in to change notification settings - Fork 231
Node properties: type, tag and contents #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joaquinelio
merged 21 commits into
javascript-tutorial:master
from
homero304:Node-properties_type-tag-and-contents
Oct 15, 2020
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7c9c530
Node properties: type, tag and contents
omero329 07d71cc
Merge branch 'master' into Node-properties_type-tag-and-contents
omero329 b7db859
Update 2-ui/1-document/05-basic-dom-node-properties/2-tree-info/solut…
omero329 ce97b25
Update 2-ui/1-document/05-basic-dom-node-properties/3-tag-in-comment/…
omero329 79e0683
Update 2-ui/1-document/05-basic-dom-node-properties/4-where-document-…
omero329 5077fca
Update 2-ui/1-document/05-basic-dom-node-properties/4-where-document-…
omero329 10b54a5
Update 2-ui/1-document/05-basic-dom-node-properties/4-where-document-…
omero329 872e7f4
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 8e92100
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 8c3fb5b
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 79a79be
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 b54440b
Winnie-pooh
omero329 c313b2c
Merge branch 'Node-properties_type-tag-and-contents' of https://githu…
omero329 dc34f25
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 b7fd044
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 ed04f67
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 3be53c7
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 c040d70
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 2a3803b
Update 2-ui/1-document/05-basic-dom-node-properties/article.md
omero329 e79bc49
integrada -> nativa
omero329 0c5fede
Merge branch 'Node-properties_type-tag-and-contents' of https://githu…
omero329 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...1-document/05-basic-dom-node-properties/2-lastchild-nodetype-inline/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
2-ui/1-document/05-basic-dom-node-properties/2-tree-info/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,21 @@ | ||
| Let's make a loop over `<li>`: | ||
| Hagamos un ciclo sobre `<li>`: | ||
|
|
||
| ```js | ||
| for (let li of document.querySelectorAll('li')) { | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| In the loop we need to get the text inside every `li`. | ||
| En el ciclo, necesitamos introducir el texto dentro de cada `li`. | ||
|
|
||
| We can read the text from the first child node of `li`, that is the text node: | ||
| Podemos leer el texto del primer nodo hijo de `li`, que es el nodo de texto: | ||
|
|
||
| ```js | ||
| for (let li of document.querySelectorAll('li')) { | ||
| let title = li.firstChild.data; | ||
|
|
||
| // title is the text in <li> before any other nodes | ||
| // el título es el texto en <li> antes de cualquier otro nodo | ||
| } | ||
| ``` | ||
|
|
||
| Then we can get the number of descendants as `li.getElementsByTagName('li').length`. | ||
| Entonces podemos obtener el número de descendientes como `li.getElementsByTagName('li'). Length`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
...document/05-basic-dom-node-properties/4-where-document-in-hierarchy/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,40 @@ | ||
|
|
||
| We can see which class it belongs by outputting it, like: | ||
| Podemos ver a qué clase pertenece, imprimiendola, así: | ||
homero304 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```js run | ||
| alert(document); // [object HTMLDocument] | ||
| ``` | ||
|
|
||
| Or: | ||
| O: | ||
|
|
||
| ```js run | ||
| alert(document.constructor.name); // HTMLDocument | ||
| ``` | ||
|
|
||
| So, `document` is an instance of `HTMLDocument` class. | ||
| Entonces, `document` es una instancia de la clase `HTMLDocument`. | ||
|
|
||
| What's its place in the hierarchy? | ||
| ¿Cuál es su lugar en la jerarquía? | ||
|
|
||
| Yeah, we could browse the specification, but it would be faster to figure out manually. | ||
| Sí, podríamos examinar las especificaciones, pero sería más rápido averiguarlo manualmente. | ||
|
|
||
| Let's traverse the prototype chain via `__proto__`. | ||
| Recorramos la cadena de prototype través de `__proto__`. | ||
|
|
||
| As we know, methods of a class are in the `prototype` of the constructor. For instance, `HTMLDocument.prototype` has methods for documents. | ||
| Como sabemos, los métodos de una clase están en el `prototype` del constructor. Por ejemplo, `HTMLDocument.prototype` tiene métodos para documentos. | ||
|
|
||
| Also, there's a reference to the constructor function inside the `prototype`: | ||
| Además, hay una referencia a la función constructor dentro de `prototype`: | ||
|
|
||
| ```js run | ||
| alert(HTMLDocument.prototype.constructor === HTMLDocument); // true | ||
| ``` | ||
|
|
||
| To get a name of the class as a string, we can use `constructor.name`. Let's do it for the whole `document` prototype chain, till class `Node`: | ||
| Para obtener un nombre de la clase como string, podemos usar `constructor.name`. Hagámoslo para toda la cadena prototype de `document`, hasta la clase `Nodo`: | ||
homero304 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```js run | ||
| alert(HTMLDocument.prototype.constructor.name); // HTMLDocument | ||
| alert(HTMLDocument.prototype.__proto__.constructor.name); // Document | ||
| alert(HTMLDocument.prototype.__proto__.__proto__.constructor.name); // Node | ||
| ``` | ||
|
|
||
| That's the hierarchy. | ||
| Esa es la jerarquía. | ||
|
|
||
| We also could examine the object using `console.dir(document)` and see these names by opening `__proto__`. The console takes them from `constructor` internally. | ||
| También podríamos examinar el objeto usando `console.dir(document)` y ver estos nombres abriendo `__proto__`. La consola los toma del `constructor` internamente. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.