summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorvitalyp <vitalyp@chromium.org>2014-09-16 16:14:24 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-16 23:14:37 +0000
commit730652530d108372ef14f62b89665197628f7880 (patch)
tree5eb8c05330e20dd10781a1fa12acbe6cc55930eb /ui
parent2bc038699947d1b05b15d35c5c5b3d4eac934f5d (diff)
downloadchromium_src-730652530d108372ef14f62b89665197628f7880.zip
chromium_src-730652530d108372ef14f62b89665197628f7880.tar.gz
chromium_src-730652530d108372ef14f62b89665197628f7880.tar.bz2
Add public API generation with cr.makePublic() and handle it in compiler pass
R=dbeam@chromium.org,tbreisacher@chromium.org BUG=393873 TEST=third_party/closure_compiler/runner/how_to_test_compiler_pass.md Review URL: https://codereview.chromium.org/557633002 Cr-Commit-Position: refs/heads/master@{#295173}
Diffstat (limited to 'ui')
-rw-r--r--ui/webui/resources/js/cr.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/webui/resources/js/cr.js b/ui/webui/resources/js/cr.js
index 94c7553..95b2cee 100644
--- a/ui/webui/resources/js/cr.js
+++ b/ui/webui/resources/js/cr.js
@@ -294,6 +294,23 @@ var cr = function() {
};
}
+ /**
+ * Forwards public APIs to private implementations.
+ * @param {Function} ctor Constructor that have private implementations in its
+ * prototype.
+ * @param {Array.<string>} methods List of public method names that have their
+ * underscored counterparts in constructor's prototype.
+ * @param {*=} opt_target Target node.
+ */
+ function makePublic(ctor, methods, opt_target) {
+ methods.forEach(function(method) {
+ ctor[method] = function() {
+ var target = opt_target || ctor.getInstance();
+ return target[method + '_'].apply(target, arguments);
+ };
+ });
+ }
+
return {
addSingletonGetter: addSingletonGetter,
createUid: createUid,
@@ -303,6 +320,7 @@ var cr = function() {
dispatchSimpleEvent: dispatchSimpleEvent,
exportPath: exportPath,
getUid: getUid,
+ makePublic: makePublic,
PropertyKind: PropertyKind,
get doc() {