Open7

Web API (DOM) の復習

wintwint

MutationObserver

https://ja.javascript.info/mutation-observer

observe

https://developer.mozilla.org/ja/docs/Web/API/MutationObserver/observe#例外

https://developer.mozilla.org/en-US/docs/Web/API/MutationObserverInit#properties

At a minimum, one of childList, attributes, and/or characterData must be true when you call observe(). Otherwise, a TypeError exception will be thrown.

Error

sample

TypeError: Failed to execute 'observe' on 'MutationObserver': The options object must set at least one of 'attributes', 'characterData', or 'childList' to true.

child list

https://developer.mozilla.org/en-US/docs/Web/API/MutationObserverInit/childList

By setting childList to true, your callback will be invoked any time nodes are added to or removed from the DOM node or nodes being watched.

Setting subtree to true causes addition or removal of nodes anywhere within the subtree rooted at target to be reported.