Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // <include src="assert.js"> | 5 // <include src="assert.js"> |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Alias for document.getElementById. Found elements must be HTMLElements. | 8 * Alias for document.getElementById. Found elements must be HTMLElements. |
| 9 * @param {string} id The ID of the element to find. | 9 * @param {string} id The ID of the element to find. |
| 10 * @return {HTMLElement} The found element or null if not found. | 10 * @return {HTMLElement} The found element or null if not found. |
| 11 */ | 11 */ |
| 12 function $(id) { | 12 function $(id) { |
| 13 // Disable getElementById restriction here, since we are instructing other | |
| 14 // places to re-use the $() that is defined here. | |
| 15 // eslint-disable-next-line no-restricted-properties | |
| 13 var el = document.getElementById(id); | 16 var el = document.getElementById(id); |
| 14 return el ? assertInstanceof(el, HTMLElement) : null; | 17 return el ? assertInstanceof(el, HTMLElement) : null; |
| 15 } | 18 } |
| 16 | 19 |
| 17 // TODO(devlin): This should return SVGElement, but closure compiler is missing | 20 // TODO(devlin): This should return SVGElement, but closure compiler is missing |
| 18 // those externs. | 21 // those externs. |
| 19 /** | 22 /** |
| 20 * Alias for document.getElementById. Found elements must be SVGElements. | 23 * Alias for document.getElementById. Found elements must be SVGElements. |
| 21 * @param {string} id The ID of the element to find. | 24 * @param {string} id The ID of the element to find. |
| 22 * @return {Element} The found element or null if not found. | 25 * @return {Element} The found element or null if not found. |
| 23 */ | 26 */ |
| 24 function getSVGElement(id) { | 27 function getSVGElement(id) { |
| 25 var el = document.getElementById(id); | 28 var el = $(id); |
|
dpapad
2017/06/06 19:25:51
Well, that was the culprit for the failing tests.
| |
| 26 return el ? assertInstanceof(el, Element) : null; | 29 return el ? assertInstanceof(el, Element) : null; |
| 27 } | 30 } |
| 28 | 31 |
| 29 /** | 32 /** |
| 30 * Add an accessible message to the page that will be announced to | 33 * Add an accessible message to the page that will be announced to |
| 31 * users who have spoken feedback on, but will be invisible to all | 34 * users who have spoken feedback on, but will be invisible to all |
| 32 * other users. It's removed right away so it doesn't clutter the DOM. | 35 * other users. It's removed right away so it doesn't clutter the DOM. |
| 33 * @param {string} msg The text to be pronounced. | 36 * @param {string} msg The text to be pronounced. |
| 34 */ | 37 */ |
| 35 function announceAccessibleMessage(msg) { | 38 function announceAccessibleMessage(msg) { |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 }); | 534 }); |
| 532 } | 535 } |
| 533 | 536 |
| 534 /** | 537 /** |
| 535 * @param {!Event} e | 538 * @param {!Event} e |
| 536 * @return {boolean} Whether a modifier key was down when processing |e|. | 539 * @return {boolean} Whether a modifier key was down when processing |e|. |
| 537 */ | 540 */ |
| 538 function hasKeyModifiers(e) { | 541 function hasKeyModifiers(e) { |
| 539 return !!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey); | 542 return !!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey); |
| 540 } | 543 } |
| OLD | NEW |