1 <h1>Web Components example</h1>2 3 <!--<link rel="import" href="/path/to/imports/stuff.html">-->4 5 <style type="text/css">6 7 8 9 10 11 </style>12 13 14 15 16 <script type="text/javascript">17 'use strict';18 19 var xFaceProto = Object.create(HTMLElement.prototype);20 21 Object.defineProperty(xFaceProto, 'ref', {22 set: function(data) {23 console.log('call to set');24 console.log(data);25 }26 });27 28 xFaceProto.createdCallback = function(){29 console.log('call to createdCallback');30 31 this.setAttribute('ref', 'hello');32 };33 34 var xFace = document.registerElement('x-face', {35 prototype: xFaceProto36 });37 </script>38 39 40 <x-face id="cara" ref="uno dos tres"> esto es un x-face ! </x-face>41 42 43 <script type="text/javascript">44 var cara = document.getElementById('cara');45 46 setTimeout(function(){47 cara.ref = 'timmeeeer';48 }, 2000);49 50 </script>51
Enlace
El enlace para compartir es: