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
O mágico mundo de Web Components
Search
Mateus Ortiz
June 26, 2014
Programming
240
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
O mágico mundo de Web Components
Present at beltrao In Tech
Mateus Ortiz
June 26, 2014
Transcript
44 slides
O Mágico Mundo De Web Components @mteusortiz
@mteusortiz /mateusortiz Front-End Developer
None
None
Web Components
HTML5 é o Futuro?
None
O Futuro
None
<x-heart> http://mateusortiz.github.io/x-heart/
None
Web Components Shadow DOM Template Custom Elements HTML Imports Decorators
Custom Elements
Antes com <element> <element name="x-button" constructor="XBUTTON" attributes="lg sm xs"> <!--
Content --> </element>
Antes com <element> <element name="x-button" extends="button"> <!-- Content --> </element>
http://goo.gl/GWatuU
com JS <my-widget></my-widget> var WidgetProto = Object.create(HTMLElement.prototype); ! WidgetProto.createdCallback =
function() { this.textContent = "BeltraoInTech"; }; ! var Widget = document.registerElement('my-widget', { prototype: WidgetProto });
Lifecycle Callbacks createdCallback(); attachedCallback(); detachedCallback(); attributeChangedCallback();
Funciona no IE6
None
t polymer-project.org
t x-tags.org
W3C standards platform polyfills Template shadow dom HTML Imports Custom
Elements
Com Polymer <polymer-element name="x-button" attributes="color"> <script> Polymer('x-button', { color: 'red',
created: function() { // ... } }); </script> </polymer-element>
Lifecycle Callbacks Polymer created(); detached(); attributeChanged(); attached();
Template
Templates são pedaços inertes de DOM que podem ser reutilizados.
# GAMBIARRA existe vários Templates para server- side e client-side
<template>
como criar? <template> <p>BeltraoInTech...</p> <img src="beltrao.png"/> </template>
como usar? var tmpl = document.querySelector("#template"); tmpl.content.querySelector("img").src = "dog.gif"; document.body.appendChild(tmpl.content.cloneNode(true));
Shadow DOM
O SHADOW DOM encapsula STYLE e MARCAÇÃO.
<iframe>
Shadow Dom é a mesma tecnologia usada pelos fabricantes de
navegadores para implemetar as tags como <video> e <textarea>.
None
t mas voltaram atrás
exemplo Shadow Dom <div class="widget"></div> var host = document.querySelector(".widget"); var
root = host.createShadowRoot(); root.innerHTML = "<h1>Estou dentro da div</h1>";
Encapsula style, marcação e script
HTML Imports
t importações carregar documentos externos em nossa página.
HTML Import <link rel="import" href="beltra-tech.html">
None
Obrigado TWITTER.COM/MTEUSORTIZ GITHUB.COM/MATEUSORTIZ
More Decks by Mateus Ortiz
See All by Mateus Ortiz
O maravilhoso mundo do front-end... não
mateusortiz
0
160
Desbravando Web Components
mateusortiz
0
71
Web Components: é o Futuro?
mateusortiz
2
200
Other Decks in Programming
See All in Programming
Promiseの向こう側へコンテキストを届ける ― proposal-async-context
seriseri
0
710
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
650
R言語プログラミング
profjoesuzuki
0
120
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
490
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
280
正解の無い問題を 「できるだけ上手く」解く ヒューリスティックで感性を磨こう。〜現実課題をプログラミングで解きあうコミュニティについて〜
allegrogiken
0
120
The Cost of the DOM
ypresto
3
1k
眠らない開発チームの作り方
biwakonbu
0
170
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
310
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
190
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
700
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340
Everyday Curiosity
cassininazir
0
430
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
410
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
310
A Tale of Four Properties
chriscoyier
163
24k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Site-Speed That Sticks
csswizardry
13
1.6k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
320