1 <!-- 2 -- Copyright 2013 The Chromium Authors. All rights reserved. 3 -- Use of this source code is governed by a BSD-style license that can be 4 -- found in the LICENSE file. 5 --> 6 7 <polymer-element name="kb-key-sequence" attributes="keys superscripts"> 8 <template> 9 <style> 10 @host { 11 * { 12 display: none; 13 } 14 } 15 </style> 16 </template> 17 <script> 18 Polymer('kb-key-sequence', { 19 /** 20 * Generates the DOM structure to replace (expand) this kb-key-sequence. 21 */ 22 generateDom: function() { 23 var result; 24 if (this.keys) { 25 var newKeys = this.keys; 26 var newSuperScripts = this.superscripts; 27 if (newSuperScripts && newKeys.length != newSuperScripts.length) { 28 console.error('keys and superscripts do not match'); 29 return; 30 } 31 var replacement = document.createDocumentFragment(); 32 for (var i = 0; i < newKeys.length; i++) { 33 var key = document.createElement('kb-key'); 34 key.innerText = newKeys[i]; 35 key.accents = newKeys[i]; 36 if (newSuperScripts) 37 key.superscript = newSuperScripts[i]; 38 replacement.appendChild(key); 39 } 40 result = replacement; 41 } 42 return result; 43 } 44 }); 45 </script> 46 </polymer-element> 47