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

Side by Side Diff: mojo/public/js/new_bindings/base.js

Issue 2759563004: Mojo JS bindings: change module loading solution. (Closed)
Patch Set: add test module-loading.html Created 3 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 if (mojoBindings) {
6 throw new Error("mojoBindings has been initialized.");
7 }
8
9 var mojoBindings = {};
Ken Rockot(use gerrit already) 2017/03/20 15:27:20 I wonder about naming here, but it's kind of just
yzshen1 2017/03/20 17:45:02 According to JS style guide, namespace should be n
Ken Rockot(use gerrit already) 2017/03/21 16:42:43 I agree with this rationale, so SGTM. In fact I wa
alokp 2017/03/27 01:56:25 Bikeshed: I find mojoBindings ugly :) I am open t
10 mojoBindings.internal = {};
11 mojoBindings.internal.global = this;
12
13 (function() {
14 var internal = mojoBindings.internal;
15
16 function exposeNamespace(namespace) {
17 var current = internal.global;
18 var parts = namespace.split('.');
19
20 for (var part; parts.length && (part = parts.shift());) {
21 if (!current[part]) {
22 current[part] = {};
23 }
24 current = current[part];
25 }
26
27 return current;
28 }
29
30 internal.exposeNamespace = exposeNamespace;
31 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698