Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/chromevox/injected/api.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api.js |
| index ee366e312521a038ba2180f0a8d6bef52f697750..674a939e316e9dce0cce63f75d68404d24a654f5 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api.js |
| @@ -128,20 +128,39 @@ if (typeof(goog) != 'undefined' && goog.require) { |
| callAsync_(message, callback); |
| }; |
| + /** |
| + * @param {string} path |
| + * @return {*} |
| + */ |
| + function getPath(path) { |
|
dmazzoni
2017/03/20 18:16:15
Could you name this something more clear and/or ad
|
| + var pieces = path.split('.'); |
| + var resolved = window; |
| + for (var i = 0; i < pieces.length; i++) { |
| + resolved = resolved[pieces[i]]; |
| + if (!resolved) |
| + return null; |
|
dmazzoni
2017/03/20 18:16:15
nit: indent
|
| + } |
| + return resolved; |
| + } |
| + |
| /** |
| * Maybe enable MathJaX support. |
| */ |
| - function maybeEnableMathJaX() { |
| - if (!MathJax || !MathJax.Hub || !MathJax.Hub.Register || |
| - !MathJax.Hub.Register.LoadHook) |
| + function maybeEnableMathJaX() { |
| + if (!getPath('MathJax.Hub.Register.LoadHook') || |
| + !getPath('MathJax.Ajax.Require')) { |
| return; |
| + } |
| - MathJax.Hub.Register.LoadHook( |
| - '[a11y]/explorer.js', |
| - function() { |
| - MathJax.Extension.explorer.Enable(true, true); |
| - }); |
| + MathJax.Hub.Register.LoadHook('[a11y]/explorer.js', function() { |
| + // |explorer| is an object instance, so we get it to call an instance |
| + // |method. |
| + var explorer = getPath('MathJax.Extension.explorer'); |
| + if (explorer.Enable) { |
| + explorer.Enable(true, true); |
| + } |
| + }); |
| MathJax.Ajax.Require('[a11y]/explorer.js'); |
| } |