diff --git a/2-ui/1-document/03-dom-navigation/article.md b/2-ui/1-document/03-dom-navigation/article.md
index b5f03098c..b5a7f2fc0 100644
--- a/2-ui/1-document/03-dom-navigation/article.md
+++ b/2-ui/1-document/03-dom-navigation/article.md
@@ -1,333 +1,344 @@
libs:
- - d3
- - domtree
----
+- d3
+- domtree
+---
-# Walking the DOM
+# Menelusuri DOM
-The DOM allows us to do anything with elements and their contents, but first we need to reach the corresponding DOM object.
+DOM memungkinkan kita untuk melakukan apapun dengan elemen-elemen dan isinya, tetapi pertama-tama kita perlu mencapai objek DOM yang sesuai.
-All operations on the DOM start with the `document` object. That's the main "entry point" to DOM. From it we can access any node.
+Semua operasi pada DOM dimulai dengan objek `document`. Itulah "titik masuk" utama ke DOM. Dari objek tersebut, kita dapat mengakses setiap node (simpul).
-Here's a picture of links that allow for travel between DOM nodes:
+Berikut adalah gambar tautan yang memungkinkan untuk berpindah antara simpul-simpul DOM):

-Let's discuss them in more detail.
-
-## On top: documentElement and body
-
-The topmost tree nodes are available directly as `document` properties:
-
-`` = `document.documentElement`
-: The topmost document node is `document.documentElement`. That's the DOM node of the `` tag.
-
-`
` = `document.body`
-: Another widely used DOM node is the `` element -- `document.body`.
-
-`` = `document.head`
-: The `` tag is available as `document.head`.
-
-````warn header="There's a catch: `document.body` can be `null`"
-A script cannot access an element that doesn't exist at the moment of running.
-
-In particular, if a script is inside ``, then `document.body` is unavailable, because the browser did not read it yet.
+Mari kita bahas lebih detail.
-So, in the example below the first `alert` shows `null`:
+## Di Puncak: documentElement dan body
-```html run
-
+Simpul paling atas dari struktur pohon tersedia langsung sebagai properti dari `document`:
-
-
-
+`` = `document.documentElement` : Simpul dokumen paling atas adalah `document.documentElement`. Itu adalah simpul DOM dari tag ``.
-
+`` = `document.body` : Simpul DOM lain yang sering digunakan adalah elemen `` -- `document.body`.
-
+`` = `document.head` : Tag `` tersedia sebagai `document.head`.
-
-
-```
-````
+> **PERINGATAN: Tapi, ada pengecualian: `document.body` bisa saja `null`.**
+>
+> Sebuah skrip tidak dapat mengakses elemen yang belum ada pada saat dijalankan.
+>
+> Khususnya, jika sebuah skrip berada di dalam tag ``, maka `document.body` tidak tersedia, karena browser (peramban) belum membacanya.
+>
+> Jadi, pada contoh di bawah ini, `alert` pertama akan menampilkan `null`:
+>
+> ```html run
+>
+>
+>
+>
+>
+>
+>
+>
+>
+> ```
-```smart header="In the DOM world `null` means \"doesn't exist\""
-In the DOM, the `null` value means "doesn't exist" or "no such node".
-```
+> **Dalam dunia DOM, `null` berarti \"Tidak ada yang eksis.\"**
+> Dalam DOM, nilai `null` berarti "tidak ada" atau "tidak ada simpul tersebut".
-## Children: childNodes, firstChild, lastChild
+## Anak-anak (Children): childNodes, firstChild, lastChild
-There are two terms that we'll use from now on:
+Ada dua istilah yang akan kita gunakan mulai sekarang:
-- **Child nodes (or children)** -- elements that are direct children. In other words, they are nested exactly in the given one. For instance, `` and `` are children of `` element.
-- **Descendants** -- all elements that are nested in the given one, including children, their children and so on.
+- **Simpul anak (Child nodes) atau Anak-anak (Children)** -- elemen-elemen yang merupakan anak langsung. Dengan kata lain, mereka bersarang tepat di dalam elemen yang diberikan. Misalnya, `` dan `` merupakan anak-anak dari elemen ``.
+- **Keturunan (Descendants)** -- semua elemen yang bersarang di dalam elemen yang diberikan, termasuk anak-anak mereka, cucu-cucu mereka, dan seterusnya.
-For instance, here `` has children `
` and `
` (and few blank text nodes):
+Misalnya, di sini `` memiliki anak-anak berupa `
` dan `
` (dan beberapa simpul teks kosong):
```html run
-
-
Begin
-
-
-
- Information
-
-
-
+
+
Mulai
+
+
+
+ Informasi
+
+
+
```
-...And descendants of `` are not only direct children `
`, `
` but also more deeply nested elements, such as `
` (a child of `
`) and `` (a child of `
`) -- the entire subtree.
+... Dan keturunan (descendants) dari `` tidak hanya anak langsung `
`, `
`, tetapi juga elemen-elemen yang bersarang lebih dalam, seperti `
` (anak dari `
`) dan `` (anak dari `
`) -- seluruh sub-pohon.
-**The `childNodes` collection lists all child nodes, including text nodes.**
+**Koleksi `childNodes` mencantumkan semua simpul anak, termasuk simpul teks.**
-The example below shows children of `document.body`:
+Contoh di bawah ini menampilkan anak-anak dari `document.body`:
```html run
-
-
Begin
-
-
-
Information
-
-
-
End
-
-
- ...more stuff...
-
+
+
Mulai
+
+
+
Informasi
+
+
+
Akhir
+
+
+ ...lebih banyak hal...
+
```
-Please note an interesting detail here. If we run the example above, the last element shown is `
+>
+> ```
-Please, don't. The `for..in` loop iterates over all enumerable properties. And collections have some "extra" rarely used properties that we usually do not want to get:
+## Saudara kandung (siblings) dan orang tua (parent)
-```html run
-
-
-
-````
-
-## Siblings and the parent
+_Saudara kandung_ adalah simpul-simpul yang merupakan anak-anak dari orang tua yang sama.
-*Siblings* are nodes that are children of the same parent.
-
-For instance, here `` and `` are siblings:
+Misalnya, di sini `` dan `` adalah saudara kandung:
```html
- ......
+
+ ...
+
+
+ ...
+
```
-- `` is said to be the "next" or "right" sibling of ``,
-- `` is said to be the "previous" or "left" sibling of ``.
+- `` disebut sebagai saudara "berikutnya" atau "kanan" dari ``,
+- `` disebut sebagai saudara "sebelumnya" atau "kiri" dari ``.
-The next sibling is in `nextSibling` property, and the previous one - in `previousSibling`.
+Saudara berikutnya dapat diakses melalui properti `nextSibling`, dan saudara sebelumnya melalui properti `previousSibling`.
-The parent is available as `parentNode`.
+Orang tua dari suatu simpul dapat diakses menggunakan properti `parentNode`.
-For example:
+Contohnya:
```js run
-// parent of is
-alert( document.body.parentNode === document.documentElement ); // true
+// Orang tua dari adalah
+alert(document.body.parentNode === document.documentElement); // true (benar)
-// after goes
-alert( document.head.nextSibling ); // HTMLBodyElement
+// Setelah ada
+alert(document.head.nextSibling); // HTMLBodyElement
-// before goes
-alert( document.body.previousSibling ); // HTMLHeadElement
+// Sebelum ada
+alert(document.body.previousSibling); // HTMLHeadElement
```
-## Element-only navigation
+## Navigasi Hanya untuk Elemen
-Navigation properties listed above refer to *all* nodes. For instance, in `childNodes` we can see both text nodes, element nodes, and even comment nodes if they exist.
+Properti-navigasi yang telah disebutkan sebelumnya merujuk pada semua simpul. Misalnya, dalam `childNodes` kita bisa melihat baik simpul teks, simpul elemen, dan bahkan simpul komentar jika ada.
-But for many tasks we don't want text or comment nodes. We want to manipulate element nodes that represent tags and form the structure of the page.
+Namun, untuk banyak tugas, kita tidak tertarik pada simpul teks atau komentar. Kita ingin memanipulasi simpul elemen yang mewakili tag dan membentuk struktur halaman.
-So let's see more navigation links that only take *element nodes* into account:
+Oleh karena itu, mari kita lihat lebih banyak tautan navigasi yang hanya memperhatikan _simpul elemen_:

-The links are similar to those given above, just with `Element` word inside:
-
-- `children` -- only those children that are element nodes.
-- `firstElementChild`, `lastElementChild` -- first and last element children.
-- `previousElementSibling`, `nextElementSibling` -- neighbor elements.
-- `parentElement` -- parent element.
+Tautan-tautan tersebut mirip dengan yang telah disebutkan sebelumnya, hanya dengan tambahan kata `Element`:
+
+- `children` -- hanya mencakup anak-anak yang merupakan simpul elemen.
+- `firstElementChild`, `lastElementChild` -- anak-anak elemen pertama dan terakhir.
+- `previousElementSibling`, `nextElementSibling` -- elemen tetangga.
+- `parentElement` -- elemen orang tua.
+
+> **Mengapa `parentElement`? Apakah orang tua bisa _tidak_ berupa elemen?**
+>
+> Properti `parentElement` mengembalikan "elemen" orang tua, sedangkan `parentNode` mengembalikan "semua simpul" orang tua. Biasanya, kedua properti tersebut akan mengambil orang tua yang sama.
+>
+> Dengan satu pengecualian yaitu `document.documentElement`:
+>
+> ```js run
+> alert(document.documentElement.parentNode); // document
+> alert(document.documentElement.parentElement); // null
+> ```
+>
+> Alasannya adalah bahwa simpul akar (root) `document.documentElement` (``) memiliki `document` sebagai orang tua. Namun, `document` bukanlah sebuah simpul elemen, sehingga `parentNode` mengembalikan `document`, sementara `parentElement` tidak.
+>
+> Detail ini bisa berguna ketika kita ingin bergerak dari suatu elemen sembarang `elem` ke ``, tapi tidak ingin sampai pada `document`:
+>
+> ```js
+> while ((elem = elem.parentElement)) {
+> // bergerak naik hingga mencapai
+> alert(elem);
+> }
+> ```
+
+Mari kita modifikasi salah satu contoh di atas: gantikan `childNodes` dengan `children`. Sekarang hanya akan menampilkan elemen-elemen:
-````smart header="Why `parentElement`? Can the parent be *not* an element?"
-The `parentElement` property returns the "element" parent, while `parentNode` returns "any node" parent. These properties are usually the same: they both get the parent.
-
-With the one exception of `document.documentElement`:
-
-```js run
-alert( document.documentElement.parentNode ); // document
-alert( document.documentElement.parentElement ); // null
+```html run
+
+
+
Mulai
+
+
+
Informasi
+
+
+
Akhir
+
+
+ ...
+
+
```
-The reason is that the root node `document.documentElement` (``) has `document` as its parent. But `document` is not an element node, so `parentNode` returns it and `parentElement` does not.
+## Tautan-tautan Tambahan: Tabel [#dom-navigation-tables]
-This detail may be useful when we want to travel up from an arbitrary element `elem` to ``, but not to the `document`:
-```js
-while(elem = elem.parentElement) { // go up till
- alert( elem );
-}
-```
-````
+Hingga saat ini, kita telah menjelaskan properti-properti navigasi dasar.
-Let's modify one of the examples above: replace `childNodes` with `children`. Now it shows only elements:
+Terdapat beberapa jenis elemen DOM yang mungkin menyediakan properti tambahan, khusus untuk jenisnya, untuk kemudahan.
-```html run
-
-
-
Begin
-
-
-
Information
-
-
-
End
-
-
- ...
-
-
-```
+Tabel adalah contoh yang bagus untuk hal ini, dan merupakan kasus yang cukup penting:
-## More links: tables [#dom-navigation-tables]
+**Elemen `
`** mendukung (selain dari yang dijelaskan di atas) properti-properti berikut:
-Till now we described the basic navigation properties.
+- `table.rows` -- koleksi elemen-elemen `
` dari tabel.
+- `table.caption/tHead/tFoot` -- referensi ke elemen `
`, `
`, `
`.
+- `table.tBodies` -- koleksi elemen-elemen `` (bisa banyak sesuai standar, tetapi minimal akan ada satu -- bahkan jika tidak ada dalam sumber HTML, peramban akan menambahkannya dalam DOM).
-Certain types of DOM elements may provide additional properties, specific to their type, for convenience.
+**Elemen ``, ``, ``** menyediakan properti `rows`:
-Tables are a great example of that, and represent a particularly important case:
+- `tbody.rows` -- koleksi elemen-elemen `
` di dalamnya.
-**The `
`** element supports (in addition to the given above) these properties:
-- `table.rows` -- the collection of `
` elements of the table.
-- `table.caption/tHead/tFoot` -- references to elements `
`, `
`, `
`.
-- `table.tBodies` -- the collection of `` elements (can be many according to the standard, but there will always be at least one -- even if it is not in the source HTML, the browser will put it in the DOM).
+**Elemen `
`:**
-**``, `
`, ``** elements provide the `rows` property:
-- `tbody.rows` -- the collection of `
` inside.
+- `tr.cells` -- koleksi sel-sel dari `
` dan `
` di dalam `
` yang diberikan.
+- `tr.sectionRowIndex` -- posisi (indexs) dari elemen `
` tertentu di dalam elemen `/
/` yang melingkupinya.
+- `tr.rowIndex` -- nomor dari elemen `
` di dalam tabel secara keseluruhan (termasuk semua baris tabel).
-**`
`:**
-- `tr.cells` -- the collection of `
` and `
` cells inside the given `
`.
-- `tr.sectionRowIndex` -- the position (index) of the given `
` inside the enclosing `/
/`.
-- `tr.rowIndex` -- the number of the `
` in the table as a whole (including all table rows).
+**Elemen `
` dan `
`:**
-**`
` and `
`:**
-- `td.cellIndex` -- the number of the cell inside the enclosing `
`.
+- `td.cellIndex` -- nomor sel di dalam elemen `
`.
-An example of usage:
+Contoh penggunaannya:
```html run height=100
-
one
two
+
one
+
two
-
three
four
+
three
+
four
```
-The specification: [tabular data](https://html.spec.whatwg.org/multipage/tables.html).
+Spesifikasi: [Data Tabel](https://html.spec.whatwg.org/multipage/tables.html).
-There are also additional navigation properties for HTML forms. We'll look at them later when we start working with forms.
+Terdapat juga properti-properti navigasi tambahan untuk formulir HTML. Kita akan melihatnya nanti ketika kita mulai bekerja dengan formulir.
-## Summary
+## Ringkasan
-Given a DOM node, we can go to its immediate neighbors using navigation properties.
+Diberikan sebuah simpul DOM, kita dapat menuju tetangganya yang langsung menggunakan properti-properti navigasi.
-There are two main sets of them:
+Ada dua set utama properti-properti tersebut:
-- For all nodes: `parentNode`, `childNodes`, `firstChild`, `lastChild`, `previousSibling`, `nextSibling`.
-- For element nodes only: `parentElement`, `children`, `firstElementChild`, `lastElementChild`, `previousElementSibling`, `nextElementSibling`.
+- Untuk semua simpul: `parentNode`, `childNodes`, `firstChild`, `lastChild`, `previousSibling`, `nextSibling`.
+- Hanya untuk elemen: `parentElement`, `children`, `firstElementChild`, `lastElementChild`, `previousElementSibling`, `nextElementSibling`.
-Some types of DOM elements, e.g. tables, provide additional properties and collections to access their content.
+Beberapa jenis elemen DOM, misalnya tabel, menyediakan properti dan koleksi tambahan untuk mengakses kontennya.
diff --git a/2-ui/1-document/06-dom-attributes-and-properties/article.md b/2-ui/1-document/06-dom-attributes-and-properties/article.md
index e39a54256..53825bbb2 100644
--- a/2-ui/1-document/06-dom-attributes-and-properties/article.md
+++ b/2-ui/1-document/06-dom-attributes-and-properties/article.md
@@ -1,42 +1,42 @@
-# Attributes and properties
+# Atribut dan Properti
-When the browser loads the page, it "reads" (another word: "parses") the HTML and generates DOM objects from it. For element nodes, most standard HTML attributes automatically become properties of DOM objects.
+Ketika peramban (browser) memuat halaman, peramban "membaca" (atau istilah lainnya: "menganalisis") HTML dan menghasilkan objek-objek DOM dari HTML tersebut. Untuk elemen-elemen, sebagian besar atribut HTML standar secara otomatis menjadi properti dari objek-objek DOM.
-For instance, if the tag is ``, then the DOM object has `body.id="page"`.
+Misalnya, jika tag adalah ``, maka objek DOM akan memiliki `body.id="page"`.
-But the attribute-property mapping is not one-to-one! In this chapter we'll pay attention to separate these two notions, to see how to work with them, when they are the same, and when they are different.
+Namun, pemetaan atribut-atribut ini tidaklah satu-satu! Di bab ini, kita akan memahami perbedaan antara kedua hal tersebut, untuk melihat bagaimana cara bekerja dengan mereka, ketika mereka sama, dan ketika mereka berbeda.
-## DOM properties
+## Properti DOM
-We've already seen built-in DOM properties. There are a lot. But technically no one limits us, and if there aren't enough, we can add our own.
+Kita telah melihat beberapa properti DOM bawaan sebelumnya. Ada banyak properti lainnya. Tetapi secara teknis, tidak ada batasan, dan jika tidak cukup, kita dapat menambahkan properti sendiri.
-DOM nodes are regular JavaScript objects. We can alter them.
+Simpul DOM adalah objek JavaScript biasa. Kita dapat memodifikasinya.
-For instance, let's create a new property in `document.body`:
+Misalnya, mari bat sebuah properti baru pada `document.body`:
```js run
document.body.myData = {
- name: 'Caesar',
- title: 'Imperator'
+ name: "Caesar",
+ title: "Imperator",
};
alert(document.body.myData.title); // Imperator
```
-We can add a method as well:
+Kita juga dapat menambahkan sebuah method:
```js run
-document.body.sayTagName = function() {
+document.body.sayTagName = function () {
alert(this.tagName);
};
-document.body.sayTagName(); // BODY (the value of "this" in the method is document.body)
+document.body.sayTagName(); // BODY (nilai dari "this" dalam method adalah document.body)
```
-We can also modify built-in prototypes like `Element.prototype` and add new methods to all elements:
+Kita juga dapat memodifikasi prototipe bawaan seperti `Element.prototype` dan menambahkan method baru ke semua elemen:
```js run
-Element.prototype.sayHi = function() {
+Element.prototype.sayHi = function () {
alert(`Hello, I'm ${this.tagName}`);
};
@@ -44,234 +44,237 @@ document.documentElement.sayHi(); // Hello, I'm HTML
document.body.sayHi(); // Hello, I'm BODY
```
-So, DOM properties and methods behave just like those of regular JavaScript objects:
+Jadi, properti dan method DOM berperilaku sama seperti objek JavaScript biasa:
-- They can have any value.
-- They are case-sensitive (write `elem.nodeType`, not `elem.NoDeTyPe`).
+- Mereka dapat memiliki nilai apa pun.
+- Mereka bersifat case-sensitive (tulis `elem.nodeType`, bukan `elem.NoDeTyPe`).
-## HTML attributes
+## Atribut HTML
-In HTML, tags may have attributes. When the browser parses the HTML to create DOM objects for tags, it recognizes *standard* attributes and creates DOM properties from them.
+Dalam HTML, tag-tag dapat memiliki atribut. Ketika peramban mengurai HTML untuk membuat objek-objek DOM untuk tag-tag tersebut, peramban mengenali atribut-atribut _standar_ dan membuat properti DOM dari atribut-atribut tersebut.
-So when an element has `id` or another *standard* attribute, the corresponding property gets created. But that doesn't happen if the attribute is non-standard.
+Jadi, ketika sebuah elemen memiliki atribut `id` atau atribut _standar_ lainnya, properti yang sesuai akan dibuat. Namun, hal ini tidak terjadi jika atribut tersebut adalah non-standar.
+
+Misalnya:
-For instance:
```html run
```
-Please note that a standard attribute for one element can be unknown for another one. For instance, `"type"` is standard for `` ([HTMLInputElement](https://html.spec.whatwg.org/#htmlinputelement)), but not for `` ([HTMLBodyElement](https://html.spec.whatwg.org/#htmlbodyelement)). Standard attributes are described in the specification for the corresponding element class.
+Harap dicatat bahwa atribut standar untuk satu elemen dapat tidak dikenali oleh elemen lain. Misalnya, `"type"` adalah atribut standar untuk `` ([HTMLInputElement](https://html.spec.whatwg.org/#htmlinputelement)), tetapi bukan untuk `` ([HTMLBodyElement](https://html.spec.whatwg.org/#htmlbodyelement)). Atribut-atribut standar dijelaskan dalam spesifikasi untuk kelas elemen yang sesuai.
+
+Di sini kita dapat melihatnya:
-Here we can see it:
```html run
-
+
```
-So, if an attribute is non-standard, there won't be a DOM-property for it. Is there a way to access such attributes?
+Jadi, jika sebuah atribut non-standar, maka tidak akan ada properti DOM untuknya. Apakah ada cara untuk mengakses atribut-atribut tersebut?
-Sure. All attributes are accessible by using the following methods:
+Tentu saja. Semua atribut dapat diakses dengan menggunakan method-method berikut:
-- `elem.hasAttribute(name)` -- checks for existence.
-- `elem.getAttribute(name)` -- gets the value.
-- `elem.setAttribute(name, value)` -- sets the value.
-- `elem.removeAttribute(name)` -- removes the attribute.
+- `elem.hasAttribute(name)` -- memeriksa keberadaan atribut.
+- `elem.getAttribute(name)` -- mendapatkan nilainya.
+- `elem.setAttribute(name, value)` -- mengatur nilainya.
+- `elem.removeAttribute(name)` -- menghapus atribut.
-These methods operate exactly with what's written in HTML.
+Method-method ini beroperasi sesuai dengan apa yang tertulis dalam HTML.
-Also one can read all attributes using `elem.attributes`: a collection of objects that belong to a built-in [Attr](https://dom.spec.whatwg.org/#attr) class, with `name` and `value` properties.
+Selain itu, kita dapat membaca semua atribut menggunakan `elem.attributes`: sebuah koleksi objek yang termasuk ke dalam kelas bawaan [Attr](https://dom.spec.whatwg.org/#attr), dengan properti `name` dan `value`.
-Here's a demo of reading a non-standard property:
+Berikut adalah contoh membaca atribut non-standar:
```html run
```
-HTML attributes have the following features:
+Atribut HTML memiliki fitur-fitur berikut:
-- Their name is case-insensitive (`id` is same as `ID`).
-- Their values are always strings.
+- Nama mereka bersifat case-insensitive (`id` sama dengan `ID`).
+- Nilai-nilai mereka selalu berupa string.
-Here's an extended demo of working with attributes:
+Berikut adalah contoh lebih lanjut tentang cara bekerja dengan atribut-atribut:
```html run
```
-Please note:
+Harap dicatat:
-1. `getAttribute('About')` -- the first letter is uppercase here, and in HTML it's all lowercase. But that doesn't matter: attribute names are case-insensitive.
-2. We can assign anything to an attribute, but it becomes a string. So here we have `"123"` as the value.
-3. All attributes including ones that we set are visible in `outerHTML`.
-4. The `attributes` collection is iterable and has all the attributes of the element (standard and non-standard) as objects with `name` and `value` properties.
+1. `getAttribute('About')` -- huruf pertama di sini adalah huruf kapital, dan dalam HTML semuanya huruf kecil. Tetapi hal ini tidak masalah: nama atribut bersifat case-insensitive.
+2. Kita dapat menetapkan apa pun sebagai atribut, tetapi nilainya akan menjadi sebuah string. Jadi disini kita memiliki `"123"` sebagai nilai atribut.
+3. Semua atribut, termasuk yang kita set, terlihat dalam `outerHTML`.
+4. Koleksi `attributes` dapat diulangi (iterable) dan berisi semua atribut dari elemen tersebut (standar dan non-standar) sebagai objek dengan properti `name` dan `value`.
-## Property-attribute synchronization
+## Sinkronisasi Properti-atribut
-When a standard attribute changes, the corresponding property is auto-updated, and (with some exceptions) vice versa.
+Ketika atribut standar berubah, properti yang sesuai akan diperbarui secara otomatis, dan (dengan beberapa pengecualian) sebaliknya.
-In the example below `id` is modified as an attribute, and we can see the property changed too. And then the same backwards:
+Pada contoh dibawah ini, `id` diubah sebagai atribut, dan kita dapat melihat bahwa properti juga berubah. Kemudian, hal yang sama terjadi sebaliknya:
```html run
-
+
```
-But there are exclusions, for instance `input.value` synchronizes only from attribute -> to property, but not back:
+Tetapi ada pengecualian, misalnya `input.value` disinkronkan hanya dari atribut -> ke properti, tapi tidak sebaliknya:
```html run
-
+
```
-In the example above:
-- Changing the attribute `value` updates the property.
-- But the property change does not affect the attribute.
+Pada contoh di atas:
+
+- Mengubah atribut `value` akan memperbarui propertinya.
+- Tetapi perubahan properti tidak mempengarui atributnya.
-That "feature" may actually come in handy, because the user actions may lead to `value` changes, and then after them, if we want to recover the "original" value from HTML, it's in the attribute.
+"Fitur" tersebut sebenarnya bisa sangat berguna, karena tindakan pengguna dapat menyebabkan perubahan nilai `value`, dan kemudian, jika kita ingin mengembalikan nilai "asli" dari HTML, nilainya terdapat dalam atribut.
-## DOM properties are typed
+## Properti DOM bertipe
-DOM properties are not always strings. For instance, the `input.checked` property (for checkboxes) is a boolean:
+Properti DOM tidak selalu berupa string. Misalnya, properti `input.checked` (untuk kotak centang / checkbox) adalah boolean:
```html run
- checkbox
+ checkbox
```
-There are other examples. The `style` attribute is a string, but the `style` property is an object:
+Ada contoh lain. Atribut `style` adalah string, tetapi properti `style` adalah objek:
```html run
Hello
```
-Most properties are strings though.
+Sebagian besar properti adalah string.
-Quite rarely, even if a DOM property type is a string, it may differ from the attribute. For instance, the `href` DOM property is always a *full* URL, even if the attribute contains a relative URL or just a `#hash`.
+Jarang sekali, meskipun tipe properti DOM adalah string, itu dapat berbeda dari atribut. Misalnya, properti DOM `href` selalu berupa URL _penuh_, meskipun atributnya berisi URL relatif atau hanya `#hash`.
-Here's an example:
+Berikut adalah contoh:
```html height=30 run
link
```
-If we need the value of `href` or any other attribute exactly as written in the HTML, we can use `getAttribute`.
+Jika kita membutuhkan nilai `href` atau atribut lainnya secara tepat seperti yang tertulis dalam HTML, kita dapat menggunakan `getAttribute`.
+## Atribut non-standar, dataset
-## Non-standard attributes, dataset
+Ketika menulis HTML, kita sering menggunakan atribut-atribut standar. Tetapi bagaimana dengan atribut non-standar, khusus? Pertama, mari lihat apakah mereka bermanfaat atau tidak? Untuk apa?
-When writing HTML, we use a lot of standard attributes. But what about non-standard, custom ones? First, let's see whether they are useful or not? What for?
+Terkadang atribut non-standar digunakan untuk menyampaikan data kustom dari HTML ke JavaScript, atau untuk "menandai" elemen-elemen HTML untuk JavaScript.
-Sometimes non-standard attributes are used to pass custom data from HTML to JavaScript, or to "mark" HTML-elements for JavaScript.
-
-Like this:
+Contohnya seperti ini:
```html run
-
+
-
+
```
-Also they can be used to style an element.
+Selain itu, atribut non-standar juga dapat digunakan untuk memberikan gaya (style) pada elemen.
-For instance, here for the order state the attribute `order-state` is used:
+Misalnya, di sini untuk keadaan pesanan (order state), digunakan atribut `order-state`:
```html run
-
- A new order.
-
+
A new order.
-
- A pending order.
-
+
A pending order.
-
- A canceled order.
-
+
A canceled order.
```
-Why would using an attribute be preferable to having classes like `.order-state-new`, `.order-state-pending`, `.order-state-canceled`?
+Mengapa menggunakan atribut lebih disukai daripada menggunakan kelas seperti `.order-state-new`, `.order-state-pending`, `.order-state-canceled`?
-Because an attribute is more convenient to manage. The state can be changed as easy as:
+Karena atribut lebih mudah dikelola. Keadaan dapat diubah dengan mudah seperti ini:
```js
-// a bit simpler than removing old/adding a new class
-div.setAttribute('order-state', 'canceled');
+// sedikit lebih sederhana daripada menghapus kelas lama/menambahkan kelas baru
+div.setAttribute("order-state", "canceled");
```
-But there may be a possible problem with custom attributes. What if we use a non-standard attribute for our purposes and later the standard introduces it and makes it do something? The HTML language is alive, it grows, and more attributes appear to suit the needs of developers. There may be unexpected effects in such case.
+Namun, ada masalah yang mungkin muncul dengan atribut kustom. Bagaimana jika kita menggunakan atribut non-standar untuk tujuan kita dan kemudian standar memperkenalkannya dan memberikan fungsionalitas tertentu padanya? Bahasa HTML adalah dinamis, berkembang, dan atribut-atribut baru muncul untuk memenuhi kebutuhan para pengembang. Dalam kasus tersebut, dapat terjadi efek yang tidak terduga.
-To avoid conflicts, there exist [data-*](https://html.spec.whatwg.org/#embedding-custom-non-visible-data-with-the-data-*-attributes) attributes.
+Untuk menghindari konflik, ada [data-\*](https://html.spec.whatwg.org/#embedding-custom-non-visible-data-with-the-data-*-attributes) atribut.
-**All attributes starting with "data-" are reserved for programmers' use. They are available in the `dataset` property.**
+**Semua atribut yang dimulai dengan "data-" disediakan untuk penggunaan programmer. Mereka dapat di akses melalui properti `dataset`.**
-For instance, if an `elem` has an attribute named `"data-about"`, it's available as `elem.dataset.about`.
+Misalnya, jika sebuah `elem` memiliki atribut bernama `"data-about"`, maka dapat diakses menggunakan `elem.dataset.about`.
-Like this:
+Contohnya seperti ini:
```html run
-
+
+
```
-Multiword attributes like `data-order-state` become camel-cased: `dataset.orderState`.
+Atribut dengan beberapa kata seperti `data-order-state` akan menjadi camel-cased: `dataset.orderState`.
-Here's a rewritten "order state" example:
+Berikut adalah contoh yang telah diperbaiki untuk "order state":
```html run
-
- A new order.
-
+
A new order.
```
-Using `data-*` attributes is a valid, safe way to pass custom data.
+Menggunakan atribut `data-*` adalah cara yang valid dan aman untuk menyampaikan data kustom.
-Please note that we can not only read, but also modify data-attributes. Then CSS updates the view accordingly: in the example above the last line `(*)` changes the color to blue.
+Harap dicatat bahwa kita tidak hanya bisa membaca, tetapi juga mengubah atribut data. Selanjutnya, CSS akan memperbarui tampilan sesuai dengan perubahan tersebut: pada contoh di atas, baris terakhir `(*)` mengubah warna menjadi biru.
-## Summary
+## Ringkasan
-- Attributes -- is what's written in HTML.
-- Properties -- is what's in DOM objects.
+- Atribut -- adalah apa yang tertulis dalam HTML.
+- Properti -- adalah apa yang ada dalam objek DOM.
-A small comparison:
+Sebuah perbandingan kecil:
-| | Properties | Attributes |
-|------------|------------|------------|
-|Type|Any value, standard properties have types described in the spec|A string|
-|Name|Name is case-sensitive|Name is not case-sensitive|
+| | Properti | Atribut |
+| ---- | -------------------------------------------------------------------------------------------- | ---------------------------------- |
+| Tipe | Bisa memiliki nilai apapun, properti standar memiliki tipe yang dijelaskan dalam spesifikasi | Sebuah string |
+| Nama | Nama bersifat case-sensitive | Nama tidak bersifat case-sensitive |
-Methods to work with attributes are:
+Method-method untuk bekerja dengan atribut adalah:
-- `elem.hasAttribute(name)` -- to check for existence.
-- `elem.getAttribute(name)` -- to get the value.
-- `elem.setAttribute(name, value)` -- to set the value.
-- `elem.removeAttribute(name)` -- to remove the attribute.
-- `elem.attributes` is a collection of all attributes.
+- `elem.hasAttribute(name)` -- untuk memeriksa keberadaan atribut.
+- `elem.getAttribute(name)` -- untuk mendapatkan nilai atribut.
+- `elem.setAttribute(name, value)` -- untuk mengatur nilai atribut.
+- `elem.removeAttribute(name)` -- untuk menghapus atribut.
+- `elem.attributes` adalah koleksi dari semua atribut.
-For most situations using DOM properties is preferable. We should refer to attributes only when DOM properties do not suit us, when we need exactly attributes, for instance:
+Untuk sebagian besar situasi, menggunakan properti DOM lebih disukai. Kita harus merujuk pada atribut hanya ketika properti DOM tidak sesuai dengan kebutuhan kita, ketika kita memerlukan atribut secara khusus, misalnya:
-- We need a non-standard attribute. But if it starts with `data-`, then we should use `dataset`.
-- We want to read the value "as written" in HTML. The value of the DOM property may be different, for instance the `href` property is always a full URL, and we may want to get the "original" value.
+- Kita membutuhkan atribut non-standar. Tetapi jika atribut tersebut dimulai dengan `data-`, maka kita harus menggunakan `dataset`.
+- Kita ingin membaca nilai "sebagaimana tertulis" dalam HTML. Nilai properti DOM mungkin berbeda, misalnya properti `href` selalu berupa URL lengkap, dan kita mungkin ingin mendapatkan nilai "asli" tersebut.