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

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

Issue 1801293005: Fix cr.exportPath()'s @return signature so the result can be used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: todo Created 4 years, 9 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 | « third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java ('k') | 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 (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 /** 5 /**
6 * The global object. 6 * The global object.
7 * @type {!Object} 7 * @type {!Object}
8 * @const 8 * @const
9 */ 9 */
10 var global = this; 10 var global = this;
11 11
12 /** @typedef {{eventName: string, uid: number}} */ 12 /** @typedef {{eventName: string, uid: number}} */
13 var WebUIListener; 13 var WebUIListener;
14 14
15 /** Platform, package, object property, and Event support. **/ 15 /** Platform, package, object property, and Event support. **/
16 var cr = cr || function() { 16 var cr = cr || function() {
17 'use strict'; 17 'use strict';
18 18
19 /** 19 /**
20 * Builds an object structure for the provided namespace path, 20 * Builds an object structure for the provided namespace path,
21 * ensuring that names that already exist are not overwritten. For 21 * ensuring that names that already exist are not overwritten. For
22 * example: 22 * example:
23 * "a.b.c" -> a = {};a.b={};a.b.c={}; 23 * "a.b.c" -> a = {};a.b={};a.b.c={};
24 * @param {string} name Name of the object that this file defines. 24 * @param {string} name Name of the object that this file defines.
25 * @param {*=} opt_object The object to expose at the end of the path. 25 * @param {*=} opt_object The object to expose at the end of the path.
26 * @param {Object=} opt_objectToExportTo The object to add the path to; 26 * @param {Object=} opt_objectToExportTo The object to add the path to;
27 * default is {@code global}. 27 * default is {@code global}.
28 * @return {!Object} The last object exported, i.e. ('cr.ui' will return the
29 * a reference to the ui dictionary property of window.cr).
dpapad 2016/03/17 18:47:49 Nit: Either put "i.e." within the parentheses, or
Dan Beam 2016/03/17 19:26:58 Done.
28 * @private 30 * @private
29 */ 31 */
30 function exportPath(name, opt_object, opt_objectToExportTo) { 32 function exportPath(name, opt_object, opt_objectToExportTo) {
31 var parts = name.split('.'); 33 var parts = name.split('.');
32 var cur = opt_objectToExportTo || global; 34 var cur = opt_objectToExportTo || global;
33 35
34 for (var part; parts.length && (part = parts.shift());) { 36 for (var part; parts.length && (part = parts.shift());) {
35 if (!parts.length && opt_object !== undefined) { 37 if (!parts.length && opt_object !== undefined) {
36 // last part and we have an object; use it 38 // last part and we have an object; use it
37 cur[part] = opt_object; 39 cur[part] = opt_object;
38 } else if (part in cur) { 40 } else if (part in cur) {
39 cur = cur[part]; 41 cur = cur[part];
40 } else { 42 } else {
41 cur = cur[part] = {}; 43 cur = cur[part] = {};
42 } 44 }
43 } 45 }
44 return cur; 46 return cur;
45 }; 47 }
46 48
47 /** 49 /**
48 * Fires a property change event on the target. 50 * Fires a property change event on the target.
49 * @param {EventTarget} target The target to dispatch the event on. 51 * @param {EventTarget} target The target to dispatch the event on.
50 * @param {string} propertyName The name of the property that changed. 52 * @param {string} propertyName The name of the property that changed.
51 * @param {*} newValue The new value for the property. 53 * @param {*} newValue The new value for the property.
52 * @param {*} oldValue The old value for the property. 54 * @param {*} oldValue The old value for the property.
53 */ 55 */
54 function dispatchPropertyChange(target, propertyName, newValue, oldValue) { 56 function dispatchPropertyChange(target, propertyName, newValue, oldValue) {
55 var e = new Event(propertyName + 'Change'); 57 var e = new Event(propertyName + 'Change');
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 get isLinux() { 471 get isLinux() {
470 return /Linux/.test(navigator.userAgent); 472 return /Linux/.test(navigator.userAgent);
471 }, 473 },
472 474
473 /** Whether this is on Android. */ 475 /** Whether this is on Android. */
474 get isAndroid() { 476 get isAndroid() {
475 return /Android/.test(navigator.userAgent); 477 return /Android/.test(navigator.userAgent);
476 } 478 }
477 }; 479 };
478 }(); 480 }();
OLDNEW
« no previous file with comments | « third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698