Skip to content

Commit e5a65e9

Browse files
authored
Merge pull request #131 from javascript-tutorial/sync-5b195795
Sync with upstream @ 5b19579
2 parents 58fc23e + 33bcfb9 commit e5a65e9

File tree

17 files changed

+104
-79
lines changed

17 files changed

+104
-79
lines changed

1-js/02-first-steps/06-type-conversions/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Les conversions de types
22

3+
<<<<<<< HEAD
34
La plupart du temps, les opérateurs et les fonctions convertissent automatiquement les valeurs qui leur sont attribuées dans le bon type.
5+
=======
6+
Most of the time, operators and functions automatically convert the values given to them to the right type.
7+
>>>>>>> 5b195795da511709faf79a4d35f9c5623b6dbdbd
48
59
Par exemple, `alert` convertit automatiquement toute valeur en chaîne de caractères pour l'afficher. Les opérations mathématiques convertissent les valeurs en nombres.
610

@@ -81,6 +85,7 @@ alert( Number(false) ); // 0
8185

8286
Veuillez noter que `null` et `undefined` se comportent différemment ici : `null` devient un zéro, alors qu'`undefined` devient `NaN`.
8387

88+
<<<<<<< HEAD
8489
````smart header="L\'addition \"+\" concatène les chaînes de caractères"
8590
Presque toutes les opérations mathématiques convertissent les valeurs en nombres. A l'exception notable de l'addition `+`. Si l'une des valeurs ajoutées est une chaîne de caractères, une autre est également convertie en chaîne de caractères.
8691
@@ -93,6 +98,9 @@ alert( '1' + 2 ); // '12' (chaîne de caractères à gauche)
9398
9499
Cela ne se produit que lorsque l'un des arguments est une chaîne de caractères. Sinon, les valeurs sont converties en nombres.
95100
````
101+
=======
102+
Most mathematical operators also perform such conversion, we'll see that in the next chapter.
103+
>>>>>>> 5b195795da511709faf79a4d35f9c5623b6dbdbd
96104
97105
## Boolean Conversion
98106

1-js/02-first-steps/08-comparison/1-comparison-questions/solution.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,20 @@ null === +"\n0\n" → false
1212

1313
Quelques raisons :
1414

15+
<<<<<<< HEAD
1516
1. Évidemment, c'est vrai.
1617
2. Comparaison du dictionnaire, donc fausse.
1718
3. Encore une fois, la comparaison du dictionnaire, le premier caractère de `"2"` est plus grand que le premier caractère de` "1"`.
1819
4. Les valeurs `null` et `undefined` sont exclusivement égale entre elles.
1920
5. L'égalité stricte est stricte. Des types différents des deux côtés conduisent à `false`.
2021
6. Voir `(4)`, `null` n'est égale qu'à `undefined`.
2122
7. Egalité stricte de différents types.
23+
=======
24+
1. Obviously, true.
25+
2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`.
26+
3. Again, dictionary comparison, first char of `"2"` is greater than the first char of `"1"`.
27+
4. Values `null` and `undefined` equal each other only.
28+
5. Strict equality is strict. Different types from both sides lead to false.
29+
6. Similar to `(4)`, `null` only equals `undefined`.
30+
7. Strict equality of different types.
31+
>>>>>>> 5b195795da511709faf79a4d35f9c5623b6dbdbd

1-js/07-object-properties/01-property-descriptors/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ Object.defineProperty(obj, propertyName, descriptor)
6666
: L'objet et sa propriété pour appliquer le descripteur.
6767

6868
`descriptor`
69+
<<<<<<< HEAD
6970
: Descripteur de propriété à appliquer.
71+
=======
72+
: Property descriptor object to apply.
73+
>>>>>>> 5b195795da511709faf79a4d35f9c5623b6dbdbd
7074
7175
Si la propriété existe, `defineProperty` met à jour ses attributs. Sinon, il crée la propriété avec la valeur et les descripteurs donnés. Dans ce cas, si aucun drapeau n'est fourni, il est supposé `false`.
7276

2-ui/1-document/07-modifying-document/12-sort-table/solution.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ The solution is short, yet may look a bit tricky, so here I provide it with exte
22

33

44
```js
5-
let sortedRows = Array.from(table.rows)
6-
.slice(1)
7-
.sort((rowA, rowB) => rowA.cells[0].innerHTML > rowB.cells[0].innerHTML ? 1 : -1);
5+
let sortedRows = Array.from(table.tBodies[0].rows) // (1)
6+
.sort((rowA, rowB) => rowA.cells[0].innerHTML > rowB.cells[0].innerHTML ? 1 : -1); // (2)
87

9-
table.tBodies[0].append(...sortedRows);
8+
table.tBodies[0].append(...sortedRows); // (3)
109
```
1110

12-
1. Get all `<tr>`, like `table.querySelectorAll('tr')`, then make an array from them, cause we need array methods.
13-
2. The first TR (`table.rows[0]`) is actually a table header, so we take the rest by `.slice(1)`.
14-
3. Then sort them comparing by the content of the first `<td>` (the name field).
15-
4. Now insert nodes in the right order by `.append(...sortedRows)`.
11+
The step-by-step algorthm:
1612

17-
Tables always have an implicit `<tbody>` element, so we need to take it and insert into it: a simple `table.append(...)` would fail.
13+
1. Get all `<tr>`, from `<tbody>`.
14+
2. Then sort them comparing by the content of the first `<td>` (the name field).
15+
3. Now insert nodes in the right order by `.append(...sortedRows)`.
1816

19-
Please note: we don't have to remove them, just "re-insert", they leave the old place automatically.
17+
Please note: we don't have to remove row elements, just "re-insert", they leave the old place automatically.
18+
19+
Also note: even if the table HTML doesn't have `<tbody>`, the DOM structure always has it. So we must insert elements as `table.tBodes[0].append(...)`: a simple `table.append(...)` would fail.

2-ui/1-document/11-coordinates/3-position-at-absolute/solution.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
let box = elem.getBoundingClientRect();
2929

3030
return {
31-
top: box.top + pageYOffset,
32-
left: box.left + pageXOffset
31+
top: box.top + window.pageYOffset,
32+
left: box.left + window.pageXOffset
3333
};
3434
}
3535

2-ui/1-document/11-coordinates/4-position-inside-absolute/solution.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
let box = elem.getBoundingClientRect();
2727

2828
return {
29-
top: box.top + pageYOffset,
30-
left: box.left + pageXOffset
29+
top: box.top + window.pageYOffset,
30+
left: box.left + window.pageXOffset
3131
};
3232
}
3333

2-ui/1-document/11-coordinates/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ function getCoords(elem) {
215215
let box = elem.getBoundingClientRect();
216216
217217
return {
218-
top: box.top + pageYOffset,
219-
left: box.left + pageXOffset
218+
top: box.top + window.pageYOffset,
219+
left: box.left + window.pageXOffset
220220
};
221221
}
222222
```

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/index.html

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
<div id="tooltip" hidden>Tooltip</div>
2121

2222
<script>
23-
// for the demo
24-
setTimeout(function() {
25-
new HoverIntent({
26-
elem,
27-
over() {
28-
tooltip.style.left = elem.getBoundingClientRect().left + 5 + 'px';
29-
tooltip.style.top = elem.getBoundingClientRect().bottom + 5 + 'px';
30-
tooltip.hidden = false;
31-
},
32-
out() {
33-
tooltip.hidden = true;
34-
}
35-
});
36-
}, 2000);
23+
new HoverIntent({
24+
elem,
25+
over() {
26+
tooltip.style.left = elem.getBoundingClientRect().left + 5 + 'px';
27+
tooltip.style.top = elem.getBoundingClientRect().bottom + 5 + 'px';
28+
tooltip.hidden = false;
29+
},
30+
out() {
31+
tooltip.hidden = true;
32+
}
33+
});
3734
</script>
3835

3936
</body>

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ describe("hoverIntent", function() {
4949
}
5050
})
5151

52-
it("mouseover -> immediately no tooltip", function() {
52+
it("mouseover -> when the pointer just arrived, no tooltip", function() {
5353
mouse('mouseover', 10, 10);
5454
assert.isFalse(isOver);
5555
});
5656

57-
it("mouseover -> pause shows tooltip", function() {
57+
it("mouseover -> after a delay, the tooltip shows up", function() {
5858
mouse('mouseover', 10, 10);
5959
this.clock.tick(100);
6060
assert.isTrue(isOver);
6161
});
6262

63-
it("mouseover -> fast mouseout no tooltip", function() {
63+
it("mouseover -> followed by fast mouseout leads doesn't show tooltip", function() {
6464
mouse('mouseover', 10, 10);
6565
setTimeout(
6666
() => mouse('mouseout', 300, 300, { relatedTarget: document.body}),

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/hoverIntent.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ class HoverIntent {
4444

4545

4646
destroy() {
47+
<<<<<<< HEAD
4748
/* votre code pour "désactiver" la fonctionnalité, enlever tous les gestionnaires d’évènements*/
49+
=======
50+
/* your code to "disable" the functionality, remove all handlers */
51+
/* it's needed for the tests to work */
52+
>>>>>>> 5b195795da511709faf79a4d35f9c5623b6dbdbd
4853
}
4954

5055
}

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/index.html

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
<div id="tooltip" hidden>Tooltip</div>
2121

2222
<script>
23-
// for the demo
24-
setTimeout(function() {
25-
new HoverIntent({
26-
elem,
27-
over() {
28-
tooltip.style.left = elem.getBoundingClientRect().left + 5 + 'px';
29-
tooltip.style.top = elem.getBoundingClientRect().bottom + 5 + 'px';
30-
tooltip.hidden = false;
31-
},
32-
out() {
33-
tooltip.hidden = true;
34-
}
35-
});
36-
}, 2000);
23+
new HoverIntent({
24+
elem,
25+
over() {
26+
tooltip.style.left = elem.getBoundingClientRect().left + 5 + 'px';
27+
tooltip.style.top = elem.getBoundingClientRect().bottom + 5 + 'px';
28+
tooltip.hidden = false;
29+
},
30+
out() {
31+
tooltip.hidden = true;
32+
}
33+
});
3734
</script>
3835

3936
</body>

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@
33
describe("hoverIntent", function() {
44

55
function mouse(eventType, x, y, options) {
6-
let eventOptions = Object.assign({
6+
let eventOptions = Object.assign({
77
bubbles: true,
88
clientX: x,
99
clientY: y,
1010
pageX: x,
1111
pageY: y,
1212
target: elem
1313
}, options || {});
14-
14+
1515
elem.dispatchEvent(new MouseEvent(eventType, eventOptions));
1616
}
1717

1818

1919
let isOver;
2020
let hoverIntent;
21-
22-
21+
22+
2323
before(function() {
2424
this.clock = sinon.useFakeTimers();
2525
});
2626

2727
after(function() {
2828
this.clock.restore();
2929
});
30-
31-
30+
31+
3232
beforeEach(function() {
3333
isOver = false;
34-
34+
3535
hoverIntent = new HoverIntent({
3636
elem: elem,
3737
over: function() {
@@ -49,18 +49,18 @@ describe("hoverIntent", function() {
4949
}
5050
})
5151

52-
it("mouseover -> immediately no tooltip", function() {
52+
it("mouseover -> when the pointer just arrived, no tooltip", function() {
5353
mouse('mouseover', 10, 10);
5454
assert.isFalse(isOver);
5555
});
56-
57-
it("mouseover -> pause shows tooltip", function() {
56+
57+
it("mouseover -> after a delay, the tooltip shows up", function() {
5858
mouse('mouseover', 10, 10);
5959
this.clock.tick(100);
6060
assert.isTrue(isOver);
6161
});
6262

63-
it("mouseover -> fast mouseout no tooltip", function() {
63+
it("mouseover -> followed by fast mouseout leads doesn't show tooltip", function() {
6464
mouse('mouseover', 10, 10);
6565
setTimeout(
6666
() => mouse('mouseout', 300, 300, { relatedTarget: document.body}),
@@ -94,5 +94,5 @@ describe("hoverIntent", function() {
9494
this.clock.tick(200);
9595
assert.isFalse(isOver);
9696
});
97-
97+
9898
});

2-ui/3-event-details/4-mouse-drag-and-drop/2-drag-heroes/solution.view/soccer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ document.addEventListener('mousedown', function(event) {
77
if (!dragElement) return;
88

99
event.preventDefault();
10-
10+
1111
dragElement.ondragstart = function() {
1212
return false;
1313
};
@@ -19,7 +19,7 @@ document.addEventListener('mousedown', function(event) {
1919
function onMouseUp(event) {
2020
finishDrag();
2121
};
22-
22+
2323
function onMouseMove(event) {
2424
moveAt(event.clientX, event.clientY);
2525
}
@@ -31,9 +31,9 @@ document.addEventListener('mousedown', function(event) {
3131
if(isDragging) {
3232
return;
3333
}
34-
34+
3535
isDragging = true;
36-
36+
3737
document.addEventListener('mousemove', onMouseMove);
3838
element.addEventListener('mouseup', onMouseUp);
3939

@@ -50,10 +50,10 @@ document.addEventListener('mousedown', function(event) {
5050
if(!isDragging) {
5151
return;
5252
}
53-
53+
5454
isDragging = false;
5555

56-
dragElement.style.top = parseInt(dragElement.style.top) + pageYOffset + 'px';
56+
dragElement.style.top = parseInt(dragElement.style.top) + window.pageYOffset + 'px';
5757
dragElement.style.position = 'absolute';
5858

5959
document.removeEventListener('mousemove', onMouseMove);

2-ui/3-event-details/8-onscroll/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Voici une petite fonction pour montrer la position actuelle du défilement:
1212

1313
```js autorun
1414
window.addEventListener('scroll', function() {
15-
document.getElementById('showScroll').innerHTML = pageYOffset + 'px';
15+
document.getElementById('showScroll').innerHTML = window.pageYOffset + 'px';
1616
});
1717
```
1818

0 commit comments

Comments
 (0)