Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
picodomでVDOMの理解を深める
Search
takanorip
January 25, 2018
Technology
440
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
picodomでVDOMの理解を深める
takanorip
January 25, 2018
More Decks by takanorip
See All by takanorip
今さら理解するウェブフォントver.2026
takanorip
3
690
AI-Slopなデザインを生まないためのデザインプロセス戦略
takanorip
10
6.2k
「見せる」登壇資料デザインの極意
takanorip
7
1.8k
Design System Documentation Tooling 2025
takanorip
3
3.1k
デザインエンジニアの延長にデザインマネージャーとしての可能性を探る
takanorip
1
1.4k
Tools for Design Engineers other than LLM in the LLM era
takanorip
1
910
Bulletproof Design System with TypeScript
takanorip
7
5.4k
Eleventy3.0 で始める爆速個人ブログ開発!
takanorip
0
320
Webフォント選定の極意!フォントの基本から最新トレンドまで徹底解説
takanorip
6
1.2k
Other Decks in Technology
See All in Technology
ゲームのリアルタイム通信から見た QUIC と MoQ
segadevtech
0
110
自主式軟體工廠
philipz
0
260
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
120
Essential architectural thinking (revised edition)
ufried
0
120
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
160
12 個 Tool と、 4,096 Token
hlum
0
150
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
100
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
120
継続的なAIコスト最適化
bgpat
1
290
組み立てて楽しむ AWS Blocks 入門
kmiya84377
0
230
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
210
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
150
Featured
See All Featured
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Faster Mobile Websites
deanohume
310
32k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
WCS-LA-2024
lcolladotor
0
880
Optimising Largest Contentful Paint
csswizardry
37
4k
Raft: Consensus for Rubyists
vanstee
142
7.8k
Transcript
picodomでVDOMの 理解を深める Takanori Oki @Megro.es
自己紹介 • 大木 尊紀(オオキ タカノリ) / @takanorip • 株式会社スマートドライブ •
フロントエンドエンジニア • React、Vue、Polymer、Web制作全般 • Polymer Japan 翻訳チーム • 「イヌでもわかる Web Components」 好評配信中 • 輝夜月かわいい
Polymer Japan Cafe (2月6日@Google Tokyo Office)
hyperapp コードリーディング会 (2月7日@チームスピリット)
picodom ?
picodom • VDOMでページを操作するJSライブラリ • 1kbしかない、軽い • hyperappのJorgeBucaranさんが書いてる • 提供するメソッドは2つだけ •
h():VDOMを生成する • patch():VDOMへ差分適用 • JSXが使える
なんでpicodom? • Fish shellのファンだから(JorgeBucaranさんはFish shellの開発者でもある) • hyperappよりも機能が絞られているから読みやすいか なと思った • VDOMの実装だけ読みたかった
• picodom使ってオレオレライブラリ作れたら面白そう
picodomを読む
構成とか • picodomの構成 • h.js:h()の定義 / 29行 • patch.js:patch()を定義 /
206行 • (index.jsは↑2つのファイルをimportしてるだけ)
picodomを読む: h() • VDOMを生成する • DOM構造をオブジェクトに変換する (VODMはオブジェクト) • めっちゃシンプルなので言うことない •
Reactとかとやってることはだいたい同じ
h("div", {id: 'app'}, [ h("h1", {class: 'title'}, 'Title'), h("button", {
onclick: () => {hoge: 'fuga'} }, "+"), 'some text' ]);
{ name: "div", props: { id: "app" }, children: [
{ name: "h1", props: { class : "title" }, children: ["Title"] }, { name: "button", props: { onclick: () => {hoge: 'fuga'} }, children: ["+"] }, "some text" ] }
picodomを読む: patch() patch patchElement setElementProp removeChildren createElement updateElement setElementProp oldNode
== null patchElement true false
picodomを読む: patch() patch patchElementの結果を返す patchElement 差分更新の処理を司る setElementProp elementにpropsを挿入する createElement document.createElementを使って
elementを作成する updateElement elementのvalueやpropsを更新する removeChildren elementを削除する
picodomを使う
import { h, patch } from picodom /** @jsx h
*/ let node function render(view, withState) { patch(node, (node = view(withState))) } function view(state) { return ( <div> <h1>{state}</h1> <input autofocus type="text" value={state} oninput={e => render(view, e.target.value)} /> </div> ) } render(view, "Hello!")
まとめ • 軽量なVDOMフレームワーク • 仮想DOMの仕組みがなんとなくわかった • コア機能のみの実装で、実装はとてもシンプル • picodomベースでオレオレフレームワークをつくる本 を書いてみたい
おわり (Rounded-L Mgen+ 2p)