20. HTML Import
• 다른 문서를 현재 문서에 포함시켜 재사용하는 방법
• 실제로 페이지 DOM에 포함되지 않음
• 페이지 자체를 다른 영역에 두고 관리
• HTML외에 CSS,JS도 가져올 수 있음
21. HTML Import
[main.html]
<head><link rel="import" href="warnings.html"></head>
<body><script>
var link = document.querySelector(‚link[rel="import"]‛);
var content = link.import; // Grab DOM from warning.html's
document.
var el = content.querySelector(“.warning”);
document.body.appendChild(el.cloneNode(true));
</script></body>
[warnings.html]
<div class="warning">
<style scoped> h3 { color: red; } </style>
<h3>Warning!</h3> <p>This page is under construction</p></div>
<div class="outdated"><h3>Heads up!</h3>
<p>This content may be out of date</p></div>
22. Web Component 예제
Custom Elements, Shadow DOM, Template Tag,
Lifecycle Callback을 활용핚 Web Component 예제
(DEMO)
23. 하지만..
• Custom Elements
• Shadow DOM
• Template Tag
• HTML Import
=> (All X)
=> (Chrome,Opera O)
=> (IE X)
=> (All X)
24. Polymer.js
• Google 에서 개발핚 라이브러리
• Polyfill을 통핚 모든 브라우저에 사용 가능하도록 대응
• Web Component를 쉽게 사용하고 만들도록 도와줌
33. Why Polymer?
• 웹 페이지가 시멘틱해지고 단순해짐
• 모듈화가 잘 되어 있어 사용하기 쉽고 재사용의 이점
• 동작하는 영역이 분리되어 성능 좋음
• Light DOM을 이용, 웹 접근성이 좋음
• 근 미래에 컴포넌트의 표준이 될 가능성 높음
34. • Angular.js, Ember.js, Dart 에 차용될 예정
• 더 나은 웹 생태계를 위해 W3C 표준안으로 채택되도록
끊임없이 연구하고 푸시하는 중
• Experimental? But Web Evolution!!
• http://polymer-project.org
Future of Polymer.js