Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Um futuro chamado Web Components
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Zeno Rocha
August 22, 2013
Programming
26k
47
Share
Um futuro chamado Web Components
BrazilJS 2013
Zeno Rocha
August 22, 2013
More Decks by Zeno Rocha
See All by Zeno Rocha
The Next Generation of Developer-First Products
zenorocha
1
690
7 Habits of Highly Productive Developers
zenorocha
1
440
7 Hábitos de Desenvolvedores Altamente Produtivos
zenorocha
1
570
What's new in the Liferay Community
zenorocha
0
730
Launching Liferay Projects Faster with WeDeploy
zenorocha
1
610
How Liferay fits into the real of latest technologies
zenorocha
0
670
Estoicismo e JavaScript
zenorocha
3
1.2k
Por que ninguém se importa com seu novo projeto open source?
zenorocha
2
1.2k
Como investir em... você!
zenorocha
1
610
Other Decks in Programming
See All in Programming
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
460
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
120
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
130
How Swift's Type System Guides AI Agents
koher
0
330
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
2
280
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
330
tRPCの概要と少しだけパフォーマンス
misoton665
2
260
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.6k
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
410
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.1k
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
180
空間オーディオの活用
objectiveaudio
0
120
Featured
See All Featured
Making Projects Easy
brettharned
120
6.6k
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
300
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
330
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
690
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Transcript
<web components> um futuro chamado @zenorocha
@liferay @alloyui
None
None
None
jqueryboilerplate.com
browserdiet.com
None
os projetos mais populares voltados para client-side estão fadados a
morrer
vs <canvas>
document.querySelector vs
vs <input type=”date”>
então quer dizer que tudo vai virar “nativo” um dia?
o que as principais empresas da web estão trabalhando hoje?
None
getbootstrap.com
None
facebook.github.io/react
None
topcoat.io
None
alloyui.com
None
purecss.io
None
None
None
como usar um “componente” hoje?
1. Nunca crie! Use um plugin jQuery
2. Copie e cole o código de alguém
3. Torça pra que funcione
Web Components
<braziljs> braziljs.github.io/braziljs-element
<video is=”camera”> customelements.github.io/camera-element
Web Components Custom Elements Import Templates Shadow DOM Decorators*
Custom Elements
<element name="braziljs" constructor="BrazilJS" attributes="onde"> // implementação </element> <element>
<element name="camera" extends="video"> // implementação </element> <element>
zno.io/QxNJ
<brazil-js></brazil-js> usando JS var proto = Object.create(HTMLElement.prototype); proto.createdCallback = function()
{ this.textContent = 'BrazilJS!'; }; document.register('brazil-js', { prototype: proto });
lifecycle •createdCallback •enteredDocumentCallback •leftDocumentCallback •attributeChangedCallback
x-tags.org
polymer-project.org
<polymer-element name="braziljs" attributes="onde"> <script> Polymer('braziljs', { onde: 'Porto Alegre', created:
function() { // faça algo } }); </script> </polymer-element> como usar?
zno.io/QxlZ
Templates
Templates são blocos reutilizáveis de código
server-side mustache handlebars liquid jinja velocity savant
client-side mustache handlebars eco ejs jade hogan
gambiarra #1 <div id="template" style="display: none"> <img src="logo.png" class="logo.png"> </div>
<script id="template" type="text/x-handlebars-template"> <img src="logo.png"> </script> gambiarra #2
<template>
<template id="meuTemplate"> <img src=""> </template> como criar?
// 1. Acessa o conteúdo do template var t =
document.querySelector('#meuTemplate').content; // 2. Manipula elemento interno do template t.querySelector('img').src = 'logo.png'; // 3. Clona e insere no DOM document.body.appendChild(t.cloneNode(true)); como usar?
Shadow DOM
Shadow DOM esconde os detalhes de implementação
mas e o <iframe>?
do que é feito um <video>? ou um password, textarea,
date?
como usar? <h1>Documento</h1> <div id=”cuia”></div> var cuia = document.querySelector('#cuia') .createShadowRoot();
cuia.innerHTML = '<h1>Mate</h1>';
estilo, marcação e script encapsulados <h1>Documento</h1> <div id=”cuia”></div> var cuia
= document.querySelector('#cuia') .createShadowRoot(); cuia.innerHTML = '<h1>Mate</h1>' + '<style>h1 { color: #f00; }</style>';
como ativar?
Import
None
None
None
None
como usar? <link rel="import" href="braziljs.html">
None
jonrimmer.github.io/are-we-componentized-yet
Flags
quero usar hoje, onde eu encontro? NPM? Bower?
@eduardolundgren
@bernarddeluna
customelements.io
<twitter> customelements.github.io/twitter-element
<gmaps> customelements.github.io/gmaps-element
<video is=”camera”> customelements.github.io/camera-element
<video is=”tracking”> eduardolundgren.github.io/tracking-element
ou seja...
encapsulamento e reaproveitamento de código de verdade
A melhor forma de prever o futuro é inventando ele
e..... camisetas!
None