Skip to content

Commit b9fa58d

Browse files
authored
Merge pull request #279 from afilahkle/master
Walking the DOM
2 parents 488f225 + d5fc65a commit b9fa58d

File tree

7 files changed

+181
-181
lines changed

7 files changed

+181
-181
lines changed
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
There are many ways, for instance:
1+
هناك العديد من الطرق، على سبيل المثال:
22

3-
4-
The `<div>` DOM node:
3+
عقدة `<DOM <div`:
54

65
```js
7-
document.body.firstElementChild
8-
// or
9-
document.body.children[0]
10-
// or (the first node is space, so we take 2nd)
11-
document.body.childNodes[1]
6+
document.body.firstElementChild;
7+
// أو
8+
document.body.children[0];
9+
// أو (العقدة الأولى هي المسافة، لذلك نأخذ الثانية)
10+
document.body.childNodes[1];
1211
```
1312

14-
The `<ul>` DOM node:
13+
عقدة `<DOM <ul`:
1514

1615
```js
17-
document.body.lastElementChild
18-
// or
19-
document.body.children[1]
16+
document.body.lastElementChild;
17+
// أو
18+
document.body.children[1];
2019
```
2120

22-
The second `<li>` (with Pete):
21+
العنصر `<li>` الثاني (مع Pete):
2322

2423
```js
25-
// get <ul>, and then get its last element child
26-
document.body.lastElementChild.lastElementChild
24+
// احصل على <ul>، ثم احصل على آخر عنصر فرعي له
25+
document.body.lastElementChild.lastElementChild;
2726
```

2-ui/1-document/03-dom-navigation/1-dom-children/task.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ importance: 5
22

33
---
44

5-
# DOM children
5+
# اطفال ال DOM
66

7-
Look at this page:
7+
انظر إلى هذه الصفحة:
88

99
```html
1010
<html>
11-
<body>
12-
<div>Users:</div>
13-
<ul>
14-
<li>John</li>
15-
<li>Pete</li>
16-
</ul>
17-
</body>
11+
<body>
12+
<div>المستخدمون:</div>
13+
<ul>
14+
<li>جون</li>
15+
<li>بيت</li>
16+
</ul>
17+
</body>
1818
</html>
1919
```
2020

21-
For each of the following, give at least one way of how to access them:
22-
- The `<div>` DOM node?
23-
- The `<ul>` DOM node?
24-
- The second `<li>` (with Pete)?
21+
لكل من التالي، أعطِ طريقة واحدة على الأقل لكيفية الوصول إليها:
22+
23+
- عقدة `<DOM <div`؟
24+
- عقدة `<DOM <ul`؟
25+
- العنصر `<li>` الثاني (مع Pete)؟
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
1. Yes, true. The element `elem.lastChild` is always the last one, it has no `nextSibling`.
2-
2. No, wrong, because `elem.children[0]` is the first child *among elements*. But there may exist non-element nodes before it. So `previousSibling` may be a text node.
1+
1. نعم، صحيح. العنصر `elem.lastChild` هو دائمًا الأخير، ولا يوجد له `nextSibling`.
2+
2. لا، خطأ، لأن `elem.children[0]` هو الطفل الأول _بين العناصر_. ولكن قد توجد عقد غير عنصرية قبله. لذلك قد يكون `previousSibling` عقدة نصية.
33

4-
Please note: for both cases if there are no children, then there will be an error.
4+
يرجى الملاحظة: في كلا الحالتين إذا لم يكن هناك أطفال، فسيكون هناك خطأ.
55

6-
If there are no children, `elem.lastChild` is `null`, so we can't access `elem.lastChild.nextSibling`. And the collection `elem.children` is empty (like an empty array `[]`).
6+
إذا لم يكن هناك أطفال، فإن `elem.lastChild` هو `null`، لذلك لا يمكننا الوصول إلى `elem.lastChild.nextSibling`. ومجموعة `elem.children` فارغة (مثل مصفوفة فارغة `[]`).

2-ui/1-document/03-dom-navigation/3-navigation-links-which-null/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# The sibling question
5+
# سؤال الأشقاء
66

7-
If `elem` -- is an arbitrary DOM element node...
7+
إذا كان `elem` -- هو عقدة DOM عنصرية عشوائية...
88

9-
- Is it true that `elem.lastChild.nextSibling` is always `null`?
10-
- Is it true that `elem.children[0].previousSibling` is always `null` ?
9+
- هل صحيح أن `elem.lastChild.nextSibling` هو دائمًا `null`؟
10+
- هل صحيح أن `elem.children[0].previousSibling` هو دائمًا `null`؟
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
We'll be using `rows` and `cells` properties to access diagonal table cells.
1+
سنستخدم خصائص `rows` و `cells` للوصول إلى الخلايا القطرية في الجدول.

2-ui/1-document/03-dom-navigation/4-select-diagonal-cells/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 5
22

33
---
44

5-
# Select all diagonal cells
5+
# حدد كل الخلايا القطرية
66

7-
Write the code to paint all diagonal table cells in red.
7+
اكتب الكود لتلوين كل الخلايا القطرية في الجدول باللون الأحمر.
88

9-
You'll need to get all diagonal `<td>` from the `<table>` and paint them using the code:
9+
سوف تحتاج إلى الحصول على كل `<td>` قطرية من `<table>` وتلوينها باستخدام الكود:
1010

1111
```js
12-
// td should be the reference to the table cell
12+
// يجب أن يكون td مرجعًا لخلية الجدول
1313
td.style.backgroundColor = 'red';
1414
```
1515

16-
The result should be:
16+
يجب أن يكون النتيجة:
1717

1818
[iframe src="solution" height=180]

0 commit comments

Comments
 (0)