DOMラッパーについて聞いてください
DOMラッパーについて聞いてください
はじまるよ!!!!
DOMラッパーについて聞いてください
はじまるよ!!!!
自己紹介
趣味でやっていること
趣味でやっていること
来週から型推論の章!
TVの前のみんなもチェック!
DOMに関する実験をしてみましょう
実験タイム
同じDOMを見ているはずなのに……?
同じDOMを見ているはずなのに……?
今日はこの現象を深掘りしてみよう!
同じDOMを見ているはずなのに……?
今日はこの現象を深掘りしてみよう!
今日のまとめ
結論
DOMラッパー??
Own work, CC BY-SA 3.0, via Wikimedia Commons
JSでDOMを操作して画面を変更するときのイメージ
JSでDOMの操作
DOMは誰が持っているんだ?
JSでDOMの操作
レンダリングエンジンにある?
でもJSエンジンにないとさわれない?
DOMの本体はレンダリングエンジン側にあり、ラッパーを通じてJSに露出
browser
rendering engine
JS engine
div
DOM
wrapper
DOM
JSでのDOMの操作
div
どうなっているんだ??
browser
rendering engine
JS engine
div
DOM
wrapper
DOM
JSでのDOMの操作
div
bindings
例えばdiv.firstChildをやると……
結論
DOMラッパーをsandboxする”world”
A world is a concept to sandbox DOM wrappers among content scripts of Chrome extensions.
All worlds in one isolate share underlying C++ DOM objects, but each world has its own DOM wrappers.
from “Design of V8 bindings”
worldは3種類あり、コンテキストを持っている
Also each world has its own context.
There are three kinds of worlds: a main world, an isolated world and a worker world.
A main world is a world where a normal JavaScript downloaded from the web is executed.
An isolated world is a world where a content script of a Chrome extension is executed.
from “Design of V8 bindings”
結論
つまり……
こういうこと
setAttribute()はDOMの操作であり……
div.XXはDOMラッパー、要するにJSオブジェクトの操作
まとめ
本当はさあ……
GC