Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. ## In 0.5
  2.  
  3. Implementing `<core-meta>`:
  4.  
  5. ```html
  6. <link rel="import" href="../core-meta/core-meta.html">
  7. <polymer-element name="core-foo" extends="core-meta">
  8. <script>
  9. Polymer('core-foo', {
  10. ready: function () {
  11. this.super();
  12. // etc..
  13. }
  14. });
  15. </script>
  16. </polymer-element>
  17. ```
  18.  
  19. Accessing `<core-meta>`:
  20.  
  21. ```html
  22. <link rel="import" href="../core-foo/core-foo.html">
  23. <polymer-element name="core-bar">
  24. <script>
  25. (function () {
  26. var meta;
  27.  
  28. Polymer('core-bar', {
  29. ready: function () {
  30. if (!meta) {
  31. meta = document.createElement('core-meta');
  32. }
  33. },
  34.  
  35. accessFoo: function () {
  36. var fooInstance = meta.byId('fooId');
  37. // etc..
  38. }
  39. });
  40. })();
  41. </script>
  42. </polymer-element>
  43. ```
  44.  
  45. ## In 0.8
  46.  
  47. Implementing `<core-meta>`:
  48.  
  49. ```html
  50. <link rel="import" href="../core-meta/core-meta.html">
  51. <template>
  52. <core-meta type="fooType" id="fooId" value="[[]]"></core-meta>
  53. </template>
  54. <script>
  55. Polymer({
  56. is: 'core-foo'
  57.  
  58. // etc..
  59. });
  60. </script>
  61. ```
  62.  
  63. Accessing `<core-meta>`:
  64.  
  65. ```html
  66. <link rel="import" href="../core-meta/core-meta.html">
  67. <template>
  68. <core-meta type="fooType" id="fooId"></core-meta>
  69. </template>
  70. <script>
  71. Polymer({
  72. is: 'core-bar',
  73.  
  74. accessFoo: function () {
  75. var fooInstance = this.$.fooId.value;
  76. // etc..
  77. }
  78. });
  79. </script>
  80. ```
  81.  
  82. ### 0.8 Mixin
  83.  
  84. Implementing core-meta:
  85.  
  86. ```html
  87. <link rel="import" href="../core-meta/core-meta.html">
  88.  
  89. <script>
  90.  
  91. using(['CoreMeta'], function(CoreMeta) {
  92. Polymer({
  93. is: 'core-foo',
  94.  
  95. getInitialMeta: function() {
  96. return {type: 'fooType', id: 'fooId', value: '[[]]'};
  97. },
  98.  
  99. mixins: [CoreMeta],
  100.  
  101. // etc...
  102. });
  103. });
  104.  
  105. </script>
  106. ```
  107.  
  108. Accessing core-meta:
  109.  
  110. ```html
  111. <link rel="import" href="../core-meta/core-meta.html">
  112.  
  113. <script>
  114.  
  115. using(['CoreMeta'], function(CoreMeta) {
  116. Polymer({
  117. is: 'core-bar',
  118.  
  119. mixins: [CoreMeta],
  120.  
  121. accessFoo: function () {
  122. var fooInstance = this.meta.byId('fooId').value;
  123. // etc..
  124. }
  125. });
  126. });
  127.  
  128. </script>
  129. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement