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
Here, below, there's an HTML-element and JavaScript that dynamically fills it using `innerHTML`.
210
+
در اینجا، در زیر، یک عنصر HTML و جاوااسکریپت وجود دارد که به صورت پویا با استفاده از `innerHTML` آن را پر می کند.
211
211
212
-
Please run the previous code (above, observes that element), and then the code below. You'll see how `MutationObserver`detects and highlights the snippet.
212
+
لطفا کد قبلی را اجرا کنید (در بالا، آن عنصر را مشاهده کنید)، و سپس کد زیر را اجرا کنید. خواهید دید که چگونه `MutationObserver`قطعه را شناسایی و برجسته می کند.
213
213
214
-
<pid="highlight-demo"style="border: 1pxsolid#ddd">A demo-element with <code>id="highlight-demo"</code>, run the code above to observe it.</p>
214
+
<pid="highlight-demo"style="border: 1pxsolid#ddd">یک عنصر آزمایشی با <code>id="highlight-demo"</code>، کد بالا را اجرا کنید تا آن را مشاهده کنید.</p>
215
215
216
-
The following code populates its `innerHTML`, that causes the `MutationObserver`to react and highlight its contents:
216
+
کد زیر `innerHTML` خود را پر می کند، که باعث می شود`MutationObserver`واکنش نشان داده و محتوای آن را برجسته کند:
217
217
218
218
```js run
219
219
let demoElem =document.getElementById('highlight-demo');
Now we have `MutationObserver`that can track all highlighting in observed elements or the whole `document`. We can add/remove code snippets in HTML without thinking about it.
231
+
اکنون `MutationObserver`را داریم که می تواند تمام برجسته سازی ها در عناصر مشاهده شده یا کل `document` را ردیابی کند. ما میتوانیم تکههای کد را بدون فکر کردن در HTML اضافه یا حذف کنیم.
232
232
233
233
## Additional methods
234
234
235
-
There's a method to stop observing the node:
235
+
روشی برای توقف مشاهده گره وجود دارد:
236
236
237
-
-`observer.disconnect()` -- stops the observation.
237
+
-`observer.disconnect()` - مشاهده را متوقف می کند.
238
238
239
-
When we stop the observing, it might be possible that some changes were not yet processed by the observer. In such cases, we use
239
+
وقتی مشاهده را متوقف می کنیم، ممکن است برخی از تغییرات هنوز توسط ناظر پردازش نشده باشد. در چنین مواردی استفاده می کنیم
240
240
241
-
-`observer.takeRecords()` -- gets a list of unprocessed mutation records - those that happened, but the callback has not handled them.
241
+
-`observer.takeRecords()` - لیستی از سوابق جهش پردازش نشده را دریافت می کند - مواردی که اتفاق افتاده اند، اما پاسخ تماس آنها را مدیریت نکرده است.
242
242
243
-
These methods can be used together, like this:
243
+
این روش ها را می توان با هم استفاده کرد، مانند:
244
244
245
245
```js
246
246
// get a list of unprocessed mutations
@@ -266,8 +266,8 @@ The mere fact that a DOM node is observed doesn't prevent the garbage collection
266
266
267
267
## Summary
268
268
269
-
`MutationObserver`can react to changes in DOM - attributes, text content and adding/removing elements.
269
+
پس`MutationObserver`می تواند به تغییرات در DOM - ویژگی ها، محتوای متن و افزودن/حذف عناصر واکنش نشان دهد.
270
270
271
-
We can use it to track changes introduced by other parts of our code, as well as to integrate with third-party scripts.
271
+
ما میتوانیم از آن برای ردیابی تغییرات ایجاد شده توسط بخشهای دیگر کدمان و همچنین برای ادغام با اسکریپتهای شخص ثالث استفاده کنیم.
272
272
273
-
`MutationObserver`can track any changes. The config "what to observe" options are used for optimizations, not to spend resources on unneeded callback invocations.
273
+
هم چنین `MutationObserver`می تواند هر تغییری را ردیابی کند. تنظیمات "چه چیزی را مشاهده کنیم" برای بهینه سازی استفاده می شود، نه برای صرف منابع در فراخوانی های غیر ضروری.
0 commit comments