OLD | NEW |
---|---|
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 /** | 5 /** |
6 * @fileoverview A collection of JavaScript utilities used to simplify working | 6 * @fileoverview A collection of JavaScript utilities used to simplify working |
7 * with the DOM. | 7 * with the DOM. |
8 */ | 8 */ |
9 | 9 |
10 | 10 |
(...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2440 * @param {Node} node The node to be tested. | 2440 * @param {Node} node The node to be tested. |
2441 * @return {boolean} Whether or not a node has an image with class TeX or LaTeX. | 2441 * @return {boolean} Whether or not a node has an image with class TeX or LaTeX. |
2442 */ | 2442 */ |
2443 cvox.DomUtil.isMathImg = function(node) { | 2443 cvox.DomUtil.isMathImg = function(node) { |
2444 if (!node || !node.tagName || !node.className) { | 2444 if (!node || !node.tagName || !node.className) { |
2445 return false; | 2445 return false; |
2446 } | 2446 } |
2447 if (node.tagName != 'IMG') { | 2447 if (node.tagName != 'IMG') { |
2448 return false; | 2448 return false; |
2449 } | 2449 } |
2450 var className = node.className.toLowerCase(); | 2450 return node.className.toLowerCase().split(' ').some(function(className) { |
dmazzoni
2015/01/14 08:20:34
Can you use classList.contains? Or at least, itera
David Tseng
2015/01/14 18:17:35
No; since the current code lower cases the classna
| |
2451 return cvox.DomUtil.ALT_MATH_CLASSES.tex.indexOf(className) != -1 || | 2451 return cvox.DomUtil.ALT_MATH_CLASSES.tex.indexOf(className) != -1 || |
2452 cvox.DomUtil.ALT_MATH_CLASSES.asciimath.indexOf(className) != -1; | 2452 cvox.DomUtil.ALT_MATH_CLASSES.asciimath.indexOf(className) != -1; |
2453 }); | |
2453 }; | 2454 }; |
2454 | 2455 |
2455 | 2456 |
2456 /** | 2457 /** |
2457 * Checks to see whether a node is a MathML node. | 2458 * Checks to see whether a node is a MathML node. |
2458 * !! This is necessary as Chrome currently does not upperCase Math tags !! | 2459 * !! This is necessary as Chrome currently does not upperCase Math tags !! |
2459 * @param {Node} node The node to be tested. | 2460 * @param {Node} node The node to be tested. |
2460 * @return {boolean} Whether or not a node is a MathML node. | 2461 * @return {boolean} Whether or not a node is a MathML node. |
2461 */ | 2462 */ |
2462 cvox.DomUtil.isMathml = function(node) { | 2463 cvox.DomUtil.isMathml = function(node) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2592 var describedNode = document.getElementById(describedById); | 2593 var describedNode = document.getElementById(describedById); |
2593 if (describedNode) { | 2594 if (describedNode) { |
2594 desc += ' ' + cvox.DomUtil.getName( | 2595 desc += ' ' + cvox.DomUtil.getName( |
2595 describedNode, true, true, true); | 2596 describedNode, true, true, true); |
2596 } | 2597 } |
2597 } | 2598 } |
2598 } | 2599 } |
2599 } | 2600 } |
2600 return desc; | 2601 return desc; |
2601 }; | 2602 }; |
OLD | NEW |