widget_embedder.js:106 [Deprecation]Listener added for a ‘DOMNodeInserted’ mutation event. Support for this event type has been removed, and this event will no longer be fired. See https://chromestatus.com/feature/5083947249172480 for more information.
エラー メッセージは次のようになっています:
widget_embedder.js:106 [Deprecation] Listener added for a 'DOMNodeInserted' mutation event. Support for this event type has been removed, and this event will no longer be fired. See https://chromestatus.com/feature/5083947249172480 for more information.
これは、DOMNodeInserted というミューテーションイベント(DOM変化イベント)が非推奨になり、サポートが廃止されたことを示しています。ミューテーションイベントは、DOM(ドキュメントオブジェクトモデル)に変更が加えられたときにトリガーされるイベントのことです。しかし、このイベントはパフォーマンスの問題やブラウザのクラッシュを引き起こす可能性があるため、最新のブラウザではサポートされなくなりました。
修正方法
このエラーを修正するには、MutationObserver を使用して同様の機能を実装することをお勧めします。MutationObserver は、DOMの変更を監視し、指定された変更が発生したときにコールバック関数を実行する新しいAPIです。以下に簡単な例を示します:
// 古いミューテーションイベントの使用例
target.addEventListener('DOMNodeInserted', event => doSomething(event.target));
// 新しい MutationObserver を使用したコード
const observer = new MutationObserver(mutationList => {
mutationList.forEach(mutation => {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach(doSomething);
}
});
});
observer.observe(target, { childList: true, subtree: true });
このように、MutationObserver を使うことで、DOMの変化に対して効率的かつ安全に対応できます。


コメントを残す
コメントを投稿するにはログインしてください。