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

Side by Side Diff: ui/webui/resources/js/action_link.js

Issue 2104103002: Convert Event#keyIdentifier (deprecated) to Event#key (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch file manager test Created 4 years, 5 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 | « ui/login/bubble.js ('k') | ui/webui/resources/js/cr/link_controller.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Action links are elements that are used to perform an in-page navigation or 5 // Action links are elements that are used to perform an in-page navigation or
6 // action (e.g. showing a dialog). 6 // action (e.g. showing a dialog).
7 // 7 //
8 // They look like normal anchor (<a>) tags as their text color is blue. However, 8 // They look like normal anchor (<a>) tags as their text color is blue. However,
9 // they're subtly different as they're not initially underlined (giving users a 9 // they're subtly different as they're not initially underlined (giving users a
10 // clue that underlined links navigate while action links don't). 10 // clue that underlined links navigate while action links don't).
(...skipping 26 matching lines...) Expand all
37 37
38 /** @this {ActionLink} */ 38 /** @this {ActionLink} */
39 createdCallback: function() { 39 createdCallback: function() {
40 // Action links can start disabled (e.g. <a is="action-link" disabled>). 40 // Action links can start disabled (e.g. <a is="action-link" disabled>).
41 this.tabIndex = this.disabled ? -1 : 0; 41 this.tabIndex = this.disabled ? -1 : 0;
42 42
43 if (!this.hasAttribute('role')) 43 if (!this.hasAttribute('role'))
44 this.setAttribute('role', 'link'); 44 this.setAttribute('role', 'link');
45 45
46 this.addEventListener('keydown', function(e) { 46 this.addEventListener('keydown', function(e) {
47 if (!this.disabled && e.keyIdentifier == 'Enter' && !this.href) { 47 if (!this.disabled && e.key == 'Enter' && !this.href) {
48 // Schedule a click asynchronously because other 'keydown' handlers 48 // Schedule a click asynchronously because other 'keydown' handlers
49 // may still run later (e.g. document.addEventListener('keydown')). 49 // may still run later (e.g. document.addEventListener('keydown')).
50 // Specifically options dialogs break when this timeout isn't here. 50 // Specifically options dialogs break when this timeout isn't here.
51 // NOTE: this affects the "trusted" state of the ensuing click. I 51 // NOTE: this affects the "trusted" state of the ensuing click. I
52 // haven't found anything that breaks because of this (yet). 52 // haven't found anything that breaks because of this (yet).
53 window.setTimeout(this.click.bind(this), 0); 53 window.setTimeout(this.click.bind(this), 0);
54 } 54 }
55 }); 55 });
56 56
57 function preventDefault(e) { 57 function preventDefault(e) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 removeAttribute: function(attr) { 104 removeAttribute: function(attr) {
105 if (attr.toLowerCase() == 'disabled') 105 if (attr.toLowerCase() == 'disabled')
106 this.disabled = false; 106 this.disabled = false;
107 else 107 else
108 HTMLAnchorElement.prototype.removeAttribute.apply(this, arguments); 108 HTMLAnchorElement.prototype.removeAttribute.apply(this, arguments);
109 }, 109 },
110 }, 110 },
111 111
112 extends: 'a', 112 extends: 'a',
113 }); 113 });
OLDNEW
« no previous file with comments | « ui/login/bubble.js ('k') | ui/webui/resources/js/cr/link_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698