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

Side by Side Diff: pkg/html_import/lib/tools/loader/loader.js

Issue 158083002: introduce web_components pkg for consolidated polyfills (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/html_import/lib/src/boot.js ('k') | pkg/html_import/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 The Polymer Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
5 */
6
7 (function() {
8
9 var scope = window.Loader = {};
10 var flags = {};
11
12 // convert url arguments to flags
13
14 if (!flags.noOpts) {
15 location.search.slice(1).split('&').forEach(function(o) {
16 o = o.split('=');
17 o[0] && (flags[o[0]] = o[1] || true);
18 });
19 }
20
21 // process global logFlags
22
23 parseLogFlags(flags);
24
25 function load(scopeName) {
26 // imports
27
28 var scope = window[scopeName];
29 var entryPointName = scope.entryPointName;
30 var processFlags = scope.processFlags;
31
32 // acquire attributes and base path from entry point
33
34 var entryPoint = findScript(entryPointName);
35 var base = entryPoint.basePath;
36
37 // acquire common flags
38 var flags = Loader.flags;
39
40 // convert attributes to flags
41 var flags = Loader.flags;
42 for (var i=0, a; (a=entryPoint.attributes[i]); i++) {
43 if (a.name !== 'src') {
44 flags[a.name] = a.value || true;
45 }
46 }
47
48 // parse log flags into global
49 parseLogFlags(flags);
50
51 // exports
52
53 scope.basePath = base;
54 scope.flags = flags;
55
56 // process flags for dynamic dependencies
57
58 if (processFlags) {
59 processFlags.call(scope, flags);
60 }
61
62 // post-process imports
63
64 var modules = scope.modules || [];
65 var sheets = scope.sheets || [];
66
67 // write script tags for dependencies
68
69 modules.forEach(function(src) {
70 document.write('<script src="' + base + src + '"></script>');
71 });
72
73 // write link tags for styles
74
75 sheets.forEach(function(src) {
76 document.write('<link rel="stylesheet" href="' + base + src + '">');
77 });
78 }
79
80 // utility method
81
82 function findScript(fileName) {
83 var script = document.querySelector('script[src*="' + fileName + '"]');
84 var src = script.attributes.src.value;
85 script.basePath = src.slice(0, src.indexOf(fileName));
86 return script;
87 }
88
89 function parseLogFlags(flags) {
90 var logFlags = window.logFlags = window.logFlags || {};
91 if (flags.log) {
92 flags.log.split(',').forEach(function(f) {
93 logFlags[f] = true;
94 });
95 }
96 }
97
98 scope.flags = flags;
99 scope.load = load;
100
101 })();
OLDNEW
« no previous file with comments | « pkg/html_import/lib/src/boot.js ('k') | pkg/html_import/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698