<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>My Great Page</title></head>
<body>
<h1>Yeah! Internet!</h1>
</body>
</html>
<twttr-typeahead source="http://mysite.com/api/">
<local-storage id="storage" name="my-namespace"></local-storage>
<todo-database id="model" storageId="storage"></todo-database>
<todo-items modelId="model">
<todo-item>A todo</todo-item>
<todo-item completed>A completed item</todo-item>
</todo-items>
<todo-list id="my-todos"></todo-list>
A return to tags marks the start of the extendable web
Custom Elements is a bedrock API. We should be able to build all HTML elements with it.
OK | -- | |
OK | update to document.register needed | |
Partial | using Blink, a step behind Chrome | |
None | -- | |
None | -- |
<my-carousel>
<my-carousel-item>one</my-carousel-item>
<my-carousel-item>two</my-carousel-item>
<my-carousel-item>three</my-carousel-item>
</my-carousel>
<script type="text/x-handlebars" data-template-name="index">
{{#e-carousel}}
<e-carousel-item>one</e-carousel-item>
<e-carousel-item>two</e-carousel-item>
<e-carousel-item>three</e-carousel-item>
{{/e-carousel}}
</script>
{{#e-carousel}}
instantiates the componentcomponents/e-carousel
marks the stamped out template{{yield}}
captures our original nodes{{#e-carousel}}
becomes App.ECarouselComponent = Ember.Component.extend...
<script type="text/x-handlebars" data-template-name="components/e-carousel">
<content>{{yield}}</content>
<-- ... -->
</script>
App.ECarouselComponent = Ember.Component.extend({
var $items = this.$('content e-carousel-item');
$items.hide();
$items.each(function(idx, item) {
// ...
});
// ...
});
<r-carousel>
<r-carousel-item>one</r-carousel-item>
<r-carousel-item>two</r-carousel-item>
<r-carousel-item>three</r-carousel-item>
</r-carousel>
<script type="text/jsx">
/** @jsx React.DOM */
var rCarousel = React.createClass({
getInitialState: function() {
var items = [],
results = this.props._content.querySelectorAll('r-carousel-item');
// ...
return {index: 0, items: items};
},
render: function() {
}
});
document.registerReact('r-carousel', rCarousel);
</script>
<ang-carousel ang-component>
<ang-carousel-item>one</ang-carousel-item>
<ang-carousel-item>two</ang-carousel-item>
<ang-carousel-item>three</ang-carousel-item>
</ang-carousel>
restrict
type of "E" parallel custom elements<ang-template for="ang-*">
can stamp out your templatesangular.bootstrap
on page load$transclude
function can give you access to the original content in your directive
<ang-template for="ang-carousel"><-- ... --></ang-template>
angular.module('angCarousel', [])
.directive('angCarousel', function () {
var tmpl = document.querySelector('ang-template[for="ang-carousel"]');
return {
restrict: 'E', transclude: true,
controller: function($scope, $transclude) {
$transclude(function(originalNodes) {
});
// ...
}
};
});
<p-carousel>
<p-carousel-item>one</p-carousel-item>
<p-carousel-item>two</p-carousel-item>
<p-carousel-item>three</p-carousel-item>
</p-carousel>
<polymer-element name="*" noscript>
defines a custom element<script>
and <style>
tags are restricted in scope
<polymer-element name="p-carousel" noscript>
<template>
<content id="content" select="p-carousel-item"></content>
<!-- ... -->
</template>
<script>
Polymer({
attached: function() {
var self = this,
contents = this.$.content.getDistributedNodes();
// ...
}
});
</script>
</polymer-element>
Components written in Angular will export to Web Components (to be used by Polymer, Ember, or any other framework/library)
Ember templates should support elements implemented in Polymer.
We have a few new tricks this time
View these slides online @ felocity.com/owc6