Chromium Code Reviews| Index: mojo/public/js/new_bindings/base.js |
| diff --git a/mojo/public/js/new_bindings/base.js b/mojo/public/js/new_bindings/base.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..31173957a4790d0bf3e23e16740116a4d0900b10 |
| --- /dev/null |
| +++ b/mojo/public/js/new_bindings/base.js |
| @@ -0,0 +1,31 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +if (mojoBindings) { |
| + throw new Error("mojoBindings has been initialized."); |
| +} |
| + |
| +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
|
| +mojoBindings.internal = {}; |
| +mojoBindings.internal.global = this; |
| + |
| +(function() { |
| + var internal = mojoBindings.internal; |
| + |
| + function exposeNamespace(namespace) { |
| + var current = internal.global; |
| + var parts = namespace.split('.'); |
| + |
| + for (var part; parts.length && (part = parts.shift());) { |
| + if (!current[part]) { |
| + current[part] = {}; |
| + } |
| + current = current[part]; |
| + } |
| + |
| + return current; |
| + } |
| + |
| + internal.exposeNamespace = exposeNamespace; |
| +})(); |