Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: chrome/browser/resources/extensions/extension_error.js

Issue 1277833003: Re-use local variable instead of querySelector()ing it again (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 cr.define('extensions', function() { 5 cr.define('extensions', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Clone a template within the extension error template collection. 9 * Clone a template within the extension error template collection.
10 * @param {string} templateName The class name of the template to clone. 10 * @param {string} templateName The class name of the template to clone.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 var iconNode = document.createElement('img'); 107 var iconNode = document.createElement('img');
108 iconNode.className = 'extension-error-icon'; 108 iconNode.className = 'extension-error-icon';
109 // TODO(hcarmona): Populate alt text with a proper description since this 109 // TODO(hcarmona): Populate alt text with a proper description since this
110 // icon conveys the severity of the error. (info, warning, fatal). 110 // icon conveys the severity of the error. (info, warning, fatal).
111 iconNode.alt = ''; 111 iconNode.alt = '';
112 this.insertBefore(iconNode, this.firstChild); 112 this.insertBefore(iconNode, this.firstChild);
113 113
114 var messageSpan = this.querySelector('.extension-error-message'); 114 var messageSpan = this.querySelector('.extension-error-message');
115 messageSpan.textContent = error.message; 115 messageSpan.textContent = error.message;
116 116
117 var deleteButton = this.querySelector('.error-delete-button'); 117 var deleteButton = this.querySelector('.error-delete-button');
Dan Beam 2015/08/11 00:48:56 ^
118 deleteButton.addEventListener('click', function(e) { 118 deleteButton.addEventListener('click', function(e) {
119 this.dispatchEvent( 119 this.dispatchEvent(
120 new CustomEvent('deleteExtensionError', 120 new CustomEvent('deleteExtensionError',
121 {bubbles: true, detail: this.error})); 121 {bubbles: true, detail: this.error}));
122 }.bind(this)); 122 }.bind(this));
123 123
124 this.addEventListener('click', function(e) { 124 this.addEventListener('click', function(e) {
125 if (e.target != deleteButton) 125 if (e.target != deleteButton)
126 this.requestActive_(); 126 this.requestActive_();
127 }.bind(this)); 127 }.bind(this));
128 this.addEventListener('keydown', function(e) { 128 this.addEventListener('keydown', function(e) {
129 if (e.keyIdentifier == 'Enter' && e.target != deleteButton) 129 if (e.keyIdentifier == 'Enter' && e.target != deleteButton)
130 this.requestActive_(); 130 this.requestActive_();
131 }); 131 });
132 132
133 this.addFocusableElement(this); 133 this.addFocusableElement(this);
134 this.addFocusableElement(this.querySelector('.error-delete-button')); 134 this.addFocusableElement(deleteButton);
hcarmona 2015/08/11 01:39:35 I'm curious how this behaves because |this| and |d
Dan Beam 2015/08/11 01:41:55 Acknowledged.
135 }, 135 },
136 136
137 /** 137 /**
138 * Bubble up an event to request to become active. 138 * Bubble up an event to request to become active.
139 * @private 139 * @private
140 */ 140 */
141 requestActive_: function() { 141 requestActive_: function() {
142 this.dispatchEvent( 142 this.dispatchEvent(
143 new CustomEvent('highlightExtensionError', 143 new CustomEvent('highlightExtensionError',
144 {bubbles: true, detail: this.error})); 144 {bubbles: true, detail: this.error}));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 onFocus_: function() { 375 onFocus_: function() {
376 var activeRow = this.gridBoundary_.querySelector('.focus-row-active'); 376 var activeRow = this.gridBoundary_.querySelector('.focus-row-active');
377 activeRow.getEquivalentElement(null).focus(); 377 activeRow.getEquivalentElement(null).focus();
378 }, 378 },
379 }; 379 };
380 380
381 return { 381 return {
382 ExtensionErrorList: ExtensionErrorList 382 ExtensionErrorList: ExtensionErrorList
383 }; 383 };
384 }); 384 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698