Open7
Web API (DOM) の復習
バニラのWeb標準で何ができるかを把握する。
DOM 4 が DOM Standard と言えそう。
特に User Script で役立つ。
微妙にTSが対応してない。
// Set multiple styles in a single statement
elt.style.cssText = "color: blue; border: 1px solid black";
// Or
elt.setAttribute("style", "color:red; border: 1px solid blue;");
// Set specific style while leaving other inline style values untouched
elt.style.color = "blue";
HTMLElement じゃない
昔はこういうのがあったらしい
代替
User Scripts
MutationObserver
observe
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
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.