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

Side by Side Diff: mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl

Issue 2930423002: Mojo JS bindings: convert relative path to URL properly. (Closed)
Patch Set:  Created 3 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 {%- if use_new_js_bindings %} 5 {%- if use_new_js_bindings %}
6 6
7 'use strict'; 7 'use strict';
8 8
9 (function() { 9 (function() {
10 var mojomId = '{{module.path}}'; 10 var mojomId = '{{module.path}}';
11 if (mojo.internal.isMojomLoaded(mojomId)) { 11 if (mojo.internal.isMojomLoaded(mojomId)) {
12 console.warn('The following mojom is loaded multiple times: ' + mojomId); 12 console.warn('The following mojom is loaded multiple times: ' + mojomId);
13 return; 13 return;
14 } 14 }
15 mojo.internal.markMojomLoaded(mojomId); 15 mojo.internal.markMojomLoaded(mojomId);
16 16
17 // TODO(yzshen): Define these aliases to minimize the differences between the 17 // TODO(yzshen): Define these aliases to minimize the differences between the
18 // old/new modes. Remove them when the old mode goes away. 18 // old/new modes. Remove them when the old mode goes away.
19 var bindings = mojo; 19 var bindings = mojo;
20 var associatedBindings = mojo; 20 var associatedBindings = mojo;
21 var codec = mojo.internal; 21 var codec = mojo.internal;
22 var validator = mojo.internal; 22 var validator = mojo.internal;
23 23
24 {%- for import in imports %} 24 {%- for import in imports %}
25 var {{import.unique_name}} = 25 var {{import.unique_name}} =
26 mojo.internal.exposeNamespace('{{import.namespace}}'); 26 mojo.internal.exposeNamespace('{{import.namespace}}');
27 if (mojo.config.autoLoadMojomDeps) { 27 if (mojo.config.autoLoadMojomDeps) {
28 mojo.internal.loadMojomIfNecessary( 28 mojo.internal.loadMojomIfNecessary(
29 '{{import.path}}', 29 '{{import.path}}',
30 new URL('{{import|get_relative_path(module)}}.js', 30 new URL('{{import|get_relative_url(module)}}.js',
31 document.currentScript.src).href); 31 document.currentScript.src).href);
32 } 32 }
33 {%- endfor %} 33 {%- endfor %}
34 34
35 {% include "module_definition.tmpl" %} 35 {% include "module_definition.tmpl" %}
36 })(); 36 })();
37 37
38 {%- else %} 38 {%- else %}
39 39
40 define("{{module.path}}", [ 40 define("{{module.path}}", [
(...skipping 21 matching lines...) Expand all
62 , {{import.unique_name}} 62 , {{import.unique_name}}
63 {%- endfor -%} 63 {%- endfor -%}
64 ) { 64 ) {
65 65
66 {%- include "module_definition.tmpl" %} 66 {%- include "module_definition.tmpl" %}
67 67
68 return exports; 68 return exports;
69 }); 69 });
70 70
71 {%- endif %} 71 {%- endif %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698