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: 1-js/01-getting-started/1-intro/article.md
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,13 +67,8 @@ Exemplos de tais restrições incluem:
67
67
68
68
Os navegadores modernos permitem que ele trabalhe com arquivos, mas o acesso é limitado e fornecido apenas se o usuário executar determinadas ações, como "dropping" de um arquivo em uma janela do navegador ou selecioná-lo por meio de uma tag `<input>`.
69
69
70
-
<<<<<<< HEAD
71
70
Existem maneiras de interagir com a câmera / microfone e outros dispositivos, mas eles exigem permissão explícita do usuário. Assim, uma página habilitada para JavaScript pode não habilmente habilitar uma câmera web, observar os arredores e enviar as informações para a [NSA](https://pt.wikipedia.org/wiki/Ag%C3%AAncia_de_Seguran%C3%A7a_Nacional).
72
71
- Diferentes abas/janelas geralmente não se conhecem mutuamente. Às vezes sim, por exemplo, quando uma janela usa JavaScript para abrir a outra. Mas mesmo neste caso, JavaScript de uma página pode não acessar a outra se eles vierem de sites diferentes (de um domínio, protocolo ou porta diferente).
73
-
=======
74
-
There are ways to interact with camera/microphone and other devices, but they require a user's explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the [NSA](https://en.wikipedia.org/wiki/National_Security_Agency).
75
-
- Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other if they come from different sites (from a different domain, protocol or port).
76
-
>>>>>>> d6e88647b42992f204f57401160ebae92b358c0d
77
72
78
73
Isso é chamado de "Política de mesma origem ". Para contornar isso, *ambas as páginas* devem conter um código JavaScript especial que lida com a troca de dados.
Copy file name to clipboardExpand all lines: 2-ui/1-document/05-basic-dom-node-properties/article.md
-32Lines changed: 0 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,13 +20,8 @@ The classes are:
20
20
21
21
-[EventTarget](https://dom.spec.whatwg.org/#eventtarget) -- is the root "abstract" class. Objects of that class are never created. It serves as a base, so that all DOM nodes support so-called "events", we'll study them later.
22
22
-[Node](http://dom.spec.whatwg.org/#interface-node) -- is also an "abstract" class, serving as a base for DOM nodes. It provides the core tree functionality: `parentNode`, `nextSibling`, `childNodes` and so on (they are getters). Objects of `Node` class are never created. But there are concrete node classes that inherit from it, namely: `Text` for text nodes, `Element` for element nodes and more exotic ones like `Comment` for comment nodes.
23
-
<<<<<<< HEAD
24
-
-[Element](http://dom.spec.whatwg.org/#interface-element) -- is a base class for DOM elements. It provides element-level navigation like `nextElementSibling`, `children` and searching methods like `getElementsByTagName`, `querySelector`. In the browser there may be not only HTML, but also XML and SVG documents. The `Element` class serves as a base for more specific classes: `SVGElement`, `XMLElement` and `HTMLElement`.
25
-
-[HTMLElement](https://html.spec.whatwg.org/multipage/dom.html#htmlelement) -- is finally the basic class for all HTML elements. It is inherited by various HTML elements:
26
-
=======
27
23
-[Element](http://dom.spec.whatwg.org/#interface-element) -- is a base class for DOM elements. It provides element-level navigation like `nextElementSibling`, `children` and searching methods like `getElementsByTagName`, `querySelector`. A browser supports not only HTML, but also XML and SVG. The `Element` class serves as a base for more specific classes: `SVGElement`, `XMLElement` and `HTMLElement`.
28
24
-[HTMLElement](https://html.spec.whatwg.org/multipage/dom.html#htmlelement) -- is finally the basic class for all HTML elements. It is inherited by concrete HTML elements:
29
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
30
25
-[HTMLInputElement](https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement) -- the class for `<input>` elements,
31
26
-[HTMLBodyElement](https://html.spec.whatwg.org/multipage/semantics.html#htmlbodyelement) -- the class for `<body>` elements,
32
27
-[HTMLAnchorElement](https://html.spec.whatwg.org/multipage/semantics.html#htmlanchorelement) -- the class for `<a>` elements
@@ -36,19 +31,12 @@ So, the full set of properties and methods of a given node comes as the result o
36
31
37
32
For example, let's consider the DOM object for an `<input>` element. It belongs to [HTMLInputElement](https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement) class. It gets properties and methods as a superposition of:
38
33
39
-
<<<<<<< HEAD
40
-
-`HTMLInputElement` -- this class provides input-specific properties, and inherits from...
41
-
-`HTMLElement` -- it provides common HTML element methods (and getters/setters) and inherits from...
42
-
-`Element` -- provides generic element methods and inherits from...
43
-
-`Node` -- provides common DOM node properties and inherits from...
44
-
=======
45
34
It gets properties and methods as a superposition of (listed in inheritance order):
46
35
47
36
-`HTMLInputElement` -- this class provides input-specific properties,
48
37
-`HTMLElement` -- it provides common HTML element methods (and getters/setters),
49
38
-`Element` -- provides generic element methods,
50
39
-`Node` -- provides common DOM node properties,
51
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
52
40
-`EventTarget` -- gives the support for events (to be covered),
53
41
- ...and finally it inherits from `Object`, so "pure object" methods like `hasOwnProperty` are also available.
54
42
@@ -325,13 +313,6 @@ Consider the example:
325
313
</script>
326
314
```
327
315
328
-
<<<<<<< HEAD
329
-
In the line `(*)` we take the full HTML of `<div>...</div>` and replace it by `<p>...</p>`. In the outer document we can see the new content instead of the `<div>`. But the old `div` variable is still the same.
330
-
331
-
The `outerHTML` assignment does not modify the DOM element, but extracts it from the outer context and inserts a new piece of HTML instead of it.
332
-
333
-
Novice developers sometimes make an error here: they modify `div.outerHTML` and then continue to work with `div` as if it had the new content in it.
334
-
=======
335
316
Looks really odd, right?
336
317
337
318
In the line `(*)` we replaced `div` with `<p>A new element</p>`. In the outer document (the DOM) we can see the new content instead of the `<div>`. But, as we can see in line `(**)`, the value of the old `div` variable hasn't changed!
@@ -342,15 +323,10 @@ So what happened in `div.outerHTML=...` is:
342
323
- `div` was removed from the document.
343
324
- Another piece of HTML `<p>A new element</p>` was inserted in its place.
344
325
- `div` still has its old value. The new HTML wasn't saved to any variable.
345
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
346
326
347
327
That's possible with `innerHTML`, but not with `outerHTML`.
348
328
349
-
<<<<<<< HEAD
350
-
We can write to `outerHTML`, but should keep in mind that it doesn't change the element we're writing to. It creates the new content on its place instead. We can get a reference to new elements by querying DOM.
351
-
=======
352
329
We can write to `elem.outerHTML`, but should keep in mind that it doesn't change the element we're writing to ('elem'). It puts the new HTML in its place instead. We can get references to the new elements by querying the DOM.
353
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
354
330
355
331
## nodeValue/data: text node content
356
332
@@ -501,11 +477,7 @@ Each DOM node belongs to a certain class. The classes form a hierarchy. The full
501
477
Main DOM node properties are:
502
478
503
479
`nodeType`
504
-
<<<<<<< HEAD
505
-
: We can get `nodeType` from the DOM object class, but often we need just to see if it is a text or element node. The `nodeType` property is good for that. It has numeric values, most important are: `1` -- for elements,`3` -- for text nodes. Read-only.
506
-
=======
507
480
: We can use it to see if a node is a text or an element node. It has a numeric value: `1` for elements,`3` for text nodes, and a few others for other node types. Read-only.
508
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
509
481
510
482
`nodeName/tagName`
511
483
: For elements, tag name (uppercased unless XML-mode). For non-element nodes `nodeName` describes what it is. Read-only.
@@ -527,8 +499,4 @@ Main DOM node properties are:
527
499
528
500
DOM nodes also have other properties depending on their class. For instance, `<input>` elements (`HTMLInputElement`) support `value`, `type`, while `<a>` elements (`HTMLAnchorElement`) support `href` etc. Most standard HTML attributes have a corresponding DOM property.
529
501
530
-
<<<<<<< HEAD
531
-
But HTML attributes and DOM properties are not always the same, as we'll see in the next chapter.
532
-
=======
533
502
However, HTML attributes and DOM properties are not always the same, as we'll see in the next chapter.
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/1-form-elements/article.md
-20Lines changed: 0 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,28 +167,18 @@ input.checked = true; // for a checkbox or radio button
167
167
```
168
168
169
169
```warn header="Use `textarea.value`, not `textarea.innerHTML`"
170
-
<<<<<<< HEAD
171
-
Please note that we should never use `textarea.innerHTML`: it stores only the HTML that was initially on the page, not the current value.
172
-
=======
173
170
Please note that even though `<textarea>...</textarea>` holds its value as nested HTML, we should never use `textarea.innerHTML` to access it.
174
171
175
172
It stores only the HTML that was initially on the page, not the current value.
176
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
177
173
```
178
174
179
175
### select and option
180
176
181
177
A `<select>` element has 3 important properties:
182
178
183
-
<<<<<<< HEAD
184
-
1. `select.options` -- the collection of `<option>` elements,
185
-
2. `select.value` -- the value of the chosen option,
186
-
3. `select.selectedIndex` -- the number of the selected option.
187
-
=======
188
179
1. `select.options` -- the collection of `<option>` subelements,
189
180
2. `select.value` -- the value of the currently selected `<option>`,
190
181
3. `select.selectedIndex` -- the number of the currently selected `<option>`.
191
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
192
182
193
183
They provide three different ways of setting a value for a `<select>`:
194
184
@@ -242,13 +232,9 @@ The full specification of the `<select>` element is available at <https://html.s
242
232
243
233
### new Option
244
234
245
-
<<<<<<< HEAD
246
-
In the specification of [the option element](https://html.spec.whatwg.org/multipage/forms.html#the-option-element) there's a nice short syntax to create `<option>` elements:
247
-
=======
248
235
This is rarely used on its own. But there's still an interesting thing.
249
236
250
237
In the [specification](https://html.spec.whatwg.org/multipage/forms.html#the-option-element) there's a nice short syntax to create `<option>` elements:
251
-
>>>>>>> e074a5f825a3d10b0c1e5e82561162f75516d7e3
252
238
253
239
```js
254
240
option = new Option(text, value, defaultSelected, selected);
@@ -306,14 +292,8 @@ Form navigation:
306
292
307
293
Value is available as `input.value`, `textarea.value`, `select.value` etc, or `input.checked` for checkboxes and radio buttons.
308
294
309
-
<<<<<<< HEAD
310
-
For `<select>` we can also get the value by the index `select.selectedIndex` or through the options collection `select.options`. The full specification of this and other elements is at <https://html.spec.whatwg.org/multipage/forms.html>.
311
-
312
-
These are the basics to start working with forms. In the next chapter we'll cover `focus` and `blur` events that may occur on any element, but are mostly handled on forms.
313
-
=======
314
295
For `<select>` we can also get the value by the index `select.selectedIndex` or through the options collection `select.options`.
315
296
316
297
These are the basics to start working with forms. We'll meet many examples further in the tutorial.
317
298
318
299
In the next chapter we'll cover `focus` and `blur` events that may occur on any element, but are mostly handled on forms.
0 commit comments