Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 })(); | |
| OLD | NEW |