| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 Polymer({ | 5 Polymer({ |
| 6 is: 'history-searched-label', | 6 is: 'history-searched-label', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 // The text to show in this label. | 9 // The text to show in this label. |
| 10 title: String, | 10 title: String, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 if (this.searchTerm == '' || this.searchTerm == null) { | 27 if (this.searchTerm == '' || this.searchTerm == null) { |
| 28 this.textContent = titleText; | 28 this.textContent = titleText; |
| 29 return; | 29 return; |
| 30 } | 30 } |
| 31 | 31 |
| 32 var re = new RegExp(quoteString(this.searchTerm), 'gim'); | 32 var re = new RegExp(quoteString(this.searchTerm), 'gim'); |
| 33 var match; | 33 var match; |
| 34 this.textContent = ''; | 34 this.textContent = ''; |
| 35 while (match = re.exec(titleText)) { | 35 while (match = re.exec(titleText)) { |
| 36 if (match.index > i) | 36 if (match.index > i) |
| 37 this.appendChild(document.createTextNode( | 37 this.appendChild( |
| 38 titleText.slice(i, match.index))); | 38 document.createTextNode(titleText.slice(i, match.index))); |
| 39 i = re.lastIndex; | 39 i = re.lastIndex; |
| 40 // Mark the highlighted text in bold. | 40 // Mark the highlighted text in bold. |
| 41 var b = document.createElement('b'); | 41 var b = document.createElement('b'); |
| 42 b.textContent = titleText.substring(match.index, i); | 42 b.textContent = titleText.substring(match.index, i); |
| 43 this.appendChild(b); | 43 this.appendChild(b); |
| 44 } | 44 } |
| 45 if (i < titleText.length) | 45 if (i < titleText.length) |
| 46 this.appendChild( | 46 this.appendChild(document.createTextNode(titleText.slice(i))); |
| 47 document.createTextNode(titleText.slice(i))); | |
| 48 }, | 47 }, |
| 49 }); | 48 }); |
| OLD | NEW |